Thread: SendableChooser
View Single Post
  #2   Spotlight this post!  
Unread 24-01-2016, 10:12
fovea1959's Avatar
fovea1959 fovea1959 is offline
Herder of programmers
AKA: Doug Wegscheid
FRC #3620 (The Average Joes)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2011
Location: St Joseph
Posts: 330
fovea1959 will become famous soon enough
Re: SendableChooser

If you are doing command based, you write a Command (often a CommandGroup) for each of your autonomous modes that you want your drivers to choose between. In robotInit, have the code send a SendableChooser to the smartdashboard, and populate the SendableChooser with the Commands you created. Driver places robot on the field, powers up, waits for communcation on the driver station, pulls up Smartdashboard, picks the one she wants for that match. In AutonomousInit() (which is called when autonomous starts), your code asks the SendableChooser for which one to run, and starts that one.

Clear example and verbage at https://wpilib.screenstepslive.com/s...smartdashboard.

If your code is *not* command based (IterativeRobot), the code can just send strings to the SendableChooser, and look to see what String got picked. If you do a File | New | Project ... | Robot Java Project (not Example Robot Java Project) | Iterative Robot, you get a nice little Iterative Robot that does this; you can copy and paste the relevant bits into your code.

Having the robot save the setting when it gets set so can retrieve the last used value when it powers up is nice; then the drivers can set the autonomous while still in queue and tethered to the robot. I read there were changes in WPILIBj around saving networktables settings, haven't looked at it yet. Get the easy version working first.
Reply With Quote