morgil / madgwick_py

A Python implementation of Madgwick's IMU and AHRS algorithm.
GNU Lesser General Public License v3.0
178 stars 60 forks source link

Acc/Gyro/Mag axis reference - which is which? #4

Open mungewell opened 5 years ago

mungewell commented 5 years ago

I've been trying to implement the AHRS with the sensors from the PlayStationVR headset, and getting confused about which axis should be which.

From reading the sensor values, as arrays, I have:

Structure of the PSVR sensor: Gyros (when wearing headset normally). 1 - yaw, +ve right hand forward 2 - pitch, +ve look up 3 - roll, +ve right hand down Accelerometers, largest when 'x' is highest point 1 - top+, bottom- 2 - right+, left- 3 - front+, back-

And on the other end, when the rendering the scene from the output of Madgewick I know that the following are true (tested by setting during init and not updating the AHRS):

Quaternion that points directly forward refq = Quaternion((1,0,0,0))

Quaternion pointing/pitched directly up refq = Quaternion.from_angle_axis(np.pi/2,1,0,0)

No matter how I've tried swapping various axis I have not yet reached a working system, it either 'moves' incorrectly or the Quaternion ends up pointing in the wrong direction....

Can someone/any provide a reference for how the axis should be arranged?