View Full Version : Autonomous: addParallel
VaneRaklan
03-03-2015, 21:55
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.
TFleig78
03-03-2015, 22:13
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:
addSequential(new ShootAndReloadBall());
addSequential(new WaitCommand(0.75));
addParallel(new IntakeFastStore());
addParallel(new DriveStraight(DRIVE_SPEED, DRIVE_TIME));
The last two commands execute at the same time.
Just to make sure everything is clear.
addSequential(new ShootAndReloadBall());
addSequential(new WaitCommand(0.75));
addParallel(new IntakeFastStore());
addSequential(new DriveStraight(DRIVE_SPEED, DRIVE_TIME));
Will also have the last two commands run at the same time.
The addX() functions basically apply to handling the next command's execution order.
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!
notmattlythgoe
04-03-2015, 10:46
If we convert this into the translated syntax you'll come up with this.
Code:
[2|1]
[3]
[4]
What you'll notice is that 1 will only execute as only as 2 executes. If 2 finishes, 1 also finishes, even if it's not done.
Looking at the source code for CommandGroups I do not believe this is the case. Command 1 will run until another command that requires the same subsystem interrupts it or it finishes on its own.
So when you are implementing a series of parallel commands in a command group they need to be followed by the sequential command which acts as the control for the command.
Code:
addParrallel(1);
addParrallel(2);
addSequential(3);
In this case the command group will run until 3 finishes.
I also do not believe this is the case. The CommandGroup will not finish until all commands it contains are finished.
shindigo
05-03-2015, 14:12
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.
Ty Tremblay
05-03-2015, 14:16
It's a little counter intuitive at first, but addParallel() commands run in parallel with the first addSequential() AFTER them.
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
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.