Package edu.wpi.first.wpilibj2.command
Class RunCommand
java.lang.Object
edu.wpi.first.wpilibj2.command.CommandBase
edu.wpi.first.wpilibj2.command.RunCommand
- All Implemented Interfaces:
Command
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.interruptOn(BooleanSupplier)
to give it one. If you only wish
to execute a Runnable once, use InstantCommand
.-
Constructor Summary
Constructors Constructor Description RunCommand(java.lang.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, getRequirements
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface edu.wpi.first.wpilibj2.command.Command
alongWith, andThen, asProxy, beforeStarting, cancel, deadlineWith, end, getName, hasRequirement, initialize, interruptOn, isFinished, isScheduled, perpetually, raceWith, runsWhenDisabled, schedule, schedule, whenFinished, withTimeout
-
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