From 0018460337ece50b16263bdd62311e8cda11dbd2 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 12 Mar 2017 12:03:48 -0400 Subject: I forgot that we have enums. --- .../usfirst/frc/team4272/robot2017/Autonomous.java | 24 +++++++++++++--------- 1 file 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 modeChooser = new SendableChooser(); 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;}, -- cgit v1.2.3