Xbox Controller Tank Drive

Hello. My team would like to use a tank drive system to drive our robot. I know how to do it with two joysticks but not 1 joystick that is an xbox controller. Can anyone help? Thanks!

Instantiate the controller as a joystick.

The different physical stick on the controller are different axis to the code. You’ll have to hack a bit/google to figure it out, I can’t remember off the top of my head. The triggers are also another axis, with one pulling it negative, and the other pulling it positive.

I hope this helps.

As tp said, you can treat the XBox controller as a very strange joystick that has 6 different axes:

1 Left Joystick X
2 Left Joystick Y
3 Triggers
4 Right Joystick X
5 Right Joystick Y
6 DPAD X (never used this)

So, do joystick.GetRawAxis(2) for the left tank drive and joystick.GetRawAxis(5) for the right. You may need to change the signs of the input to get what you want.

Here is our XBOX Class

Here is our TankDrive Command

We init an XboxController object in the OI, and I have everything mapped out in the class for the axis. Makes it very simple to call from commands.

Go to run on your computer (if you’re using Windows) and search for / run “joy.cpl” (without quotes). Then go to properties (I think) and it should show you everything you could ever need to know about mapping the controller.

Ok thanks guys ill try that

We used one too! You can look at this code. It’s in C++ but the WPI syntax should be similar.

Alex Brinister