title: Determining heading in Inertial Navigation Systems
body: <p>I have a question regarding inertial navigation with a mobile device. 
  I am using an android tablet for development but I think the question is related to 
  all types (even with better sensors) of hardware.</p>
  
  <p>The most basic question when developing an inertial system is how to determine the 
  direction of the carrier's movement. 
  Even if we assume that the magnetometer readings are 100% accurate (which they are obviously not!) There is still the question of the device orientation relative to the user.</p>
  
  <p>Simple example - if the user is walking north, but holds the device with the device's Y axis points north-east, (a link to a picture of the different axis: <a href="http://developer.android.com/reference/android/hardware/SensorEvent.html" rel="nofollow">http://developer.android.com/reference/android/hardware/SensorEvent.html</a>) 
  Then the magnetometer will point towards north-east.
  How can we tell which way the user is actually heading?
  (The same will be true if we use both magnetometer and Gyro for determining heading)</p>
  
  <p>A possible solution will be to use the Accelerometer's Y-axis and X-axis readings.
  Something in the direction of using arctan(a-Y/a-X)
  (for example -  if the user holds the device perfectly straight, then the X-Axis will show nothing...)
  But since the Accelerometer's readings are not stable, it is not so easy...</p>
  
  <p>Does anyone know of an algorithm that actually works? I am sure this is a well known problem, but I can't seem to find references to solutions...</p>
  
  <p>Thanks in advance!</p>
  
  <p>Ariel</p>