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

后端 未结 7 1774
天命终不由人
天命终不由人 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:31

    Differentiating with respect to time a function of time rids you of the constants.

    So by taking the derivative of the accelerometer's signal you'll get the "Jerk", which you can then re-integrate in order to get the non-constant part of the acceleration you're looking for.

    In Layman's terms, take a sample from the accelerometer every 1 second, and subtract it from the previous sample. If the answer is (very close to) zero, you're not accelerating relatively to earth. If the result is non-zero, integrate it (in this case, multiply by one second), you have your acceleration.

    Two things, though : -Look out for noise in the signal, round off your input. -Don't expect hyper-accurate results from on-chip accelerometers. You can use them to detect shaking, changes in orientation, but not really for knowing how many G's you're experiencing while making sharp turns in your car.

提交回复
热议问题