Search code examples
androidaccelerometer

Determining the yaw angle using only the accelerometer


Is it possible to determine the yaw angle of the device (rotation about a vertical axis) using only the accelerometer? I know how to do it using a magnetometer (compass).

enter image description here


Solution

  • I wonder if this is off-topic, because the answer is "no" and the explanation is about physics, not programming (it could be on-topic if the answer was "yes"). But let me help you here.

    You can think of an accelerometer as a set of 3 springs (or dynamometers) that measure forces applied to an inner weight of a. along 3 axes (x, y, z). If the device is not accelerated, it shows g force applied along z. Now, one can measure Roll and Pitch because if those are non-zero, gravity is applied in another direction (remember that we use frame of reference attached to the device). However, if Roll and Pitch are zero, no matter what your Yaw is, you get only (0,0,g) vector from the accelerometer (so you can't deduce Yaw). If Roll and/or Pitch are non-zero, you can only imply that Yaw is zero (or some other certain value) and calculate Roll and Pitch from (Fx,Fy,Fz) - if you don't make such implication, you can't even determine what Roll and Pitch are (Roll = alpha, Pitch = 0, Yaw = 0 is the same as Roll = 0, Pitch = alpha, Yaw = 90; I may have put the wrong sign to either Pitch or Yaw). I'm not that sure about the case when the body is accelerated, but you surely can't get Yaw in that case, using only accelerometer.