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

Public Member Functions

 RunCommand (Runnable toRun, Subsystem... requirements)
 
void execute ()
 
- 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 initialize ()
 
default void end (boolean interrupted)
 
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_toRun
 
- Protected Attributes inherited from edu.wpi.first.wpilibj2.command.CommandBase
Set< Subsystemm_requirements = new HashSet<>()
 

Detailed Description

A command that runs a Runnable continuously. Has no end condition as-is; either subclass it or use Command#withTimeout(double) or Command#withInterrupt(BooleanSupplier) to give it one. If you only wish to execute a Runnable once, use InstantCommand.

Constructor & Destructor Documentation

◆ RunCommand()

edu.wpi.first.wpilibj2.command.RunCommand.RunCommand ( Runnable  toRun,
Subsystem...  requirements 
)

Creates a new RunCommand. The Runnable will be run continuously until the command ends. Does not run when disabled.

Parameters
toRunthe Runnable to run
requirementsthe subsystems to require

Member Function Documentation

◆ execute()

void edu.wpi.first.wpilibj2.command.RunCommand.execute ( )

The main body of a command. Called repeatedly while the command is scheduled.

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


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