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

后端 未结 7 1717
天命终不由人
天命终不由人 2020-12-29 08:16

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

I am using SensorEventListener with onSensorChanged() method for getting Sensor.TY

7条回答
  •  温柔的废话
    2020-12-29 08:37

    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.

提交回复
热议问题