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
use
Command.withTimeout(double)
or Command.withInterrupt(BooleanSupplier)
to give
it one. If you only wish to execute a Runnable once, use InstantCommand
.-
Field Summary
-
Constructor Summary
Constructors Constructor Description RunCommand(Runnable toRun, Subsystem... requirements)
Creates a new RunCommand. -
Method Summary
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
-
Field Details
-
Constructor Details
-
RunCommand
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
-
-
Method Details