Calibrating Android Accelerometer?

TL; DR

How is it that the accelerometer values ​​obtained from Sensor.TYPE_ACCELEROMETER

are slightly biased? I don't mean by gravity, but with some slight error that varies from axis to axis and from phone to phone.

Can the accelerometer be calibrated? Or is there a standard way to compensate for these errors?

I am developing an application that requires as accurate measurements of acceleration as possible (mainly vertical acceleration, i.e. in the same direction as gravity).

I have done a lot of testing and it turns out that the original values ​​I get from Sensor.TYPE_ACCELEROMETER

are off. If I let the phone rest on a perfectly horizontal surface with the screen facing up, the accelerometer displays a Z-value of 9.0, where it should be about 9.81. Likewise, if I put the phone in portrait or landscape mode, the X- and Y-accelerometer reads around 9.6. instead of 9.81.

This of course affects my vertical acceleration as I use SensorManager.getRotationMatrixFromVector()

to calculate the vertical acceleration, which results in a vertical acceleration that is turned off by a different amount depending on the rotation of the device.

Now, before someone jumps a gun and remembers what I should try to use Sensor.TYPE_LINEAR_ACCELERATION

instead, I should point out that I am doing this too, in parallel with TYPE_ACCELERATION

. Then, using a gravity sensor, calculate the vertical acceleration ( as described in this answer ). The funny thing is that I get EXACTLY the same result as the method that uses the raw accelerometer SensorManager.getRotationMatrixFromVector()

and matrix multiplication (and finally the subtraction of gravity).

The only way I can get nearly flat vertical acceleration for the landline at any rotation is to get the original accelerometer values, add an offset (from earlier observations, i.e. X+0.21

, Y+0.21

and Z+0.81

), and then execute the rotation matrix material to get world accelerations of the coordinate system. Please note that since this is not just a calculated vertical acceleration that is wrong - these are actually raw values ​​from Sensor.TYPE_ACCELEROMETER

which I think other sources of error exclude, such as a gyroscope sensor, etc.

I tested this on two different phones (Samsung Galaxy S5 and Sony Xperia Z3 compact) and both have these deviations from the accelerometer value, but certainly not the same values ​​on both phones.

Why are the values Sensor.TYPE_ACCELEROMETER

disabled, and is there a better way to "calibrate" the accelerometer than just watching how much they deviate from gravity and add the difference to the values ​​before using them?

+3


source to share





All Articles