Package org.chsrobotics.lib.commands
Class ConditionalRunnableCommand
- java.lang.Object
-
- edu.wpi.first.wpilibj2.command.CommandBase
-
- org.chsrobotics.lib.commands.ConditionalRunnableCommand
-
- All Implemented Interfaces:
edu.wpi.first.util.sendable.Sendable,edu.wpi.first.wpilibj2.command.Command
public class ConditionalRunnableCommand extends edu.wpi.first.wpilibj2.command.CommandBaseClass to allow execution of methods (with no parameters) upon boolean state change, in the command-based structure.
-
-
Constructor Summary
Constructors Constructor Description ConditionalRunnableCommand(java.lang.Runnable onTrue, java.lang.Runnable onFalse, java.util.function.Supplier<java.lang.Boolean> conditional, double durationSeconds, edu.wpi.first.wpilibj2.command.Subsystem... toRequire)Constructs a ConditionalRunnableCommand.ConditionalRunnableCommand(java.lang.Runnable onTrue, java.lang.Runnable onFalse, java.util.function.Supplier<java.lang.Boolean> conditional, edu.wpi.first.wpilibj2.command.Subsystem... toRequire)Constructs a ConditionalRunnableCommand that does not end.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidexecute()voidinitialize()booleanisFinished()booleanrunsWhenDisabled()voidsetRunsWhileDisabled(boolean runsWhileDisabled)Sets whether this command should continue to run even while the robot is in a disabled state.-
Methods inherited from class edu.wpi.first.wpilibj2.command.CommandBase
addRequirements, getName, getRequirements, getSubsystem, initSendable, setName, setSubsystem, withName
-
-
-
-
Constructor Detail
-
ConditionalRunnableCommand
public ConditionalRunnableCommand(java.lang.Runnable onTrue, java.lang.Runnable onFalse, java.util.function.Supplier<java.lang.Boolean> conditional, double durationSeconds, edu.wpi.first.wpilibj2.command.Subsystem... toRequire)Constructs a ConditionalRunnableCommand.- Parameters:
onTrue- Method to be called whenconditionalchanges fromfalsetotrue. Ifnull, will not be called.onFalse- Method to be called whenconditionalchanges fromtruetofalse. Ifnull, will not be called.conditional- Lambda of a boolean state dictating when the runnables should be called.durationSeconds- Time that this command should be active for; if less than zero, this command will not end; if zero, this command will start and end in the same command scheduler loop.toRequire- Any subsystems required to be freed for the method.
-
ConditionalRunnableCommand
public ConditionalRunnableCommand(java.lang.Runnable onTrue, java.lang.Runnable onFalse, java.util.function.Supplier<java.lang.Boolean> conditional, edu.wpi.first.wpilibj2.command.Subsystem... toRequire)Constructs a ConditionalRunnableCommand that does not end.- Parameters:
onTrue- Method to be called whenconditionalchanges fromfalsetotrue. Ifnull, will not be called.onFalse- Method to be called whenconditionalchanges fromtruetofalse. Ifnull, will not be called.conditional- Lambda of a boolean state dictating when the runnables should be called.toRequire- Any subsystems required to be freed for the method.
-
-
Method Detail
-
setRunsWhileDisabled
public void setRunsWhileDisabled(boolean runsWhileDisabled)
Sets whether this command should continue to run even while the robot is in a disabled state.- Parameters:
runsWhileDisabled- True if this command should continue in the disabled state.
-
runsWhenDisabled
public boolean runsWhenDisabled()
-
initialize
public void initialize()
-
execute
public void execute()
-
isFinished
public boolean isFinished()
-
-