Search code examples
javaandroidgoogle-project-tango

How to get the rotation angle in Google Tango


I am developing an indoor location app with Google's Project Tango device, and I want the UI to display the device orientation with regard to the ADF map.

For this purpose I am accessing the Z axis rotation information from TangoPoseData, and try to convert the rotation data back to an angle in degrees.

The rotation information in TangoPoseData being defined as follows,
z = RotationAxis.z * sin(RotationAngle / 2)

my code looks like this:

//Sine value of the angle
double tangoRotationZsin = pose.rotation[2];

//Convert the sine value into a angle in radians
double tangoRotationZRad = 2*Math.asin(tangoRotationZsin);

//Convert to an angle in degrees
double tangoRotationZDeg = tangoRotationZRad * 180/Math.PI;

Problem:

The angle value in degrees (tangoRotationZDeg) should range from -180 to 180, but even if I rotate the device by 360 degrees several times on the Z axis, the angle ranges only from -120 to 120 degrees (or sometimes between -110 to 110 degrees).

What am I missing?
I guess that the problem has something to do with the "RotationAxis.z" factor in TangoPoseData which I assume equal to 1 in my code, but not sure.

Thank you for any help!


Solution

  • Look at this -- SO Post on extracting yaw from a quaternion - note that the TangoPoseData rotation is a quaternion value, not a set of Euler angles