Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove Gravity factor from Accelerometer readings in Android 3-axis accelerometer

Can anyone help on removing the g factor from accelerometer readings?

I am using SensorEventListener with onSensorChanged() method for getting Sensor.TYPE_ACCELEROMETER data. I need only pure acceleration values in all directions. So at any state if the device is stable (or in constant speed), it should give (0.0,0.0,0.0) roughly.

Currently, depending on its pitch and roll, it gives me variable output depending on the g forces acting on each axis.

I hope there is some formula to remove this, as I also get orientation values (pitch and roll) from Sensor.TYPE_ORIENTATION listener. I have used some but it didn't work.

like image 758
Pritam Avatar asked Jul 31 '10 07:07

Pritam


People also ask

How does gravity affect accelerometer?

The Accelerometer sensor is an inertial-frame sensor , this means that when the device is in free fall, the acceleration is 0 m/s2 in the falling direction, and when a device is laying flat on a table, the acceleration in upwards direction will be equal to the Earth gravity, i.e. g ≡ 9.8 m/s2 as it is measuring the ...

Why does accelerometer measure gravity?

Technically, an accelerometer measures proper acceleration, which is not the same as coordinate acceleration. This means that the accelerometer can be used to detect the direction of gravity.

How does an accelerometer measure 3 axes?

Triaxial Accelerometer Triaxial accelerometers measure the vibration in three axes X, Y and Z. They have three crystals positioned so that each one reacts to vibration in a different axis. The output has three signals, each representing the vibration for one of the three axes.

What is g in accelerometer?

M/s2 is the international (SI*) unit for acceleration. g is also used as a unit for acceleration, relative to standard gravity (1g = 9.80665m/s2). Other units include Gal (CGS) used to measure seismic acceleration.


1 Answers

You can use a low-pass filter.

Do this for each of your sensor values:

g = 0.9 * g + 0.1 * v

Where v is your current sensor value and g is a global variable initially set to zero. Mind that you'll need as many g variables as you have axes.

With v = v - g you can eliminate the gravity factor from your sensor value.

like image 154
Matthias Braun Avatar answered Sep 30 '22 05:09

Matthias Braun