Robot Core Documentation
Public Member Functions | Protected Attributes | List of all members
edu.wpi.first.wpilibj2.command.StartEndCommand Class Reference
Inheritance diagram for edu.wpi.first.wpilibj2.command.StartEndCommand:
edu.wpi.first.wpilibj2.command.CommandBase edu.wpi.first.wpilibj2.command.Command

Public Member Functions

 StartEndCommand (Runnable onInit, Runnable onEnd, Subsystem... requirements)
void initialize ()
void end (boolean interrupted)
- Public Member Functions inherited from edu.wpi.first.wpilibj2.command.CommandBase
final void addRequirements (Subsystem... requirements)
Set< SubsystemgetRequirements ()
- Public Member Functions inherited from edu.wpi.first.wpilibj2.command.Command
default void execute ()
default boolean isFinished ()
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 ()

Protected Attributes

final Runnable m_onInit
final Runnable m_onEnd
- Protected Attributes inherited from edu.wpi.first.wpilibj2.command.CommandBase
Set< Subsystemm_requirements = new HashSet<>()

Detailed Description

A command that runs a given runnable when it is initialized, and another runnable when it ends. Useful for running and then stopping a motor, or extending and then retracting a solenoid. Has no end condition as-is; either subclass it or use Command#withTimeout(double) or Command#withInterrupt(BooleanSupplier) to give it one.

Constructor & Destructor Documentation

◆ StartEndCommand()

edu.wpi.first.wpilibj2.command.StartEndCommand.StartEndCommand ( Runnable  onInit,
Runnable  onEnd,
Subsystem...  requirements 

Creates a new StartEndCommand. Will run the given runnables when the command starts and when it ends.

onInitthe Runnable to run on command init
onEndthe Runnable to run on command end
requirementsthe subsystems required by this command

Member Function Documentation

◆ end()

void edu.wpi.first.wpilibj2.command.StartEndCommand.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.

interruptedwhether the command was interrupted/canceled

Implements edu.wpi.first.wpilibj2.command.Command.

◆ initialize()

void edu.wpi.first.wpilibj2.command.StartEndCommand.initialize ( )

The initial subroutine of a command. Called once when the command is initially scheduled.

Implements edu.wpi.first.wpilibj2.command.Command.

The documentation for this class was generated from the following file: