Skip to content
This repository was archived by the owner on Sep 14, 2019. It is now read-only.

Commit aaf8666

Browse files
committed
2 parents 8574583 + 2ac79eb commit aaf8666

9 files changed

Lines changed: 97 additions & 46 deletions

File tree

.DS_Store

-6 KB
Binary file not shown.

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
bin/
2+
build/
3+
dist/
4+
.DS_Store

Robot2018/.gitignore

Lines changed: 0 additions & 3 deletions
This file was deleted.

Robot2018/src/org/usfirst/frc/team199/Robot2018/commands/Autonomous.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.usfirst.frc.team199.Robot2018.commands;
22

3+
import edu.wpi.first.wpilibj.DriverStation;
34
import edu.wpi.first.wpilibj.command.CommandGroup;
45

56
/**
@@ -55,7 +56,15 @@ public double getDelay() {
5556
// TODO
5657
return 0;
5758
}
58-
59+
60+
/**
61+
* {@inheritDoc}
62+
*/
63+
@Override
64+
public String getFMS() {
65+
return DriverStation.getInstance().getGameSpecificMessage();
66+
}
67+
5968
/**
6069
* {@inheritDoc}
6170
*/

Robot2018/src/org/usfirst/frc/team199/Robot2018/commands/AutonomousInterface.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ public enum Strategy {
4747
*
4848
* @return FMS data
4949
*/
50-
default String getFMS() {
51-
return DriverStation.getInstance().getGameSpecificMessage();
52-
}
50+
public String getFMS();
5351

5452
/**
5553
* Pick the script to run for Autonomous
Lines changed: 50 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,62 @@
11
package org.usfirst.frc.team199.Robot2018.commands;
22

3+
import java.util.ArrayList;
4+
import java.util.Arrays;
5+
import java.util.Map;
6+
7+
import org.usfirst.frc.team199.Robot2018.Robot;
8+
9+
import edu.wpi.first.wpilibj.Timer;
310
import edu.wpi.first.wpilibj.command.CommandGroup;
11+
import edu.wpi.first.wpilibj.command.WaitCommand;
412

513
/**
614
* Gets the script name and runs the script.
715
*/
816
public class RunScript extends CommandGroup implements RunScriptInterface {
917

1018
public RunScript(String scriptName) {
11-
// TODO
12-
13-
// Add Commands here:
14-
// e.g. addSequential(new Command1());
15-
// addSequential(new Command2());
16-
// these will run in order.
17-
18-
// To run multiple commands at the same time,
19-
// use addParallel()
20-
// e.g. addParallel(new Command1());
21-
// addSequential(new Command2());
22-
// Command1 and Command2 will run in parallel.
23-
24-
// A command group will require all of the subsystems that each member
25-
// would require.
26-
// e.g. if Command1 requires chassis, and Command2 requires arm,
27-
// a CommandGroup containing them would require both the chassis and the
28-
// arm.
19+
ArrayList<String> script = Robot.autoScripts.getOrDefault(scriptName, new ArrayList<String>());
20+
21+
outerloop:
22+
for(String cmd : script) {
23+
String[] cmdParts = cmd.split(" ");
24+
String cmdName = cmdParts[0];
25+
String[] cmdArgs = Arrays.copyOfRange(cmdParts, 1, cmdParts.length);
26+
27+
switch (cmdParts[0]) {
28+
case "moveto":
29+
addSequential(new AutoMoveTo(cmdArgs));
30+
break;
31+
case "turn":
32+
addSequential(new AutoTurn(cmdArgs[0]));
33+
break;
34+
case "move":
35+
addSequential(new AutoMove(cmdArgs[0]));
36+
break;
37+
case "switch":
38+
addSequential(new EjectToSwitch());
39+
break;
40+
case "scale":
41+
addSequential(new EjectToScale());
42+
break;
43+
case "exchange":
44+
addSequential(new EjectToExchange());
45+
break;
46+
case "wait":
47+
addSequential(new WaitCommand(Double.parseDouble(cmdArgs[0])));
48+
break;
49+
case "intake":
50+
addSequential(new IntakeCube());
51+
break;
52+
case "jump":
53+
addSequential(new RunScript(cmdArgs[0]));
54+
break;
55+
case "end":
56+
break outerloop;
57+
default:
58+
throw new Exception();
59+
}
60+
}
2961
}
3062
}

Robot2018/src/org/usfirst/frc/team199/Robot2018/commands/TestAuto.java

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,14 @@
99
public class TestAuto extends CommandGroup implements TestAutoInterface {
1010

1111
public TestAuto() {
12-
// TODO
13-
14-
// Add Commands here:
15-
// e.g. addSequential(new Command1());
16-
// addSequential(new Command2());
17-
// these will run in order.
18-
19-
// To run multiple commands at the same time,
20-
// use addParallel()
21-
// e.g. addParallel(new Command1());
22-
// addSequential(new Command2());
23-
// Command1 and Command2 will run in parallel.
24-
25-
// A command group will require all of the subsystems that each member
26-
// would require.
27-
// e.g. if Command1 requires chassis, and Command2 requires arm,
28-
// a CommandGroup containing them would require both the chassis and the
29-
// arm.
12+
addSequential(new RunScript(getScriptToTest()));
3013
}
3114

3215
/**
3316
* {@inheritDoc}
3417
*/
3518
@Override
36-
public String getScriptToTest() {
37-
// TODO
38-
return null;
19+
public String getScriptToTest() {
20+
return getString("Auto Script", "NOTHING");
3921
}
4022
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pynetworktables==2018.0.0
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#nt setup
2+
from networktables import NetworkTables
3+
NetworkTables.initialize(server='roboRIO-199-FRC.local')
4+
prefs = NetworkTables.getTable("Preferences")
5+
6+
go = False #true when file has been successfully read
7+
file = [] #an array of strings which represent each line of the file
8+
filename = input("File name: ") #the name of the file to read (user input)
9+
10+
#loops until a file is read into the file array
11+
while not go:
12+
try:
13+
if filename == "quit":
14+
quit()
15+
16+
with open(filename) as script:
17+
file = script.readlines()
18+
#balex's testing
19+
for line in file:
20+
print(repr(line))
21+
22+
break
23+
except:
24+
filename = input("Not found. Try another name (enter to quit): ") or "quit" #retry, or quit (in case the file doesn't exist)
25+
26+
#puts the string array
27+
prefs.putStringArray("autoscripts", file)
28+
print("Uploaded %s as a String[] to key \"autoscripts\"" % filename)

0 commit comments

Comments
 (0)