public class InstantCommand extends Command
Subclassing InstantCommand
is shorthand for returning true from
isFinished
.
Constructor and Description |
---|
InstantCommand() |
InstantCommand(Runnable func)
Creates a new
InstantCommand . |
InstantCommand(String name)
Creates a new
InstantCommand with the given name. |
InstantCommand(String name,
Runnable func)
Creates a new
InstantCommand . |
InstantCommand(String name,
Subsystem subsystem)
Creates a new
InstantCommand with the given name and requirement. |
InstantCommand(String name,
Subsystem requirement,
Runnable func)
Creates a new
InstantCommand . |
InstantCommand(Subsystem subsystem)
Creates a new
InstantCommand with the given requirement. |
InstantCommand(Subsystem requirement,
Runnable func)
Creates a new
InstantCommand . |
Modifier and Type | Method and Description |
---|---|
protected void |
_initialize()
Trigger the stored function.
|
protected boolean |
isFinished()
Returns whether this command is finished.
|
cancel, clearRequirements, doesRequire, end, execute, getGroup, initialize, initSendable, interrupted, isCanceled, isCompleted, isInterruptible, isRunning, isTimedOut, requires, setInterruptible, setRunWhenDisabled, setTimeout, start, timeSinceInitialized, toString, willRunWhenDisabled
addChild, close, free, getName, getSubsystem, setName, setName, setName, setSubsystem
public InstantCommand()
public InstantCommand(String name)
InstantCommand
with the given name.name
- the name for this commandpublic InstantCommand(Subsystem subsystem)
InstantCommand
with the given requirement.subsystem
- the subsystem this command requirespublic InstantCommand(String name, Subsystem subsystem)
InstantCommand
with the given name and requirement.name
- the name for this commandsubsystem
- the subsystem this command requirespublic InstantCommand(Runnable func)
InstantCommand
.func
- the function to run when initialize()
is runpublic InstantCommand(String name, Runnable func)
InstantCommand
.name
- the name for this commandfunc
- the function to run when initialize()
is runpublic InstantCommand(Subsystem requirement, Runnable func)
InstantCommand
.requirement
- the subsystem this command requiresfunc
- the function to run when initialize()
is runpublic InstantCommand(String name, Subsystem requirement, Runnable func)
InstantCommand
.name
- the name for this commandrequirement
- the subsystem this command requiresfunc
- the function to run when initialize()
is runprotected boolean isFinished()
Command
end()
will be called.
It may be useful for a team to reference the isTimedOut()
method for time-sensitive commands.
Returning false will result in the command never ending automatically. It may still be
cancelled manually or interrupted by another command. Returning true will result in the
command executing once and finishing immediately. We recommend using InstantCommand
for this.
isFinished
in class Command
isTimedOut()
protected void _initialize()
Called just before this Command runs the first time.