diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2017-03-12 12:03:48 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2017-03-12 12:03:48 -0400 |
commit | 0018460337ece50b16263bdd62311e8cda11dbd2 (patch) | |
tree | b370f00896b4c413ef54d176156ea1d4167d24a6 | |
parent | 1bf7777ae04dc0069d76d657f2b0f09d8f7e0570 (diff) |
I forgot that we have enums.
-rw-r--r-- | src/org/usfirst/frc/team4272/robot2017/Autonomous.java | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/org/usfirst/frc/team4272/robot2017/Autonomous.java b/src/org/usfirst/frc/team4272/robot2017/Autonomous.java index a64e5ad..2669205 100644 --- a/src/org/usfirst/frc/team4272/robot2017/Autonomous.java +++ b/src/org/usfirst/frc/team4272/robot2017/Autonomous.java @@ -163,21 +163,24 @@ public class Autonomous { private final HwRobot robot; private final Command[] commands; private int step = 0; - private static final SendableChooser modeChooser = new SendableChooser(); + + public static enum Mode { + CENTER_PEG, LEFT_PEG, RIGHT_PEG, NONE + } + private static final SendableChooser<Mode> modeChooser = new SendableChooser<Mode>(); public static void robotInit() { - modeChooser.addObject("Center Peg", "Center Peg"); - modeChooser.addObject("Left Peg", "Left Peg"); - modeChooser.addObject("Right Peg", "Right Peg"); - modeChooser.addObject("Stand Still", "Stand Still"); + modeChooser.addObject("Center Peg", Mode.CENTER_PEG); + modeChooser.addObject("Left Peg", Mode.LEFT_PEG); + modeChooser.addObject("Right Peg", Mode.RIGHT_PEG); + modeChooser.addObject("Stand Still", Mode.NONE); SmartDashboard.putData("Autonomous Mode", modeChooser); } public Autonomous(HwRobot robot) { this.robot = robot; - String mode = (String) modeChooser.getSelected(); - SmartDashboard.putString("read mode", mode); + Mode mode = modeChooser.getSelected(); Command init = c->{ c.lDrive = c.rDrive = 0; @@ -186,7 +189,7 @@ public class Autonomous { }; switch (mode) { - case "Center Peg": + case CENTER_PEG: commands = new Command[]{ init, new TimedCommand(driveDistance(robot, 0.4, 8.75), 6), @@ -196,7 +199,7 @@ public class Autonomous { c->{c.lDrive = c.rDrive = 0; return true;}, }; break; - case "Left Peg": + case LEFT_PEG: commands = new Command[]{ init, driveDistance(robot, 0.4, 3.5), @@ -205,7 +208,7 @@ public class Autonomous { c->{c.lDrive = c.rDrive = 0; return true;}, }; break; - case "Right Peg": + case RIGHT_PEG: commands = new Command[]{ init, driveDistance(robot, 0.4, 3.5), @@ -214,6 +217,7 @@ public class Autonomous { c->{c.lDrive = c.rDrive = 0; return true;}, }; break; + case NONE: default: commands = new Command[]{ c->{c.lDrive = c.rDrive = 0; return true;}, |