View Single Post
  #4   Spotlight this post!  
Unread 23-02-2013, 12:36
Fifthparallel Fifthparallel is offline
Registered User
AKA: Sam Chen
FRC #1410
 
Join Date: Dec 2012
Rookie Year: 2011
Location: Denver, CO
Posts: 65
Fifthparallel is an unknown quantity at this point
Re: Command-Based robot button toggle question

Are the two commands related in any way? (i.e., could you use one command for both actions?). If so, you may want to consider refactoring either your subsystem or command code so that you have this functionality.

OR, you could put them all inside a command group with a bool that holds state, and based on that run either of two commands. Just make sure your "state" variable inside of whatever subsystem is actually being toggled back to whatever is needs to be.

Code:
//In the CommandGroup foo, you could either have a state that is toggled from within one of your subsystems,
//ala GetterSetter pattern and use this state to make a decision.

//OI code
JoystickButton *xyz = new JoystickButton(stick1, 11);
xyz->WhenPressed(new foo());

//CommandGroup 'foo' code

subsystemOne.ChangeStateOfFooBar();
if(subsystemOne.GetStateOfFooBar())
{
     AddSequential(new bar());
}
else
{
     AddSequential(new baz());
}
__________________
sudo chmod u+x helloworld.sh
gotta start somewhere.

Last edited by Fifthparallel : 23-02-2013 at 14:11.
Reply With Quote