Xboxcontroller trigger binding to commands

Hello, our team is trying to bind commands to the triggers(LT and RT) on our Xboxcontroller, but since they are axis and not buttons, it seems to not want to start the command even when writing driverRT.toggleOnTrue___. In previous years, we had separate analogbutton classes that could convert these axis triggers into on and off buttons, but due to a bunch of deprecations, we couldn’t use them anymore. Does anyone have an updated analogbutton class, or a solution to use the triggers as an on and off command button?

You should definitely switch to the CommandXboxController class (new for 2023): Binding Commands to Triggers — FIRST Robotics Competition documentation

1 Like

With the command Xbox controller, the triggers are built in CommandXboxController (WPILib API 2023.4.2)

Is there a way to accomplish the same task with xboxcontroller class? Our team had one issue with CommandXboxcontroller which was that there was no method to return the boolean of a pressed bumper(driver.getRawButton) which was something we use in drive controls, so we changed to xboxcontroller.

CommandXboxController controller = ....

This should work. That said, if you’re using command-based, you really shouldn’t need to do this. If you’re not using command-based, carry on (but you should definitely look into it)

This is what we did last year before command Xbox controller existed FRC2022/ at 022a43a90aa1f021a7c47ef2dbddd4ba579fad91 · Frc5572/FRC2022 · GitHub.

The way we’re doing it is just triggering when you press it more than halfway. It’s pretty simple in code, needing about the exact same amount as a normal button.

controller.leftTrigger(0.5).whileTrue(new WhateverCommandHere());

This is using the CommandXboxController class for our controllers, which works amazingly with the new wpilib updates.

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.