Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Autonomous Switching With the Iterative Robot Template (http://www.chiefdelphi.com/forums/showthread.php?t=128454)

trevormcclellan 02-04-2014 18:29

Autonomous Switching With the Iterative Robot Template
 
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/...smartdashboard

Domenic Rodriguez 02-04-2014 19:12

Re: Autonomous Switching With the Iterative Robot Template
 
1 Attachment(s)
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 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

Re: Autonomous Switching With the Iterative Robot Template
 
You could do a similar thing as shown in the post above, but with Smartdashboard.

If you write:

Code:

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.

Code:

SmartDashboard.getNumber("exampleVal");

virtuald 02-04-2014 22:29

Re: Autonomous Switching With the Iterative Robot Template
 
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.


All times are GMT -5. The time now is 11:35.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi