Package edu.wpi.first.wpilibj2.command
Class CommandGroupBase
java.lang.Object
edu.wpi.first.wpilibj2.command.CommandBase
edu.wpi.first.wpilibj2.command.CommandGroupBase
- All Implemented Interfaces:
Command
- Direct Known Subclasses:
ParallelCommandGroup,ParallelDeadlineGroup,ParallelRaceGroup,SequentialCommandGroup
public abstract class CommandGroupBase extends CommandBase implements Command
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.
-
Constructor Summary
Constructors Constructor Description CommandGroupBase() -
Method Summary
Modifier and Type Method Description abstract voidaddCommands(Command... commands)Adds the given commands to the command group.static voidclearGroupedCommand(Command command)Removes a single command from the list of grouped commands, allowing it to be freely used again.static voidclearGroupedCommands()Clears the list of grouped commands, allowing all commands to be freely used again.static CommandGroupBasedeadline(Command deadline, Command... commands)Factory method forParallelDeadlineGroup, included for brevity/convenience.static CommandGroupBaseparallel(Command... commands)Factory method forParallelCommandGroup, included for brevity/convenience.static CommandGroupBaserace(Command... commands)Factory method forParallelRaceGroup, included for brevity/convenience.static voidrequireUngrouped(Command... commands)Requires that the specified commands not have been already allocated to a CommandGroup.static voidrequireUngrouped(java.util.Collection<Command> commands)Requires that the specified commands not have been already allocated to a CommandGroup.static CommandGroupBasesequence(Command... commands)Factory method forSequentialCommandGroup, included for brevity/convenience.Methods inherited from class edu.wpi.first.wpilibj2.command.CommandBase
addRequirements, getRequirementsMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface edu.wpi.first.wpilibj2.command.Command
alongWith, andThen, asProxy, beforeStarting, cancel, deadlineWith, end, execute, getName, getRequirements, hasRequirement, initialize, interruptOn, isFinished, isScheduled, perpetually, raceWith, runsWhenDisabled, schedule, schedule, whenFinished, withTimeout
-
Constructor Details
-
CommandGroupBase
public CommandGroupBase()
-
-
Method Details
-
clearGroupedCommands
public static void 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 anIllegalArgumentExceptionif 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 anIllegalArgumentExceptionif 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
-