Running Commands on Joystick Input¶
This documentation describes the use of the legacy command-based library. While this documentation has been preserved to help teams that have yet to do so, teams are strongly encouraged to migrate to the new command-based library.
You can cause commands to run when joystick buttons are pressed, released, or continuously while the button is held down. This is extremely easy to do only requiring a few lines of code.
The OI Class¶
The command based template contains a class called OI, located in
OI.java, where Operator Interface behaviors are typically defined.
In addition to the
whenPressed() condition showcased above, there are a few other conditions you can use to link buttons to commands:
Commands can run when a button is released by using
Commands can run continuously while the button is depressed by calling
Commands can be toggled when a button is pressed using
A command can be canceled when a button is pressed using
Additionally commands can be triggered by arbitrary conditions of your choosing by using the Trigger class instead of Button. Triggers (and Buttons) are usually polled every 20ms or whenever the scheduler is called.