-
Notifications
You must be signed in to change notification settings - Fork 6
Calling a Command Based on Button Press
Buttons on the logitech controller correspond to integers. We name each one with their buttons in the LogitechControllerButtons class (included in the Common Library). Make sure you have this class inside the project.
We assign button bindings (to control robot elements) inside the RobotContainer class, binding certain buttons to certain commands to run. All buttons are assigned in the RobotContainer class, so navigate there first before doing anything else.
Buttons can be bound to either the primary or secondary controller. Make sure to put your bindings under the corresponding method, either:
configurePrimaryBindings( ) , or configureSecondaryBindings( ).
To initialize a button use the type “JoystickButton” and define it as a new JoystickButton constructor, and pass in the controller the button will use, and the button’s identity from LCB (logitech controller buttons)
JoystickButton a = new JoystickButton(secondaryController, LogitechControllerButtons.a);For D-pad inputs be sure to use “POVButton” instead as the type and the constructor. These are still under LCB, so don’t worry about adding more files.
POVButton up = new POVButton(secondaryController, LogitechControllerButtons.up);After defining the button, assign a command to the button you want to run when it is either on press (onTrue), button released (onFalse), while pressed (whileTrue), and while not pressed (whileFalse).
On press: when you first press the button, the command is called once. While pressed: the command is called continuously while the button is held down.
For example, the following buttons are assigned to separate commands:
a.onTrue(new ShootBallCommand(0, shooter));
up.onFalse(new SetElevatorTargetCommand(Constants.topElevatorTargetPosition, elevator));This is an officially licensed product of Team 4026. Decatur Robotics 2024 is not sponsored by any other Team, and is not responsible for any damages caused by using this product or trusting the programming team, which is by far the least most trustworthy team(Shadow owen money gang, we love coding the robot). By using this product, you are consenting to your information, and thus your identity to be stolen and first-born child taken.
- Editing Documentation & Markdown Syntax
- Code Team to-do List
- Code Standards
- Common Library Structure
- Interfaces
- General Setup
- Branching System
- How to Create Pull Requests
- How to Switch Branches
- Code Reviews
- Reverting Commits
- Singleton Pattern
- Software Installations
- Necessary IntelliJ Plugins
- Vendordeps
- Setting Up New Projects
- Autoformatter Set Up
- Showbot Requirements
- Autonomous
- Calling a Command Based on a Button Press
- CAN
- Clearing Sticky Faults
- Current Limits
- PID Config and Usage
- Robot.java, TeleopInit, DisabledInit
- RoboRio Ports
- SetDefaultCommand
- Wait for Time
- SlewRateLimiter
- LEDs
- InstantCommand
- PhotonVision
- Apriltags
- Camera Display on Shuffleboard
- Object Detection
- Raspberry Pi
- Network Tables
- List of Network Tables (2023)
Up to date as of SJ2, end of 2023 season