Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between "gravity" and "acceleration" sensors in Android?

Tags:

What is the difference between gravity and acceleration sensors in Android? From my point of view the physical value is the same in both cases.

Which one measures the force acting on unit mass inside the device?

ADDITION

The question is: what physical quantity is measured by these sensors? According to equivalence principle the acceleration and gravity are indistinguishable and the only way to measure both is by usual (but 3d) spring balance.

like image 877
Suzan Cioc Avatar asked May 04 '12 09:05

Suzan Cioc


People also ask

Is gravity sensor and accelerometer same?

Even if the Android had two sensors they would both be measuring the same thing. When a device is at rest, the output of the gravity sensor should be identical to that of the accelerometer.

What is a gravity sensor in Android?

Use the gravity sensor The gravity sensor provides a three dimensional vector indicating the direction and magnitude of gravity. Typically, this sensor is used to determine the device's relative orientation in space. The following code shows you how to get an instance of the default gravity sensor: Kotlin Java.

What is accelerometer sensor Android?

The accelerometer is an in-built comment of a smartphone to measure its acceleration. It tracks the different motion like shaking, tilting, swinging, and rotating and accordingly change the orientation of your app.


1 Answers

Acceleration sensor gives you back the sum of all forces applied to your device, while Gravity sensor returns only the influence of gravity. If you want to exclude the gravity from acceleration, you may use a high-pass filter or just subtract the gravity sensor values from acceleration sensor values -- not sure which method gives better precision.

Another method could be using Sensor.TYPE_LINEAR_ACCELERATION, which gives exactly (acceleration - gravity), however you should check if it's available on the device. I've found a few devices, which have ACCELERATION sensor working, but no response from GRAVITY or LINEAR_ACCELERATION sensors.

like image 76
lenik Avatar answered Oct 10 '22 05:10

lenik