public abstract class ConditionalCommand extends Command
ConditionalCommand is a Command that starts one of two commands.
 
 A ConditionalCommand uses m_condition to determine whether it should run m_onTrue or
 m_onFalse.
 
 A ConditionalCommand adds the proper Command to the Scheduler during
 Command.initialize() and then isFinished() will
 return true once that Command has finished executing.
 
 If no Command is specified for m_onFalse, the occurrence of that condition will be a
 no-op.
 
| Constructor and Description | 
|---|
| ConditionalCommand(Command onTrue)Creates a new ConditionalCommand with given onTrue and onFalse Commands. | 
| ConditionalCommand(Command onTrue,
                  Command onFalse)Creates a new ConditionalCommand with given onTrue and onFalse Commands. | 
| ConditionalCommand(java.lang.String name,
                  Command onTrue)Creates a new ConditionalCommand with given name and onTrue and onFalse Commands. | 
| ConditionalCommand(java.lang.String name,
                  Command onTrue,
                  Command onFalse)Creates a new ConditionalCommand with given name and onTrue and onFalse Commands. | 
| Modifier and Type | Method and Description | 
|---|---|
| protected void | _cancel()This works like cancel(), except that it doesn't throw an exception if it is a part of a
 command group. | 
| protected void | _initialize()Calls  condition()and runs the proper command. | 
| protected abstract boolean | condition()The Condition to test to determine which Command to run. | 
| protected void | interrupted()Called when the command ends because somebody called  cancel()or
 another command shared the same requirements as this one, and booted it out. | 
| protected boolean | isFinished()Returns whether this command is finished. | 
cancel, clearRequirements, doesRequire, end, execute, getGroup, getName, getSmartDashboardType, getTable, initialize, initTable, isCanceled, isInterruptible, isRunning, isTimedOut, requires, setInterruptible, setRunWhenDisabled, setTimeout, start, timeSinceInitialized, toString, willRunWhenDisabledpublic ConditionalCommand(Command onTrue)
Users of this constructor should also override condition().
onTrue - The Command to execute if condition() returns truepublic ConditionalCommand(Command onTrue, Command onFalse)
Users of this constructor should also override condition().
onTrue - The Command to execute if condition() returns trueonFalse - The Command to execute if condition() returns falsepublic ConditionalCommand(java.lang.String name, Command onTrue)
Users of this constructor should also override condition().
name - the name for this command grouponTrue - The Command to execute if condition() returns truepublic ConditionalCommand(java.lang.String name, Command onTrue, Command onFalse)
Users of this constructor should also override condition().
name - the name for this command grouponTrue - The Command to execute if condition() returns trueonFalse - The Command to execute if condition() returns falseprotected abstract boolean condition()
protected void _initialize()
condition() and runs the proper command.protected void _cancel()
Commandprotected boolean isFinished()
Commandend() 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 CommandisTimedOut()protected void interrupted()
Commandcancel() or
 another command shared the same requirements as this one, and booted it out.
 This is where you may want to wrap up loose ends, like shutting off a motor that was being used in the command.
Generally, it is useful to simply call the end() method within this
 method, as done here.
interrupted in class Command