Sequential Command Group¶
The SequentialCommandGroup
is the most popular command group. Works by running a list of commands in sequential order. Starts with the first command in the list then the second and so on.
Warning
The SequentialCommandGroup
will not finish unless all the commands finish. Also if a command in the list does not finish the next command in line will not start.
Example code¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | import edu.wpi.first.wpilibj2.command.SequentialCommandGroup; public class Example extends SequentialCommandGroup { public Example() { addCommands( //Drive Forward new DriveForward(), //Drive Reverse new DriveReverse()); } } |
1 2 3 4 5 6 7 8 9 10 11 12 | #prama once #include <frc2/command/CommandHelper.h> #include <frc2/command/SequentialCommandGroup.h> class Example : public frc2::CommandHelper<frc2::SequentialCommandGroup, Example> { public: Example(void); }; |
1 2 3 4 5 6 7 8 9 10 11 12 | #include "commands/Example.h" Example::Example(void) { AddCommands( //Drive Forward DriveForward(), //Drive Backwards DriveReverse()); } |
In the above example using SequentialCommandGroup
the command DriveForward()
will be exeuted first and when complete the command DriveReverse()
will be executed.
Note
If DriveForward()
does not end then DriveReverse()
will never start.