TYPE_GAME_ROTATION_VECTOR sensor initial value

42 views Asked by At

I have a screen on my app that simulate the rotation of device's angle. Each time I enter this screen, I register to listen the TYPE_GAME_ROTATION_VECTOR sensor and receive the value from it and calculate the euler angles. But I see that no matter where the device are, the yaw angle that I calculate from this sensor's initial value is the same (on my device, it's always -11 and other is -90). So what cause this problem and how to fix it?

Here is my calculation's code:

private fun calculateAngle(eventValues: FloatArray) {
        SensorManager.getRotationMatrixFromVector(rotationMatrix, eventValues)
        SensorManager.remapCoordinateSystem(rotationMatrix, SensorManager.AXIS_X,    SensorManager.AXIS_Y, outR)
            SensorManager.getOrientation(outR, orientationAngles)
        _yaw = Math.toDegrees(orientationAngles[0].toDouble()).toFloat()
0

There are 0 answers