Filtering out noise from Android tilt (accelerometer and magnetic field) sensors?

為{幸葍}努か 提交于 2019-12-25 00:20:04

问题


So I have implemented a simple app on Android that makes the ball roll in the direction I tilt the phone. However it is impossible to keep the ball still since the sensor values are continously changing even if I think I am holding it still.

So I guess what I want tis filter away small changes? Using some sort of lowpassfilter?

So how would I do that? Keep the old rotationMatrix and not do any changes if the difference is not bigger than some threshold?


回答1:


A low pass filter might make the movement look incorrect, as it won't move at all for small increments. You might be better throttling your update function, so that it only updates once every certain number of milliseconds.

Throttling (and debouncing) are commonly used in Javascript for events which may fire repeatedly, for instance window resizing.

http://halley.cc/code/?java/Throttle.java




回答2:


If you want to make the ball roll in the direction you tilt the phone I suggest trying using the gyroscope in x and y directions. However, a combination of accelerometer and gyroscope can give you better results.

This is a good video to understand how the sensors work. It explains how the sensors acquire the data in mobile devices and how to minimize the error using sensorfusion and filtering techniques.



来源:https://stackoverflow.com/questions/19335912/filtering-out-noise-from-android-tilt-accelerometer-and-magnetic-field-sensors

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!