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

Commit 91696c8

Browse files
committed
add RunScript command
AutoMoveTo, AutoTurn, AutoMove, DeployToSwitch, DeployToScale, and DeployToExchange all still need to be implemented and some should be delegated to their respective subsystem programmer
1 parent 7686223 commit 91696c8

1 file changed

Lines changed: 49 additions & 18 deletions

File tree

  • Robot2018/src/org/usfirst/frc/team199/Robot2018/commands
Lines changed: 49 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,61 @@
11
package org.usfirst.frc.team199.Robot2018.commands;
22

3+
import java.awt.Robot;
4+
import java.util.ArrayList;
5+
import java.util.Arrays;
6+
import java.util.Map;
7+
8+
import edu.wpi.first.wpilibj.Timer;
39
import edu.wpi.first.wpilibj.command.CommandGroup;
10+
import edu.wpi.first.wpilibj.command.WaitCommand;
411

512
/**
613
* Gets the script name and runs the script.
714
*/
815
public class RunScript extends CommandGroup implements RunScriptInterface {
916

1017
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.
18+
ArrayList<String> script = Robot.autoScripts.getOrDefault(scriptName, new ArrayList<String>());
19+
20+
outerloop:
21+
for(String cmd : script) {
22+
String[] cmdParts = cmd.split(" ");
23+
String cmdName = cmdParts[0];
24+
String[] cmdArgs = Arrays.copyOfRange(cmdParts, 1, cmdParts.length);
25+
26+
switch (cmdParts[0]) {
27+
case "moveto":
28+
addSequential(new AutoMoveTo(cmdArgs));
29+
break;
30+
case "turn":
31+
addSequential(new AutoTurn(cmdArgs[0]));
32+
break;
33+
case "move":
34+
addSequential(new AutoMove(cmdArgs[0]));
35+
break;
36+
case "switch":
37+
addSequential(new DeployToSwitch());
38+
break;
39+
case "scale":
40+
addSequential(new DeployToScale());
41+
break;
42+
case "exchange":
43+
addSequential(new DeployToExchange);
44+
break;
45+
case "wait":
46+
addSequential(new WaitCommand(Double.parseDouble(cmdArgs[0])));
47+
break;
48+
case "intake":
49+
addSequential(new IntakeCube());
50+
break;
51+
case "jump":
52+
addSequential(new RunScript(cmdArgs[0]));
53+
break;
54+
case "end":
55+
break outerloop;
56+
default:
57+
throw new Exception();
58+
}
59+
}
2960
}
3061
}

0 commit comments

Comments
 (0)