Currently, I am trying to combine accelerometer and gyroscope on android phone to calculate the orientation (how much angle each axis rotates) of the phone. I know that acceleration cannot simply calculate the exact orientation of the phone but it could calculate a "steady state" of orientation and then gyroscope could monitor the change of orientation. But I am stuck at the first step. Does anybody know how to use acceleration data to get the approximate orientation? Is there any formula to calculate the angle rotated by each axis?
Asked
Active
Viewed 1,143 times
1 Answers
1
It sounds like you need to convert the gravity vector to polar coordinates, invert it so that it represents 'up', and then negate the angles so that it represents the offset of the phone from vertical rather than the offset of vertical from the phone.
Step one is described here: http://en.wikipedia.org/wiki/Spherical_coordinate_system#Cartesian_coordinates
For the rest I think θ' = π - Θ and φ' = π - φ works.

James Moughan
- 413
- 2
- 3