简体   繁体   中英

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

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?

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM