Is a gyroscope included in getOrientation?

I am trying to understand Android sensor control. Is it correct if I wanted to turn on the gyro to get the orientation of the phone, does this automatically happen when I call getOrientation (..) and the phone has a gyro sensor?

So, if the phone has an acceleration sensor and a gyroscope, is there likely to be a better orientation result, unlike when it has only acceleration sensors?

Thanks!

+1
source share
2 answers

The methods included in the Android API for obtaining orientation do not include readings from the gyro sensor. The gyroscope does not provide orientation information, since it only has rotation speed information.

You can take advantage of the gyro sensor readings using this information to better evaluate your orientation:

  • Step 1: initial orientation assessment.
  • Step 2: You received a newer orientation estimate and some information from the gyro sensor.
    • You have information about the increase in time (delta-t) between steps 1 and 2: So, you can integrate the speed of rotation at this time to get an estimate of the rotation between the two states.
    • You also have 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 orientation estimate in step 2.
    • This can be done in a fairly simple way using an additional filter.
+2
source

If you work with Api Level 9 and higher, and your device has a gyroscope, you can use Sensor.TYPE_ROTATION_VECTOR .

He takes care of the "fusion" of the data obtained with the help of an accelerometer, a magnetic sensor and a gyroscope.

+1
source

Source: https://habr.com/ru/post/901031/


All Articles