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

Commit 8fbce46

Browse files
committed
clean up and document auto code
add more documentation and make some of the code neater
1 parent ef51d3c commit 8fbce46

3 files changed

Lines changed: 11 additions & 14 deletions

File tree

Robot2018/src/org/usfirst/frc/team199/Robot2018/Robot.java

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,13 @@ public void robotInit() {
8484
rd = new RightDrive();
8585
oi = new OI();
8686

87-
// put in position chooer
87+
// auto position chooser
8888
for (Position p : Position.values()) {
8989
posChooser.addObject(p.getSDName(), p);
9090
}
9191
SmartDashboard.putData("Starting Position", posChooser);
9292

93-
// put in strategy choosers
93+
// auto strategy choosers
9494
for (String input : fmsPossibilities) {
9595
SendableChooser<Strategy> chooser = new SendableChooser<Strategy>();
9696
for (Strategy s : Strategy.values()) {
@@ -100,8 +100,10 @@ public void robotInit() {
100100
stratChoosers.put(input, chooser);
101101
}
102102

103+
// auto delay chooser
103104
SmartDashboard.putNumber("Auto Delay", 0);
104-
105+
106+
// parse scripts from Preferences, which maintains values throughout reboots
105107
autoScripts = AutoUtils.parseScriptFile(Preferences.getInstance().getString("autoscripts", ""));
106108

107109
listen = new Listener();
@@ -123,15 +125,9 @@ public void disabledPeriodic() {
123125
}
124126

125127
/**
126-
* This autonomous (along with the chooser code above) shows how to select
127-
* between different autonomous modes using the dashboard. The sendable chooser
128-
* code works with the Java SmartDashboard. If you prefer the LabVIEW Dashboard,
129-
* remove all of the chooser code and uncomment the getString code to get the
130-
* auto name from the text box below the Gyro
131-
*
132-
* You can add additional auto modes by adding additional commands to the
133-
* chooser code above (like the commented example) or additional comparisons
134-
* to the switch structure below with additional strings &amp; commands.
128+
* This function is called once during the start of autonomous in order to
129+
* grab values from SmartDashboard and the FMS and call the Autonomous
130+
* command with those values.
135131
*/
136132
@Override
137133
public void autonomousInit() {

Robot2018/src/org/usfirst/frc/team199/Robot2018/autonomous/AutoUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public static Map<String, ArrayList<String[]>> parseScriptFile(String scriptFile
2626
// remove comments
2727
int commentIndex = line.indexOf("#");
2828
if (commentIndex != -1)
29-
line = line.substring(0, line.indexOf("#"));
29+
line = line.substring(0, commentIndex);
3030

3131
// trim and remove extra whitespace just to make it neater
3232
line = line.trim().replaceAll("\\s+", " ");
@@ -40,7 +40,7 @@ public static Map<String, ArrayList<String[]>> parseScriptFile(String scriptFile
4040
if (line.endsWith(":")) {
4141
autoScripts.put(currScriptName, currScript);
4242
currScript = new ArrayList<String[]>();
43-
currScriptName = line.substring(0, line.indexOf(":"));
43+
currScriptName = line.substring(0, line.length() - 1);
4444
} else {
4545

4646
// first separate the command into instruction and args

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ public Autonomous(Position startPos, Map<String, Strategy> strategies, double de
107107
else
108108
scriptName += "x";
109109

110+
// this is here because running this code outside of the RoboRIO is problematic
110111
if (!isTest) {
111112
addSequential(new WaitCommand(delay));
112113
addSequential(new RunScript(scriptName));

0 commit comments

Comments
 (0)