Search code examples
androidaccelerometer

Accelerometer's equations


I have been going over Accelerometer's tutorial and some aspects still confusing to me:

  • values[0]: Acceleration minus Gx on the x-axis
  • values[1]: Acceleration minus Gy on the y-axis
  • values[2]: Acceleration minus Gz on the z-axis

The question is: when the device lies flat on a table in its default orientation
it outputs +9,81 instead of -9.81.

If the device lies flat on table Z-axis points down - so the Gz is 9,81 therefore values[2] shall be ( 0 - Gz) = (0 - 9,81) = -9,81.


The question is why is that ?
With X and Y axes there is no such confusion.


Solution

  • The simple (i.e. not rigorous and will have real physicists turning in their graves) is that the usual convention is that if the Z acceleration is negative the device is accelerating downwards i.e. in this case towards the centre of the earth.

    Since it is staying still in a gravitational field it 'feels like' it is accelerating upwards (i.e. positive acceleration) just to stay in place.

    (this is all explained pretty clearly in the SDK docs: Using the Accelerometer