#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

# [solved] joystick angle

edited February 2016

Hi guys, I'm trying to set up an experiment in which participants point to things with a joystick. I'm interested in getting the pointing angle (in degrees) and the rt. The RT is no problem but I'm wondering if there's an easy way to get the angle (or at least the x-y coordinates and get the angle from there using trigonometry). Any ideas?
cheers,
m

• edited 12:19AM

Hi Mario,

The joystick plug-in (http://osdoc.cogsci.nl/devices/joystick/) has the function .get_joyaxes() which returns a position value. I suspect this to be an x,y-tuple, although it could also be the direct angle of the joystick. You could in any case verify this manually, by moving the joystick to a specific angle (for example the maximum, the angle of which is easiest to retrieve), and compare it to the output. Let me know if it works.

Cheers,

Josh

• edited 12:19AM

Thanks for the reply Josh. I've tried the .getjoyaxes() function and the position value I get is a tuple with 5 values. They range from -1 to 1 and the 4th one is always 0. Can't really tell what these numbers mean and I'm not sure why there's 5 of them!
marios

• edited February 2016

Hi Marios,

The joystick you're using seems to have 5 axis. You can figure out which values correspond to which axes by trial-and-error. If, by any chance, you're using the XBox 360 controller on Windows, please refer to this image. Other controllers (and the same controller under different operating systems) will be different.

Two of the axes should be the x- and y-axes for the main stick. The values of these axes range from -1 (all the way to one side) to 1 (all the way to the other side). 0 means the axis isn't angles at all.

Using Pythagoras, you can simply recalculate the two axes' states into an angle.

Good luck!

Edwin (wrote most of the joystick plug-in)

• edited 12:19AM

Ah, that explains it! I generally use Logitech Attack 3 joysticks for my experiments but I only had a more complex Saitek joystick at home yesterday to play with. Thanks for the reply Edwin, and for the plugin (I used your sample experiment to figure out how to make the joystick work).
Cheers,
marios

• edited 12:19AM

No worries!

The Attack 3 has three axes: x and y for the main stick, and a z-axis for the throttle (the bit you can slide up and down; it's on the side near to the user).

Not familiar with the Saitek brand, but I hear it's primarily for flight simulators? Sounds fancy!

Will mark this as solved. Thanks for letting us know!

Cheers,

Edwin