CommandGroup¶
-
class
wpilib.command.
CommandGroup
(name=None)[source]¶ Bases:
wpilib.command.Command
A CommandGroup is a list of commands which are executed in sequence.
Commands in a CommandGroup are added using the
addSequential()
method and are called sequentially. CommandGroups are themselves Commands and can be given to other CommandGroups.CommandGroups will carry all of the requirements of their subcommands. Additional requirements can be specified by calling
requires()
normally in the constructor.CommandGroups can also execute commands in parallel, simply by adding them using addParallel(...).
See also
Command
,Subsystem
Creates a new CommandGroup with the given name.
Parameters: name – the name for this command group (optional). If None, the name of this command will be set to its class name. -
class
Entry
(command, state, timeout)[source]¶ Bases:
object
-
BRANCH_CHILD
= 2¶
-
BRANCH_PEER
= 1¶
-
IN_SEQUENCE
= 0¶
-
-
CommandGroup.
addParallel
(command, timeout=None)[source]¶ Adds a new child Command to the group (with an optional timeout). The Command will be started after all the previously added Commands.
Once the Command is started, it will run until it finishes, is interrupted, or the time expires (if a timeout is provided), whichever is sooner. Note that the given Command will have no knowledge that it is on a timer.
Instead of waiting for the child to finish, a CommandGroup will have it run at the same time as the subsequent Commands. The child will run until either it finishes, the timeout expires, a new child with conflicting requirements is started, or the main sequence runs a Command with conflicting requirements. In the latter two cases, the child will be canceled even if it says it can’t be interrupted.
Note that any requirements the given Command has will be added to the group. For this reason, a Command’s requirements can not be changed after being added to a group.
It is recommended that this method be called in the constructor.
Parameters: - command – The command to be added
- timeout – The timeout (in seconds) (optional)
-
CommandGroup.
addSequential
(command, timeout=None)[source]¶ Adds a new Command to the group (with an optional timeout). The Command will be started after all the previously added Commands.
Once the Command is started, it will be run until it finishes or the time expires, whichever is sooner (if a timeout is provided). Note that the given Command will have no knowledge that it is on a timer.
Note that any requirements the given Command has will be added to the group. For this reason, a Command’s requirements can not be changed after being added to a group.
It is recommended that this method be called in the constructor.
Parameters: - command – The Command to be added
- timeout – The timeout (in seconds) (optional)
-
class