Using a button to make controls flip

I’m not really sure what to ask, so I’ll try to explain what we want to do.

We went with mecanum drive this year. Basically, we want to be able to press a button, and it flip all of our drive controls. So, for instance, when button has not been pressed, controls would be Forwards/Back, Strafe Left/Right, Rotate Left/Right. After the button was pressed, it would be Back/Forwards, Strafe Right/Left, Rotate Right/Left.

I’m pretty sure we can achieve this with something alone the lines of a True/False case structure, but I wanted to be able to press a button to activate it, and press that button (or another, it doesn’t matter) to deactivate it, and I’m not sure how to accomplish that.

Thanks in advance, please ask questions if I was unclear on what I was asking.

See here:

What language are you coding in? Cause that’ll affect some things. Regardless the boolean toggle would be the way to go. The way that I coded our Gemini Drive (that’s what I’ve been calling it) is by having the code look at both controllers constantly. For us, if Start and Select are active at the same time then the boolean changes to true thus running drive code altered for one direction and vice versa for the other controller.

So have two sets of drive code that change based on the state of a boolean, and tie thaat boolean to button combinations on the controllers or to some other button.

Here is the link to our code:
The two files to look at would be ArcadeDrive_cmd and Chassis in the command and subsystem folders respectively. Just in case you’d like to see how we did it. Hope this helps!

I assume that the reason you want to know this is so that you can drive easier when you are turned around. Alternatively, you could use WPI’s built in field-oriented mecanum functionality, so that forward is always down the field, down is towards you, left is your left, etc. relative to the driver, not the robot.

Thank you! Works perfectly