View Single Post
  #9   Spotlight this post!  
Unread 23-02-2013, 22:25
kylelanman's Avatar
kylelanman kylelanman is offline
Programming Mentor
AKA: Kyle
FRC #2481 (Roboteers)
Team Role: Mentor
 
Join Date: Feb 2008
Rookie Year: 2007
Location: Tremont Il
Posts: 189
kylelanman is a name known to allkylelanman is a name known to allkylelanman is a name known to allkylelanman is a name known to allkylelanman is a name known to allkylelanman is a name known to all
Re: Command-Based robot button toggle question

While I would be interested in a ToggleButton type that provides this functionality we found the following much easier.

Example of how our shooter works.

We use the following pattern for structuring our subsystems.
Code:
void raiseShooter();
void lowerShooter();
bool isRaised();
Then we have 3 commands.

RaiseShooterCommand:
Code:
void Execute() {
        shooter->raiseShooter();
}
LowerShooterCommand:
Code:
void Execute() {
        shooter->lowerShooter();
}
ToggleShooterCommand:
Code:
void Execute() {
    if (shooter->isRaised())
        shooter->lowerShooter();
    else
        shooter->raiseShooter();
}
The controls use the ToggleShooterCommand. Any command groups for sequences or auton use the explicit RaiseShooterCommand and LowerShooterCommand.
__________________
"May the coms be with you"

Is this a "programming error" or a "programmer error"?

Reply With Quote