Saturday, 13 October 2018

Sensor values of TYPE_ROTATION_VECTOR aren't the same of different devices

I'm using sensor data of type ROTATION_VECTOR in my app.

Using my Nexus 5 I can get azimuth from orientation[0] and can get the phones heading in the range shown in the picture below (it's very accurate).

Since I've tried my app on different devices, I found out that the sensor values differs from my Nexus 5 test device. On my Samsung Galaxy Nexus and on a Samsung Galaxy S3 Mini the azimuth is influenced by tilting the devices as shown in the picture.

Portrait Only - No Tilting to side

TYPE_ROTATION_VECTOR is using sensor fusion, that's why I checked the single sensor values on different devices with sensor test apps. On Nexus 5 the orientation values for z-axis are staying roughly the same when tilting the device, on Samsung Galaxy Nexus the value for z changed while tilting (about 90° from standing upright to lying). I fear that the sensor fusion is using these values and that's why my azimuth is different on different devices.

Does anyone experience a similar scenario and even more important: does anybody has a workaround or a different way to receive the azimuth?

Just to make sure, I looking for the direction, in which the back camera is pointing...

Here is my code:

final float[] mRotationMatrix = new float[9];
final float[] mRotationMatrixFromVector = new float[9];
final float[] orientation = new float[3];

...

SensorManager.getRotationMatrixFromVector(mRotationMatrixFromVector,
                event.values);

// enables usable range like in picture
SensorManager.remapCoordinateSystem(mRotationMatrixFromVector,
                        SensorManager.AXIS_X, SensorManager.AXIS_Z,
                        mRotationMatrix);

SensorManager.getOrientation(mRotationMatrix, orientation);



from Sensor values of TYPE_ROTATION_VECTOR aren't the same of different devices

No comments:

Post a Comment