Use SmartDashboard to choose which autonomous you need
before the match. It lets you add things like radio buttons to the screen, and you can use those to choose which defense is in front of you. Quick snippet of code:
Code:
//Initialize the SendableChooser
public void robotInit() {
SendableChooser chooser = new SendableChooser();
chooser.initTable(NetworkTable.getTable("Defense Chooser"));
chooser.addDefault("Low Bar", "lowbar");
chooser.addObject("Ramparts", "ramparts");
chooser.addObject("Moat", "moat");
chooser.addObject("Cheval de Frise", "cheval");
chooser.addObject("Rock Wall", "rockwall");
//ect...add the rest of the defenses
SmartDashboard.putData("Autonomous Defense Chooser", chooser);
}
...
//Use the below code to check which defense is selected
String defense = chooser.getSelected().toString();
if (defense.equals("lowbar")) {
//Lowbar auto
} else if (defense.equals("ramparts")) {
//ramparts auto
} else if (defense.equals("moat")) {
//moat auto
}
//ect...add the rest of the if/elses
The SendableChooser class lets you create a set of radio buttons. You use SendableChooser.addDefault() and SendableChooser.addObject() to add different options to it. The two Strings arguments, in order, are display name and an internal value. The first String (the display name) is what people see in SmartDashboard. The second String (the internal value) is what is returned when you call SendableChooser.getSelected(). Hope this helps!