Gyroscope included in getOrientation?

一世执手 提交于 2019-12-01 13:39:20

The methods included in the Android APIs to get the orientation does not include readings from the gyroscope sensor. Gyroscope does not provide information about orientation, since it only has information about rotation speed.

You can benefit from gyroscope sensor readings using such information to get a better estimation of the orientation:

  • Step 1: You have an initial estimation of the orientation.
  • Step 2: You have a newer estimation of the orientation and some information coming from the gyroscope sensor.
    • You have information about the time increase (delta-t) between step 1 and step 2: So, you can integrate the rotational speed during this time to get an estimation of the rotation between the two states.
    • You have also a new orientation reading in state 2.
    • You can integrate these two sources of information ([orientation @step=1 + rotation] and [orientation @step=2]) to get a refined estimation of orientation at step 2.
    • This can be done in a rather simple way using the complementary filter

If you are working with Api Level 9 and above, and your device has a gyroscope, you can benefit from Sensor.TYPE_ROTATION_VECTOR.

It takes care of the "fusion" of data retrieved from accelerometer, magnetic sensor and gyroscope.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!