|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Autonomous: addParallel
So we are trying to run parallels in our autonomous, but for some reason when we add a parallel to the mix, that command won't run until after every other sequential command has finished. Any ideas for why this would happen? If someone could put up an example of a simple, working, auto code that uses parallels, t that would be great.
|
|
#2
|
||||
|
||||
|
Re: Autonomous: addParallel
I believe a parallel command won't run until the sequential command above it has finished. if you want two things to happen simultaneously, make the first one parallel.
This is a snippet of our code from last year: Code:
addSequential(new ShootAndReloadBall());
addSequential(new WaitCommand(0.75));
addParallel(new IntakeFastStore());
addParallel(new DriveStraight(DRIVE_SPEED, DRIVE_TIME));
|
|
#3
|
||||
|
||||
|
Re: Autonomous: addParallel
Just to make sure everything is clear.
Code:
addSequential(new ShootAndReloadBall());
addSequential(new WaitCommand(0.75));
addParallel(new IntakeFastStore());
addSequential(new DriveStraight(DRIVE_SPEED, DRIVE_TIME));
The addX() functions basically apply to handling the next command's execution order. |
|
#4
|
||||
|
||||
|
Re: Autonomous: addParallel
Deleting my post because I was wrong in several of my assumptions.
Thanks Matt for correcting me. Needless to say, adding parallel commands can certainly make your head spin. Good luck! Last edited by mwtidd : 04-03-2015 at 11:19. |
|
#5
|
|||||
|
|||||
|
Re: Autonomous: addParallel
Quote:
Quote:
Last edited by notmattlythgoe : 04-03-2015 at 10:51. |
|
#6
|
|||
|
|||
|
Re: Autonomous: addParallel
We put all our sets of parallel commands in their own CommandGroup. We find this makes is clearer what is running in parallel and what is not.
In the Autonomous CommandGroup we have: AddSequential(new DoThing1()); AddSequential(new DoThings2and3()); AddSequential(new DoThing4()); Inside the CommandGroup called DoThings2and3 we have: AddParallel(new DoThing2()); AddParallel(new DoThing3()); Thing4 does not execute until 2 and 3 are finished. |
|
#7
|
||||
|
||||
|
Re: Autonomous: addParallel
It's a little counter intuitive at first, but addParallel() commands run in parallel with the first addSequential() AFTER them.
Code:
addParallel(1) addParallel(2) addSequential(1) //All 3 commands run addSequential(1) addParallel(1) addParallel(2) addSequential(2) //sequential 1 will run, then parallels 1&2 will run with sequential 2 |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|