View Single Post
  #13   Spotlight this post!  
Unread 22-01-2016, 09:15
Oromus's Avatar
Oromus Oromus is offline
Lead Programmer, Community Liason
AKA: Ryan
FRC #1902 (Exploding Bacon)
Team Role: Programmer
 
Join Date: Jan 2015
Rookie Year: 2013
Location: Florida
Posts: 82
Oromus is a splendid one to beholdOromus is a splendid one to beholdOromus is a splendid one to beholdOromus is a splendid one to beholdOromus is a splendid one to beholdOromus is a splendid one to behold
Re: Question on Autonomous Mode

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!
__________________


2016 Roles: Manipulator, Strategy Co-Lead, Programmer
2016 Orlando Regional: Quarterfinalist (Captain w/ 1557, 5557 and 4352)
2016 Rocket City Regional: Quarterfinalist (w/ 283 and 34), Regional Chairman's Award Winner
2016 Championship: N/A (had fun and was inspired, that's what counts)
-------------
2015 Role: Programmer
2015 GSCR: Quarterfinalist (w/ 4189 and 4026), Regional Chairman's Award Winner
2015 Orlando Regional: Semifinalist (w/ 456 and 86), Imagery Award Winner
2015 Championship: Pit Safety Award Winner

Last edited by Oromus : 22-01-2016 at 09:24.