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.
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 ...
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With