Package edu.wpi.first.wpilibj2.command
Class InstantCommand
- java.lang.Object
-
- edu.wpi.first.wpilibj2.command.CommandBase
-
- edu.wpi.first.wpilibj2.command.InstantCommand
-
- Direct Known Subclasses:
PrintCommand
public class InstantCommand extends CommandBase
A Command that runs instantly; it will initialize, execute once, and end on the same iteration of the scheduler. Users can either pass in a Runnable and a set of requirements, or else subclass this command if desired.
-
-
Field Summary
-
Fields inherited from class edu.wpi.first.wpilibj2.command.CommandBase
m_requirements
-
-
Constructor Summary
Constructors Constructor Description InstantCommand()
Creates a new InstantCommand with a Runnable that does nothing.InstantCommand(Runnable toRun, Subsystem... requirements)
Creates a new InstantCommand that runs the given Runnable with the given requirements.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
initialize()
The initial subroutine of a command.boolean
isFinished()
Whether the command has finished.-
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, execute, hasRequirement, isScheduled, perpetually, raceWith, runsWhenDisabled, schedule, schedule, withInterrupt, withTimeout
-
-
-
-
Constructor Detail
-
InstantCommand
public InstantCommand(Runnable toRun, Subsystem... requirements)
Creates a new InstantCommand that runs the given Runnable with the given requirements.- Parameters:
toRun
- the Runnable to runrequirements
- the subsystems required by this command
-
InstantCommand
public InstantCommand()
Creates a new InstantCommand with a Runnable that does nothing. Useful only as a no-arg constructor to call implicitly from subclass constructors.
-
-
Method Detail
-
initialize
public void initialize()
Description copied from interface:Command
The initial subroutine of a command. Called once when the command is initially scheduled.
-
isFinished
public final boolean isFinished()
Description copied from interface:Command
Whether the command has finished. Once a command finishes, the scheduler will call its end() method and un-schedule it.- Returns:
- whether the command has finished.
-
-