title: Doing sensor fusion in Android NDK
body: <p>So, the Android JAVA SDK has provisions to do sensor fusion.
  It can combine gyro and accelerometer readings to generate a reliable gravity vector.
  This is exposed in the API with the sensor type <a href="http://developer.android.com/reference/android/hardware/Sensor.html#TYPE_GRAVITY" rel="nofollow">TYPE_GRAVITY</a>.</p>
  
  <p>Now, the NDK has sensor support as well, for instance, here is an example NDK app that reads the accelerometer at 60Hz: <a href="http://developer.android.com/reference/android/app/NativeActivity.html" rel="nofollow">NativeActivity sample source</a></p>
  
  <p>However, judging from the <a href="https://android.googlesource.com/platform/frameworks/native/+/master/include/gui/Sensor.h" rel="nofollow">sensor.h sourcecode</a>, the NDK only lets me generate the following sensor types:</p>
  
  <ul>
  <li>Accelerometer</li>
  <li>Magnetic field</li>
  <li>Gyroscope</li>
  <li>Light</li>
  <li>Proximity</li>
  </ul>
  
  <p>So the sample code uses ASENSOR_TYPE_ACCELEROMETER. Sadly, there is no ASENSOR_TYPE_GRAVITY. Is this simply a case of NDK only doing a barebones subset of the SDK API?</p>
  
  <p>How can I do sensor fusion on Android NDK? I would like to avoid bringing in the values from Java, as I have read warnings on heavy CPU use when doing high frequency readings in Java.</p>
  
  <p>Thank you.</p>