I believe they are computed from the quaternion, which is in turn computed 
from the fusion of magnetometer, accelerometer and if available gyroscope 
sensors.  Lance has pointed to some good reading the the Android SDK docs, 
but these are not complete.  For example, the documentation does not 
specify the order in which yaw, pitch and roll is to be applied, which is 
VERY important.  I am assuming yaw, then pitch, then roll in sync with 
Microsoft and HTML5 standards.  From what I have seen on phones, few 
implement the android specs correctly anyway so it is hard to tell.  (Many 
put pitch in range of 90 to -90 and not roll).  The other thing to be very 
cautious of is that yaw pitch and roll in Android are LEFT handed rotations.

Note that one sensor is not enough to determine orientation (rotate a phone 
laying flat on a table and accelerometer will read the same value no matter 
how you rotate it in z, in a perfectly aligned system).  If you have good 
mag (and mags are noisy and require a heavy calibration, btw), then you can 
compute yaw as

 yaw =- atan2(magX, magY)

pitch,roll  from accel can be done but is a little tricky to get in the 
right range.  Most phones should be using a Kalman Filter to compute 
orientation via a quaternion, though, and derive YPR from that.  There are 
direct calls in android to getOrientation.

On Sunday, October 4, 2009 5:57:30 AM UTC-7, DD wrote:
>
> Hi, 
>
> It seems that for onSensorChanged(), the orientation readings 
> (yaw,pitch,roll) are not detected directly, but computed from the 
> acceleration readings. Does anybody know how they do this calculation? 
> is it by rotationmatrix..? May I know exactly the calculation process? 
>
> Thanks!

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to