Java XboxController.getLeftTriggerAxis() how to use it for making my motor spin

Hi there im programming our Robots Controller and im running into a problem with our XboxController from 2021 to 2022 they updated the triggers on the XboxController and i was wondering if anyone could help me with getting the value of the double when you call that trigger and how to make it as like if statement.

Here is some of the code i have now
rightTriggerAxis = xboxController.getRightTriggerAxis(); while(rightTriggerAxis >= 0.5){ System.out.println("Were Shootings"); }
and this will display but when we load the simulator it starts calling it before we put it in teleop and i was wondering if anyone had any idea on how to use these.

Hey Devin, welcome to chief Delphi!

Would it be possible to share more of your code? If not can you share in what method you have placed this code block?

Lastly, it’s not often advisable to have a while loop in your FRC code (see here Are loops ok in FRC Programming) as it could possibly cause you to overrun the 20 ms periodic cycle of the period functions.

You might want to use a small piece of code to convert the trigger value to a button state.

This will do: FRC2495-2022/ at main · FRC2495/FRC2495-2022 (

Here cause with the new xboxcontroller import you can just get the buttons like if(Xboxcontroller.getXbuttonPressed){
run command}
but when i get the controller leftTriggerAxis i cant put it in a if statment.

here is more code

new JoystickButton(xboxController, 8).whileActiveOnce

(new WenchDownCmd(wenchSubsystem, WenchConstants.kMotorSpeed));

new JoystickButton(xboxController, 9).whileActiveOnce(

new ShootForwardCmd(shooterSubsysten, ShooterConstants.kleftMotorSpeed, ShooterConstants.krightMotorSpeed));

rightTriggerAxis = xboxController.getRightTriggerAxis();

if(rightTriggerAxis >= 0.5){

System.out.println("Were Shootings");


if (xboxController.getXButtonPressed()){

System.out.println("X Button is  pressed");


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