title: How to detect an absolute rotation of an android device
body: <p>I'm looking to implement a robot that is navigating indoor, using a software running on an android device. One mandatory feature is to know the robot orientation in "real time".</p>
  
  <p>I have one major constraint : the android device <em>should</em> be placed with a screen on the gravity axe (that means : vertical, like for taking pictures with the camera on the device)</p>
  
  <p>This prevents me from using azimut which is the most common measure to get a reference angle. It makes no sense to use :</p>
  
  <pre><code>SensorManager.getRotationMatrixFromVector(mRotationMatrixFromVector, event.values);
  </code></pre>
  
  <p>then </p>
  
  <pre><code>SensorManager.getOrientation(mRotationMatrix, orientation);
  </code></pre>
  
  <p>since <strong>orientation[0]</strong> supposed to provide azimut is inconsistent.</p>
  
  <p>I was searching for longtime now, but I didn't find any acceptable solution over here.</p>
  
  <p>An "acceptable solution" is to have a system response within 100ms and with a precision close to 5°. The reference is not necessarily the magnetic North, but it must be stable over the time. It can be a starting position (but there are some drift issues...)</p>
  
  <p>Are there any sensors of other type than <strong>TYPE_ROTATION_VECTOR</strong> more situable for this use ? I was trying with <strong>TYPE_GYROSCOPE</strong> but with poor results...</p>
  
  <p>My android device is the Google Tango tablet.</p>
  
  <p>Thanks for any help</p>