Accelerometer vs Gravity sensor
Asked Answered
O

2

9

Does gravity sensor return right values if device is in motion? I thought that gravity sensor use accelerometer to recognize gravitation direction. Are these two sensors different piece of hardware?

Orgeat answered 28/2, 2014 at 17:55 Comment(0)
A
10

The Gravity sensor is what Android calls a 'software sensor' and calculates its values using more than one hardware sensor.

The software Gravity sensor is only available if the device has a gyroscope. By combining accelerometer data with gyroscope data, the acceleration due to moving the device can be filtered out to leave the pure gravity signal. So yes, it will return the right value under motion.

Thus, the Gravity sensor gives a much better signal for device orientation than just the accelerometer on its own.

Combining sensor values is called sensor fusion and important for high quality measurement values.

The Android Documentation describes the Gravity Sensor.

Unfortunately, many Android devices lack a Gyroscope, and thus, will have no Gravity sensor either. This leaves you with a sub optimal signal from just the accelerometer alone, giving a lower quality user experience compared to Android devices with both sensors, and lower quality experience compared to iOS devices.

You can block installations on incompatible devices by using a Google Play requirement specification as follows:

<uses-feature android:name="android.hardware.sensor.gyroscope" />
Agronomy answered 25/1, 2017 at 22:35 Comment(0)
F
3

Albert Einstein answered this question in 1911

A little reflection will show that the law of the equality of the inertial and gravitational mass is equivalent to the assertion that the acceleration imparted to a body by a gravitational field is independent of the nature of the body. For Newton's equation of motion in a gravitational field, written out in full, it is:

(Inertial mass) \cdot (Acceleration) = (Intensity of the gravitational field) \cdot (Gravitational mass). It is only when there is numerical equality between the inertial and gravitational mass that the acceleration is independent of the nature of the body.

— Albert Einstein

We cannot differentiate the measurement of acceleration from the measurement of gravity since they are equivalent to the observer. Even if the Android had two sensors they would both be measuring the same thing.

Foxed answered 28/2, 2014 at 18:2 Comment(2)
When a device is at rest, the output of the gravity sensor should be identical to that of the accelerometer. ___ From documentation____ So why isn't same when the device is in motion?Orgeat
Provided the accepted answer, not having seen the actual source code, I can only guess that the software gravity sensor attempts to guess the component of the acceleration that is due to Earth's gravity, using Earth's surface as reference frame. In the end, that's the definition of motion in daily life. If the sensor is running over a period of time, you could guess what the direction of gravity is if you detect periods in which the acceleration is constant at 9.8m/s2. Than you could simply always track in which direction this 9.8m/s2 acceleration is probably pointing, relative to the device.Sass

© 2022 - 2024 — McMap. All rights reserved.