Package edu.wpi.first.wpilibj2.command
Class StartEndCommand
java.lang.Object
edu.wpi.first.wpilibj2.command.CommandBase
edu.wpi.first.wpilibj2.command.FunctionalCommand
edu.wpi.first.wpilibj2.command.StartEndCommand
public class StartEndCommand extends FunctionalCommand
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.until(java.util.function.BooleanSupplier)
to give it one.
This class is provided by the NewCommands VendorDep
-
Nested Class Summary
Nested classes/interfaces inherited from interface edu.wpi.first.wpilibj2.command.Command
Command.InterruptionBehavior
-
Field Summary
Fields inherited from class edu.wpi.first.wpilibj2.command.FunctionalCommand
m_isFinished, m_onEnd, m_onExecute, m_onInit
-
Constructor Summary
Constructors Constructor Description StartEndCommand(Runnable onInit, Runnable onEnd, Subsystem... requirements)
Creates a new StartEndCommand. -
Method Summary
Methods inherited from class edu.wpi.first.wpilibj2.command.FunctionalCommand
end, execute, initialize, isFinished
Methods inherited from class edu.wpi.first.wpilibj2.command.CommandBase
addRequirements, getName, getRequirements, getSubsystem, initSendable, setName, setSubsystem
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, finallyDo, getInterruptionBehavior, handleInterrupt, hasRequirement, ignoringDisable, isScheduled, onlyIf, onlyWhile, raceWith, repeatedly, runsWhenDisabled, schedule, unless, until, withInterruptBehavior, withName, withTimeout
-
Constructor Details
-
StartEndCommand
Creates a new StartEndCommand. Will run the given runnables when the command starts and when it ends.- Parameters:
onInit
- the Runnable to run on command initonEnd
- the Runnable to run on command endrequirements
- the subsystems required by this command
-