How to Calibrate Android Accelerometer & Reduce Noise, Eliminate Gravity

前端 未结 3 1062
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-01 23:38

So, I\'ve been struggling with this problem for some time, and haven\'t had any luck tapping the wisdom of the internets and related SO posts on the subject.

I am writin

3条回答
  •  梦谈多话
    2021-02-02 00:12

    To get a correct reading from the accelerometer you need to use the equation speed = SQRT(x*x + y*y + z*z). Using this, when the phone is at rest the speed will be that of gravity - 9.8m/s. So if you subtract that (SensorManager.GRAVITY_EARTH) then when the phone is at rest, you will have a reading of 0 m/s. As for noise, Blrfl might be right about cheap accelerometers, even when my phone is at rest, it continuously flickers a few fractions of a metre per second. You could just set a small threshold e.g 0.4m/s and if the speed doesn't go over that, then it is at rest.

提交回复
热议问题