RobotCore
Robot Core Documentation
|
Public Member Functions | |
default void | initialize () |
default void | execute () |
default void | end (boolean interrupted) |
default boolean | isFinished () |
Set< Subsystem > | getRequirements () |
default ParallelRaceGroup | withTimeout (double seconds) |
default ParallelRaceGroup | withInterrupt (BooleanSupplier condition) |
default SequentialCommandGroup | beforeStarting (Runnable toRun, Subsystem... requirements) |
default SequentialCommandGroup | andThen (Runnable toRun, Subsystem... requirements) |
default SequentialCommandGroup | andThen (Command... next) |
default ParallelDeadlineGroup | deadlineWith (Command... parallel) |
default ParallelCommandGroup | alongWith (Command... parallel) |
default ParallelRaceGroup | raceWith (Command... parallel) |
default PerpetualCommand | perpetually () |
default ProxyScheduleCommand | asProxy () |
default void | schedule (boolean interruptible) |
default void | schedule () |
default void | cancel () |
default boolean | isScheduled () |
default boolean | hasRequirement (Subsystem requirement) |
default boolean | runsWhenDisabled () |
default String | getName () |
A state machine representing a complete action to be performed by the robot. Commands are run by the CommandScheduler, and can be composed into CommandGroups to allow users to build complicated multi-step actions without the need to roll the state machine logic themselves.
Commands are run synchronously from the main robot loop; no multithreading is used, unless specified explicitly from the command implementation.
default ParallelCommandGroup edu.wpi.first.wpilibj2.command.Command.alongWith | ( | Command... | parallel | ) |
Decorates this command with a set of commands to run parallel to it, ending when the last command ends. Often more convenient/less-verbose than constructing a new ParallelCommandGroup explicitly.
Note: This decorator works by composing this command within a CommandGroup. The command cannot be used independently after being decorated, or be re-decorated with a different decorator, unless it is manually cleared from the list of grouped commands with CommandGroupBase#clearGroupedCommand(Command). The decorated command can, however, be further decorated without issue.
parallel | the commands to run in parallel |
default SequentialCommandGroup edu.wpi.first.wpilibj2.command.Command.andThen | ( | Command... | next | ) |
Decorates this command with a set of commands to run after it in sequence. Often more convenient/less-verbose than constructing a new SequentialCommandGroup explicitly.
Note: This decorator works by composing this command within a CommandGroup. The command cannot be used independently after being decorated, or be re-decorated with a different decorator, unless it is manually cleared from the list of grouped commands with CommandGroupBase#clearGroupedCommand(Command). The decorated command can, however, be further decorated without issue.
next | the commands to run next |
default SequentialCommandGroup edu.wpi.first.wpilibj2.command.Command.andThen | ( | Runnable | toRun, |
Subsystem... | requirements | ||
) |
Decorates this command with a runnable to run after the command finishes.
Note: This decorator works by composing this command within a CommandGroup. The command cannot be used independently after being decorated, or be re-decorated with a different decorator, unless it is manually cleared from the list of grouped commands with CommandGroupBase#clearGroupedCommand(Command). The decorated command can, however, be further decorated without issue.
toRun | the Runnable to run |
requirements | the required subsystems |
default ProxyScheduleCommand edu.wpi.first.wpilibj2.command.Command.asProxy | ( | ) |
Decorates this command to run "by proxy" by wrapping it in a ProxyScheduleCommand. This is useful for "forking off" from command groups when the user does not wish to extend the command's requirements to the entire command group.
default SequentialCommandGroup edu.wpi.first.wpilibj2.command.Command.beforeStarting | ( | Runnable | toRun, |
Subsystem... | requirements | ||
) |
Decorates this command with a runnable to run before this command starts.
Note: This decorator works by composing this command within a CommandGroup. The command cannot be used independently after being decorated, or be re-decorated with a different decorator, unless it is manually cleared from the list of grouped commands with CommandGroupBase#clearGroupedCommand(Command). The decorated command can, however, be further decorated without issue.
toRun | the Runnable to run |
requirements | the required subsystems |
default void edu.wpi.first.wpilibj2.command.Command.cancel | ( | ) |
Cancels this command. Will call the command's interrupted() method. Commands will be canceled even if they are not marked as interruptible.
default ParallelDeadlineGroup edu.wpi.first.wpilibj2.command.Command.deadlineWith | ( | Command... | parallel | ) |
Decorates this command with a set of commands to run parallel to it, ending when the calling command ends and interrupting all the others. Often more convenient/less-verbose than constructing a new ParallelDeadlineGroup explicitly.
Note: This decorator works by composing this command within a CommandGroup. The command cannot be used independently after being decorated, or be re-decorated with a different decorator, unless it is manually cleared from the list of grouped commands with CommandGroupBase#clearGroupedCommand(Command). The decorated command can, however, be further decorated without issue.
parallel | the commands to run in parallel |
default void edu.wpi.first.wpilibj2.command.Command.end | ( | boolean | interrupted | ) |
The action to take when the command ends. Called when either the command finishes normally, or when it interrupted/canceled.
Do not schedule commands here that share requirements with this command. Use andThen(Command...) instead.
interrupted | whether the command was interrupted/canceled |
Implemented in edu.wpi.first.wpilibj2.command.WaitCommand, edu.wpi.first.wpilibj2.command.StartEndCommand, edu.wpi.first.wpilibj2.command.SequentialCommandGroup, edu.wpi.first.wpilibj2.command.SelectCommand, edu.wpi.first.wpilibj2.command.ProxyScheduleCommand, edu.wpi.first.wpilibj2.command.PerpetualCommand, edu.wpi.first.wpilibj2.command.ParallelRaceGroup, edu.wpi.first.wpilibj2.command.ParallelDeadlineGroup, edu.wpi.first.wpilibj2.command.ParallelCommandGroup, edu.wpi.first.wpilibj2.command.FunctionalCommand, and edu.wpi.first.wpilibj2.command.ConditionalCommand.
default void edu.wpi.first.wpilibj2.command.Command.execute | ( | ) |
The main body of a command. Called repeatedly while the command is scheduled.
Implemented in edu.wpi.first.wpilibj2.command.SequentialCommandGroup, edu.wpi.first.wpilibj2.command.SelectCommand, edu.wpi.first.wpilibj2.command.RunCommand, edu.wpi.first.wpilibj2.command.ProxyScheduleCommand, edu.wpi.first.wpilibj2.command.PerpetualCommand, edu.wpi.first.wpilibj2.command.ParallelRaceGroup, edu.wpi.first.wpilibj2.command.ParallelDeadlineGroup, edu.wpi.first.wpilibj2.command.ParallelCommandGroup, edu.wpi.first.wpilibj2.command.FunctionalCommand, and edu.wpi.first.wpilibj2.command.ConditionalCommand.
default String edu.wpi.first.wpilibj2.command.Command.getName | ( | ) |
Gets the name of this Command.
Set<Subsystem> edu.wpi.first.wpilibj2.command.Command.getRequirements | ( | ) |
Specifies the set of subsystems used by this command. Two commands cannot use the same subsystem at the same time. If the command is scheduled as interruptible and another command is scheduled that shares a requirement, the command will be interrupted. Else, the command will not be scheduled. If no subsystems are required, return an empty set.
Note: it is recommended that user implementations contain the requirements as a field, and return that field here, rather than allocating a new set every time this is called.
Implemented in edu.wpi.first.wpilibj2.command.CommandBase.
default boolean edu.wpi.first.wpilibj2.command.Command.hasRequirement | ( | Subsystem | requirement | ) |
Whether the command requires a given subsystem. Named "hasRequirement" rather than "requires" to avoid confusion with edu.wpi.first.wpilibj.command.Command#requires(edu.wpi.first.wpilibj.command.Subsystem)
requirement | the subsystem to inquire about |
default void edu.wpi.first.wpilibj2.command.Command.initialize | ( | ) |
The initial subroutine of a command. Called once when the command is initially scheduled.
Implemented in edu.wpi.first.wpilibj2.command.WaitCommand, edu.wpi.first.wpilibj2.command.StartEndCommand, edu.wpi.first.wpilibj2.command.SequentialCommandGroup, edu.wpi.first.wpilibj2.command.SelectCommand, edu.wpi.first.wpilibj2.command.ScheduleCommand, edu.wpi.first.wpilibj2.command.ProxyScheduleCommand, edu.wpi.first.wpilibj2.command.PerpetualCommand, edu.wpi.first.wpilibj2.command.ParallelRaceGroup, edu.wpi.first.wpilibj2.command.ParallelDeadlineGroup, edu.wpi.first.wpilibj2.command.ParallelCommandGroup, edu.wpi.first.wpilibj2.command.InstantCommand, edu.wpi.first.wpilibj2.command.FunctionalCommand, and edu.wpi.first.wpilibj2.command.ConditionalCommand.
default boolean edu.wpi.first.wpilibj2.command.Command.isFinished | ( | ) |
Whether the command has finished. Once a command finishes, the scheduler will call its end() method and un-schedule it.
Implemented in edu.wpi.first.wpilibj2.command.WaitUntilCommand, edu.wpi.first.wpilibj2.command.WaitCommand, edu.wpi.first.wpilibj2.command.SequentialCommandGroup, edu.wpi.first.wpilibj2.command.SelectCommand, edu.wpi.first.wpilibj2.command.ScheduleCommand, edu.wpi.first.wpilibj2.command.ProxyScheduleCommand, edu.wpi.first.wpilibj2.command.ParallelRaceGroup, edu.wpi.first.wpilibj2.command.ParallelDeadlineGroup, edu.wpi.first.wpilibj2.command.ParallelCommandGroup, edu.wpi.first.wpilibj2.command.InstantCommand, edu.wpi.first.wpilibj2.command.FunctionalCommand, and edu.wpi.first.wpilibj2.command.ConditionalCommand.
default boolean edu.wpi.first.wpilibj2.command.Command.isScheduled | ( | ) |
Whether or not the command is currently scheduled. Note that this does not detect whether the command is being run by a CommandGroup, only whether it is directly being run by the scheduler.
default PerpetualCommand edu.wpi.first.wpilibj2.command.Command.perpetually | ( | ) |
Decorates this command to run perpetually, ignoring its ordinary end conditions. The decorated command can still be interrupted or canceled.
Note: This decorator works by composing this command within a CommandGroup. The command cannot be used independently after being decorated, or be re-decorated with a different decorator, unless it is manually cleared from the list of grouped commands with CommandGroupBase#clearGroupedCommand(Command). The decorated command can, however, be further decorated without issue.
default ParallelRaceGroup edu.wpi.first.wpilibj2.command.Command.raceWith | ( | Command... | parallel | ) |
Decorates this command with a set of commands to run parallel to it, ending when the first command ends. Often more convenient/less-verbose than constructing a new ParallelRaceGroup explicitly.
Note: This decorator works by composing this command within a CommandGroup. The command cannot be used independently after being decorated, or be re-decorated with a different decorator, unless it is manually cleared from the list of grouped commands with CommandGroupBase#clearGroupedCommand(Command). The decorated command can, however, be further decorated without issue.
parallel | the commands to run in parallel |
default boolean edu.wpi.first.wpilibj2.command.Command.runsWhenDisabled | ( | ) |
Whether the given command should run when the robot is disabled. Override to return true if the command should run when disabled.
Implemented in edu.wpi.first.wpilibj2.command.WaitUntilCommand, edu.wpi.first.wpilibj2.command.WaitCommand, edu.wpi.first.wpilibj2.command.SequentialCommandGroup, edu.wpi.first.wpilibj2.command.SelectCommand, edu.wpi.first.wpilibj2.command.ScheduleCommand, edu.wpi.first.wpilibj2.command.PrintCommand, edu.wpi.first.wpilibj2.command.PerpetualCommand, edu.wpi.first.wpilibj2.command.ParallelRaceGroup, edu.wpi.first.wpilibj2.command.ParallelDeadlineGroup, edu.wpi.first.wpilibj2.command.ParallelCommandGroup, and edu.wpi.first.wpilibj2.command.ConditionalCommand.
default void edu.wpi.first.wpilibj2.command.Command.schedule | ( | ) |
Schedules this command, defaulting to interruptible.
default void edu.wpi.first.wpilibj2.command.Command.schedule | ( | boolean | interruptible | ) |
Schedules this command.
interruptible | whether this command can be interrupted by another command that shares one of its requirements |
default ParallelRaceGroup edu.wpi.first.wpilibj2.command.Command.withInterrupt | ( | BooleanSupplier | condition | ) |
Decorates this command with an interrupt condition. If the specified condition becomes true before the command finishes normally, the command will be interrupted and un-scheduled. Note that this only applies to the command returned by this method; the calling command is not itself changed.
Note: This decorator works by composing this command within a CommandGroup. The command cannot be used independently after being decorated, or be re-decorated with a different decorator, unless it is manually cleared from the list of grouped commands with CommandGroupBase#clearGroupedCommand(Command). The decorated command can, however, be further decorated without issue.
condition | the interrupt condition |
default ParallelRaceGroup edu.wpi.first.wpilibj2.command.Command.withTimeout | ( | double | seconds | ) |
Decorates this command with a timeout. If the specified timeout is exceeded before the command finishes normally, the command will be interrupted and un-scheduled. Note that the timeout only applies to the command returned by this method; the calling command is not itself changed.
Note: This decorator works by composing this command within a CommandGroup. The command cannot be used independently after being decorated, or be re-decorated with a different decorator, unless it is manually cleared from the list of grouped commands with CommandGroupBase#clearGroupedCommand(Command). The decorated command can, however, be further decorated without issue.
seconds | the timeout duration |