View Single Post
  #5   Spotlight this post!  
Unread 25-02-2013, 12:07
GrimmReaper's Avatar
GrimmReaper GrimmReaper is offline
Registered User
FRC #2046 (Bear Metal)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2011
Location: Maple Valley, WA
Posts: 24
GrimmReaper is on a distinguished road
Re: methods for Switchable Autonomous Modes

I like using the DIO's on the I/O tab of the drivers station. You had mentioned that and yes it's easily doable. Something like this:
Code:
//declare the driver station - perhaps globally in the robot
DriverStation* driverStation;

//...  then in your init code grab the instance
driverStation = DriverStation::GetInstance();

// then in autonomous mode read the inputs to decide
// Start with just 1 through 8 because you can actually label them on
//the driver station what they are
		if (driverStation->GetDigitalIn(1)) {
			AutoRoutine1();
		} else if (driverStation->GetDigitalIn(2)) {
			AutoRoutine2();
		} else if (driverStation->GetDigitalIn(3)) {
			AutoRoutine3();
		}
If you get beyond 8 needed modes, you'll have to keep a list of how to set the IO's and you can check for combinations of Inputs you could do this straight binary and use 4 lights to get you 16 or in our case we just had a couple more, so we just added on a couple of 2 light scenarios at the top: use Digital IO's to choose autonomous Scenarios
Code:
		if (driverStation->GetDigitalIn(1) && driverStation->GetDigitalIn(2)) {
			AutoRoutine9();
		} else if (driverStation->GetDigitalIn(1) && driverStation->GetDigitalIn(3)) {
			AutoRoutine10();
		} else if (driverStation->GetDigitalIn(1)) {
			AutoRoutine1();
		} else if (driverStation->GetDigitalIn(2)) {
			AutoRoutine2();
		} else if (driverStation->GetDigitalIn(3)) {
			AutoRoutine3();
		}
Reply With Quote