View Single Post
  #5   Spotlight this post!  
Unread 10-02-2015, 10:31
microbuns's Avatar
microbuns microbuns is offline
Registered User
AKA: Sam Maier
FRC #4917
Team Role: Mentor
 
Join Date: Jan 2015
Rookie Year: 2014
Location: Elmira
Posts: 81
microbuns is an unknown quantity at this point
Re: Conditional Command Group?

I know I'm not OP, but I'm on his team - I'll show you specifically what we are doing:

We have a command group like so:
Code:
Grp1::Grp1() {
AddSequential(new Cmd1());
AddSequential(new Cmd2());
AddSequential(new Cmd3());
}
Which is called by a button in OI.cpp:
Code:
groupButton->WhenPressed(new Grp1());
However to speed things up, we can skip Cmd2 in Grp1 occasionally based off the state of the robot. This kind of thing would be nice:

Code:
Grp1::Grp1() {
AddSequential(new Cmd1());
if (!mDrivetrain->canSkip()) {
   AddSequential(new Cmd2());
}
AddSequential(new Cmd3());
}
One of our mentors (that I think you know, Kyle ) suggested we just make 2 separate command groups, and then have the button press call a new Command, which in turn checks the robot's state and calls the appropriate group based off of that. I was just wondering if there are any cleaner solutions?
Reply With Quote