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 Details

  • 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

      public static void clearGroupedCommand​(Command command)
      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

      public static void requireUngrouped​(Command... commands)
      Requires that the specified commands not have been already allocated to a CommandGroup. Throws an IllegalArgumentException if commands have been allocated.
      Parameters:
      commands - The commands to check
    • requireUngrouped

      public static void requireUngrouped​(java.util.Collection<Command> commands)
      Requires that the specified commands not have been already allocated to a CommandGroup. Throws an IllegalArgumentException if commands have been allocated.
      Parameters:
      commands - The commands to check
    • addCommands

      public abstract void addCommands​(Command... commands)
      Adds the given commands to the command group.
      Parameters:
      commands - The commands to add.
    • sequence

      public static CommandGroupBase sequence​(Command... commands)
      Factory method for SequentialCommandGroup, included for brevity/convenience.
      Parameters:
      commands - the commands to include
      Returns:
      the command group
    • parallel

      public static CommandGroupBase parallel​(Command... commands)
      Factory method for ParallelCommandGroup, included for brevity/convenience.
      Parameters:
      commands - the commands to include
      Returns:
      the command group
    • race

      public static CommandGroupBase race​(Command... commands)
      Factory method for ParallelRaceGroup, included for brevity/convenience.
      Parameters:
      commands - the commands to include
      Returns:
      the command group
    • deadline

      public static CommandGroupBase deadline​(Command deadline, Command... commands)
      Factory method for ParallelDeadlineGroup, included for brevity/convenience.
      Parameters:
      deadline - the deadline command
      commands - the commands to include
      Returns:
      the command group