RobotCore
Robot Core Documentation
|
Public Member Functions | |
Trigger (BooleanSupplier isActive) | |
Trigger () | |
boolean | get () |
Trigger | whenActive (final Command command, boolean interruptible) |
Trigger | whenActive (final Command command) |
Trigger | whenActive (final Runnable toRun, Subsystem... requirements) |
Trigger | whileActiveContinuous (final Command command, boolean interruptible) |
Trigger | whileActiveContinuous (final Command command) |
Trigger | whileActiveContinuous (final Runnable toRun, Subsystem... requirements) |
Trigger | whileActiveOnce (final Command command, boolean interruptible) |
Trigger | whileActiveOnce (final Command command) |
Trigger | whenInactive (final Command command, boolean interruptible) |
Trigger | whenInactive (final Command command) |
Trigger | whenInactive (final Runnable toRun, Subsystem... requirements) |
Trigger | toggleWhenActive (final Command command, boolean interruptible) |
Trigger | toggleWhenActive (final Command command) |
Trigger | cancelWhenActive (final Command command) |
Trigger | and (Trigger trigger) |
Trigger | or (Trigger trigger) |
Trigger | negate () |
This class provides an easy way to link commands to inputs.
It is very easy to link a button to a command. For instance, you could link the trigger button of a joystick to a "score" command.
It is encouraged that teams write a subclass of Trigger if they want to have something unusual (for instance, if they want to react to the user holding a button while the robot is reading a certain sensor input). For this, they only have to write the Trigger#get() method to get the full functionality of the Trigger class.
edu.wpi.first.wpilibj2.command.button.Trigger.Trigger | ( | BooleanSupplier | isActive | ) |
Creates a new trigger with the given condition determining whether it is active.
isActive | returns whether or not the trigger should be active |
edu.wpi.first.wpilibj2.command.button.Trigger.Trigger | ( | ) |
Creates a new trigger that is always inactive. Useful only as a no-arg constructor for subclasses that will be overriding Trigger#get() anyway.
Composes this trigger with another trigger, returning a new trigger that is active when both triggers are active.
trigger | the trigger to compose with |
Cancels a command when the trigger becomes active.
command | the command to cancel |
boolean edu.wpi.first.wpilibj2.command.button.Trigger.get | ( | ) |
Returns whether or not the trigger is active.
This method will be called repeatedly a command is linked to the Trigger.
Reimplemented in edu.wpi.first.wpilibj2.command.button.JoystickButton, and edu.wpi.first.wpilibj2.command.button.InternalButton.
Trigger edu.wpi.first.wpilibj2.command.button.Trigger.negate | ( | ) |
Creates a new trigger that is active when this trigger is inactive, i.e. that acts as the negation of this trigger.
Composes this trigger with another trigger, returning a new trigger that is active when either trigger is active.
trigger | the trigger to compose with |
Toggles a command when the trigger becomes active. The command is set to be interruptible.
command | the command to toggle |
Trigger edu.wpi.first.wpilibj2.command.button.Trigger.toggleWhenActive | ( | final Command | command, |
boolean | interruptible | ||
) |
Toggles a command when the trigger becomes active.
command | the command to toggle |
interruptible | whether the command is interruptible |
Starts the given command whenever the trigger just becomes active. The command is set to be interruptible.
command | the command to start |
Trigger edu.wpi.first.wpilibj2.command.button.Trigger.whenActive | ( | final Command | command, |
boolean | interruptible | ||
) |
Starts the given command whenever the trigger just becomes active.
command | the command to start |
interruptible | whether the command is interruptible |
Trigger edu.wpi.first.wpilibj2.command.button.Trigger.whenActive | ( | final Runnable | toRun, |
Subsystem... | requirements | ||
) |
Runs the given runnable whenever the trigger just becomes active.
toRun | the runnable to run |
requirements | the required subsystems |
Starts the command when the trigger becomes inactive. The command is set to be interruptible.
command | the command to start |
Trigger edu.wpi.first.wpilibj2.command.button.Trigger.whenInactive | ( | final Command | command, |
boolean | interruptible | ||
) |
Starts the command when the trigger becomes inactive.
command | the command to start |
interruptible | whether the command is interruptible |
Trigger edu.wpi.first.wpilibj2.command.button.Trigger.whenInactive | ( | final Runnable | toRun, |
Subsystem... | requirements | ||
) |
Runs the given runnable when the trigger becomes inactive.
toRun | the runnable to run |
requirements | the required subsystems |
Trigger edu.wpi.first.wpilibj2.command.button.Trigger.whileActiveContinuous | ( | final Command | command | ) |
Constantly starts the given command while the button is held.
Command#schedule(boolean) will be called repeatedly while the trigger is active, and will be canceled when the trigger becomes inactive. The command is set to be interruptible.
command | the command to start |
Trigger edu.wpi.first.wpilibj2.command.button.Trigger.whileActiveContinuous | ( | final Command | command, |
boolean | interruptible | ||
) |
Constantly starts the given command while the button is held.
Command#schedule(boolean) will be called repeatedly while the trigger is active, and will be canceled when the trigger becomes inactive.
command | the command to start |
interruptible | whether the command is interruptible |
Trigger edu.wpi.first.wpilibj2.command.button.Trigger.whileActiveContinuous | ( | final Runnable | toRun, |
Subsystem... | requirements | ||
) |
Constantly runs the given runnable while the button is held.
toRun | the runnable to run |
requirements | the required subsystems |
Starts the given command when the trigger initially becomes active, and ends it when it becomes inactive, but does not re-start it in-between. The command is set to be interruptible.
command | the command to start |
Trigger edu.wpi.first.wpilibj2.command.button.Trigger.whileActiveOnce | ( | final Command | command, |
boolean | interruptible | ||
) |
Starts the given command when the trigger initially becomes active, and ends it when it becomes inactive, but does not re-start it in-between.
command | the command to start |
interruptible | whether the command is interruptible |