View Full Version : Autonomous Switching With the Iterative Robot Template
trevormcclellan
02-04-2014, 18:29
Hello everyone, I am a programmer from team 5137 and I was wondering if there was a simple way to choose an autonomous program from the smart dash board like the tutorial, but with the iterative robot template instead of command based.
Here is the tutorial: http://wpilib.screenstepslive.com/s/3120/m/7932/l/81109-choosing-an-autonomous-program-from-smartdashboard
Domenic Rodriguez
02-04-2014, 19:12
The approach my team uses for multiple autonomous modes is to choose a mode based on one of the analog input sliders on the driver station (see attachment). Each autonomous mode is encapsulated within a class that inherits from the AutonomousMode base class. In autonomousInit(), we read the value of the first analog slider and then use that number in a switch statement to choose which autonomous class to create an instance of. Here's (https://github.com/LuNaTeCs-316/SureShotSAM-Java/blob/master/src/org/lunatecs316/frc2013/SureShotSAM.java) last year's code if you're interested (autonomous modes are in the "org.lunatecs316.frc2013.auto" package). The downside to this approach is that you have to remember the numbering of your autonomous modes.
TFleig78
02-04-2014, 20:34
You could do a similar thing as shown in the post above, but with Smartdashboard.
If you write:
SmartDashboard.putNumber("exampleVal", value);
You can edit the value before the match, depending on the auto you want then write the following to get the value and use it to run a specific sequence.
SmartDashboard.getNumber("exampleVal");
virtuald
02-04-2014, 22:29
You can use the same code as given in the tutorial. I believe the second argument to the chooser addObject() is just an object, so it can be anything -- not just a command. You can use the result of chooser.getSelected() to decide which autonomous behavior to perform.
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.