Package org.team1126.lib.util.command
Class CommandBuilder
java.lang.Object
edu.wpi.first.wpilibj2.command.Command
org.team1126.lib.util.command.CommandBuilder
- All Implemented Interfaces:
edu.wpi.first.util.sendable.Sendable
public class CommandBuilder
extends edu.wpi.first.wpilibj2.command.Command
A command builder. Very similar to
FunctionalCommand.
Stylistic alternative to using decorators.-
Nested Class Summary
Nested classes/interfaces inherited from class edu.wpi.first.wpilibj2.command.Command
edu.wpi.first.wpilibj2.command.Command.InterruptionBehavior -
Constructor Summary
ConstructorsConstructorDescriptionCommandBuilder(edu.wpi.first.wpilibj2.command.Subsystem... requirements) Create the command builder.CommandBuilder(String name, edu.wpi.first.wpilibj2.command.Subsystem... requirements) Create the command builder. -
Method Summary
Modifier and TypeMethodDescriptionvoidend(boolean interrupted) voidexecute()voidbooleanisFinished(boolean isFinished) Whether the command has finished.isFinished(BooleanSupplier isFinished) Whether the command has finished.onEnd(edu.wpi.first.util.function.BooleanConsumer onEnd) The action to take when the command ends.The action to take when the command ends.The main body of a command.onInitialize(Runnable onInitialize) The initial subroutine of a command.Methods inherited from class edu.wpi.first.wpilibj2.command.Command
addRequirements, addRequirements, alongWith, andThen, andThen, asProxy, beforeStarting, beforeStarting, cancel, deadlineFor, deadlineWith, finallyDo, finallyDo, getInterruptionBehavior, getName, getRequirements, getSubsystem, handleInterrupt, hasRequirement, ignoringDisable, initSendable, isScheduled, onlyIf, onlyWhile, raceWith, repeatedly, runsWhenDisabled, schedule, setName, setSubsystem, unless, until, withDeadline, withInterruptBehavior, withName, withTimeout, withTimeout
-
Constructor Details
-
CommandBuilder
Create the command builder.- Parameters:
name- The command's name.requirements- The subsystems required by the command.
-
CommandBuilder
public CommandBuilder(edu.wpi.first.wpilibj2.command.Subsystem... requirements) Create the command builder.- Parameters:
requirements- The subsystems required by the command.
-
-
Method Details
-
onInitialize
The initial subroutine of a command. Called once when the command is initially scheduled. -
onExecute
The main body of a command. Called repeatedly while the command is scheduled. -
onEnd
The action to take when the command ends. Called when either the command finishes normally, or when it interrupted/canceled. -
onEnd
The action to take when the command ends. Called when either the command finishes normally, or when it interrupted/canceled. Supplied boolean is if the command was interrupted. -
isFinished
Whether the command has finished. Once a command finishes, the scheduler will call its end() method and un-schedule it. By default, this returnsfalse. Iftrue, the command is effectively anInstantCommand. Iffalse, the command will run continuously until it is canceled. -
isFinished
Whether the command has finished. Once a command finishes, the scheduler will call its end() method and un-schedule it. By default, this returnsfalse. -
initialize
public void initialize()- Overrides:
initializein classedu.wpi.first.wpilibj2.command.Command
-
execute
public void execute()- Overrides:
executein classedu.wpi.first.wpilibj2.command.Command
-
end
public void end(boolean interrupted) - Overrides:
endin classedu.wpi.first.wpilibj2.command.Command
-
isFinished
public boolean isFinished()- Overrides:
isFinishedin classedu.wpi.first.wpilibj2.command.Command
-