Ps3/360 controller with robot programmed in Java

Hi all,

We’re interested in knowing how our team could drive our robot using a Ps3 controller/Xbox 360 controller. We are programming our robot in Java. Can anyone help us out? Thanks.

The driver station should see it as a Joystick. Install any drivers you would normally need (google for them), and then the controller should have its hats (the sticks) enumerated as axes and buttons numbered.

If you’re having problems figuring out which axis/buttons on the controllers are which, go to Control Panel > Game Controllers.

Then, you select the game controller and click properties. Now, you can calibrate your device and see which axes is which number, and which button is which.

Hint: Look at the documentation for the Joystick class for more information on how to read Joystick inputs.

My edits are getting a bit excessive, sorry. I’m in a situation similar to OP’s, and I wanted to get the D-Pad working properly.

I thought I had found the solution to my problem. I just need to find out what the “Point of View Hat” (The D-Pad) is according to the WPI Libraries.

I know that Left-Right movement is read as Axis 6, but Up-Down movement is either not recognized by the Joystick class (being an axis higher than 6), or something else that I’m not thinking of.

it only has six axes

One would think… but I actually found 7.

Left Analog Up/Down (Axis 2)
Left Analog Left/Right (Axis 1)
Right Analog Up/Down (Axis 5)
Right Analog Left/Right (Axis 4)
D-Pad Up/Down (Axis 7?)
D-Pad Left/Right (Axis 6)
Left/Right Triggers (yes, for some reason, these form their own set of axes, where pressing the left trigger outputs a positive value, and pressing the right trigger outputs a negative value) (Axis 3)

If you would like to use a PS/3 controller you need a program called motionjoy to use its full funtionality. Our team is using a PS/3 controller with its 7 axis capibilities its very stable and easy to use.

Programmer Matt
Gus Robotics, team228.org

Sorry but the D-Pad is not an axis the 7 axis’s are
Left Right joysticks would be 4
tilt foward back side side would be 2
and the variable triggers is 1

Programmer Matt,
Gus Robotics, team228.org

If I were using a PS3 controller, that would definitely be the case.

    public static int getDPad1( )
    {
        return 6;
    }

This is a snippet of code I’m using in a config file that is imported into our main robot code, referenced here:

if ( opControl.getRawAxis( ControllerConfig.getDPad1( ) ) >= 0.03 )
            {
                System.out.println( "This is Axis #6." );
            }

In this case, when the robot is running in teleoperated mode, and the D-Pad is pressed to the right, it prints “This is Axis #6.” This is placeholder code, but it’s apparent that if I try to create and call a 7th axis, it won’t work. I just want to know if there’s some sort of workaround so I can use the Up-Down axis of the D-Pad.