New Command Framework Xbox Triggers

With the new command based frame work there has been a change in how Buttons were created, by using the JoystickButton object to create the button. My team and I are using an xbox controller and are trying to assign actions to the triggers, but can’t seem to assign a trigger the same way we would with a regular button or how we did last year with if statements. What do we have to do to do that with the new framework in the RobotContainer. Thank you!!

Triggers are analog axes. You will have to subclass the Trigger class ( which by itself has nothing to do with the actual triggers) and return true if the axis is greater than whatever threshold value you pick.

You can do this inline without any subclassing by passing a lambda to the button class.

You guys continue to impress me. How would we do that?

That’s what we were doing with the rest of our buttons, we just couldn’t find how to use Triggers and not the Buttons

I’d assume Something like this

new Button(() -> stick.getRawAxis(axisNum) > theshold);

Ah cool. TIL.

I am still confused, I want to use a trigger to run a motor, is there some example code I can see/use?

There is a list of many different examples, all of which generally can make the robot drive with a trigger.

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