Package edu.wpi.first.wpilibj2.command
Class RunCommand
- java.lang.Object
-
- edu.wpi.first.wpilibj2.command.CommandBase
-
- edu.wpi.first.wpilibj2.command.RunCommand
-
public class RunCommand extends CommandBase
A command that runs a Runnable continuously. Has no end condition as-is; either subclass it or useCommand.withTimeout(double)
orCommand.withInterrupt(BooleanSupplier)
to give it one. If you only wish to execute a Runnable once, useInstantCommand
.
-
-
Field Summary
Fields Modifier and Type Field Description protected Runnable
m_toRun
-
Fields inherited from class edu.wpi.first.wpilibj2.command.CommandBase
m_requirements
-
-
Constructor Summary
Constructors Constructor Description RunCommand(Runnable toRun, Subsystem... requirements)
Creates a new RunCommand.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
execute()
The main body of a command.-
Methods inherited from class edu.wpi.first.wpilibj2.command.CommandBase
addRequirements, getName, getRequirements, getSubsystem, initSendable, setName, setSubsystem, withName
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface edu.wpi.first.wpilibj2.command.Command
alongWith, andThen, andThen, asProxy, beforeStarting, beforeStarting, cancel, deadlineWith, end, hasRequirement, initialize, isFinished, isScheduled, perpetually, raceWith, runsWhenDisabled, schedule, schedule, withInterrupt, withTimeout
-
-
-
-
Constructor Detail
-
RunCommand
public 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:
toRun
- the Runnable to runrequirements
- the subsystems to require
-
-