Package edu.wpi.first.wpilibj2.command
Class CommandGroupBase
java.lang.Object
edu.wpi.first.wpilibj2.command.CommandBase
edu.wpi.first.wpilibj2.command.CommandGroupBase
- Direct Known Subclasses:
ParallelCommandGroup
,ParallelDeadlineGroup
,ParallelRaceGroup
,SequentialCommandGroup
public abstract class CommandGroupBase extends CommandBase
A base for CommandGroups. Statically tracks commands that have been allocated to groups to ensure
those commands are not also used independently, which can result in inconsistent command state
and unpredictable execution.
-
Field Summary
-
Constructor Summary
Constructors Constructor Description CommandGroupBase()
-
Method Summary
Modifier and Type Method Description abstract void
addCommands(Command... commands)
Adds the given commands to the command group.static void
clearGroupedCommand(Command command)
Removes a single command from the list of grouped commands, allowing it to be freely used again.static void
clearGroupedCommands()
Clears the list of grouped commands, allowing all commands to be freely used again.static CommandGroupBase
deadline(Command deadline, Command... commands)
Factory method forParallelDeadlineGroup
, included for brevity/convenience.static CommandGroupBase
parallel(Command... commands)
Factory method forParallelCommandGroup
, included for brevity/convenience.static CommandGroupBase
race(Command... commands)
Factory method forParallelRaceGroup
, included for brevity/convenience.static void
requireUngrouped(Command... commands)
Requires that the specified commands not have been already allocated to a CommandGroup.static void
requireUngrouped(Collection<Command> commands)
Requires that the specified commands not have been already allocated to a CommandGroup.static CommandGroupBase
sequence(Command... commands)
Factory method forSequentialCommandGroup
, included for brevity/convenience.Methods inherited from class edu.wpi.first.wpilibj2.command.CommandBase
addRequirements, getName, getRequirements, getSubsystem, initSendable, setName, setSubsystem, withName
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface edu.wpi.first.wpilibj2.command.Command
alongWith, andThen, andThen, asProxy, beforeStarting, beforeStarting, cancel, deadlineWith, end, execute, hasRequirement, initialize, isFinished, isScheduled, perpetually, raceWith, runsWhenDisabled, schedule, schedule, withInterrupt, withTimeout
-
Constructor Details
-
CommandGroupBase
public CommandGroupBase()
-
-
Method Details
-
clearGroupedCommands
Clears the list of grouped commands, allowing all commands to be freely used again.WARNING: Using this haphazardly can result in unexpected/undesirable behavior. Do not use this unless you fully understand what you are doing.
-
clearGroupedCommand
Removes a single command from the list of grouped commands, allowing it to be freely used again.WARNING: Using this haphazardly can result in unexpected/undesirable behavior. Do not use this unless you fully understand what you are doing.
- Parameters:
command
- the command to remove from the list of grouped commands
-
requireUngrouped
Requires that the specified commands not have been already allocated to a CommandGroup. Throws anIllegalArgumentException
if commands have been allocated.- Parameters:
commands
- The commands to check
-
requireUngrouped
Requires that the specified commands not have been already allocated to a CommandGroup. Throws anIllegalArgumentException
if commands have been allocated.- Parameters:
commands
- The commands to check
-
addCommands
Adds the given commands to the command group.- Parameters:
commands
- The commands to add.
-
sequence
Factory method forSequentialCommandGroup
, included for brevity/convenience.- Parameters:
commands
- the commands to include- Returns:
- the command group
-
parallel
Factory method forParallelCommandGroup
, included for brevity/convenience.- Parameters:
commands
- the commands to include- Returns:
- the command group
-
race
Factory method forParallelRaceGroup
, included for brevity/convenience.- Parameters:
commands
- the commands to include- Returns:
- the command group
-
deadline
Factory method forParallelDeadlineGroup
, included for brevity/convenience.- Parameters:
deadline
- the deadline commandcommands
- the commands to include- Returns:
- the command group
-