简体   繁体   English

过滤掉来自Android倾斜(加速度计和磁场)传感器的噪声?

[英]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. 因此,我在Android上实现了一个简单的应用程序,该程序使球朝着倾斜手机的方向滚动。 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? 保留旧的rotationMatrix,如果差异不超过某个阈值,则不做任何更改?

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. 在Javascript中,通常将节流(和反跳)用于可能反复触发的事件,例如,调整窗口大小。

http://halley.cc/code/?java/Throttle.java 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. 如果要将球朝着倾斜手机的方向滚动,建议您尝试在x和y方向上使用陀螺仪。 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. 它说明了传感器如何在移动设备中获取数据,以及如何使用传感器融合和过滤技术将错误最小化。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 通过加速度计和磁场传感器检测Android设备的倾斜和晃动 - Detect tilting and shaking of Android device via accelerometer and magnetic field sensors Android手机会影响传感器(加速度计和磁场),而手机会面向用户 - Android camera affects sensors (Accelerometer & Magnetic Field) while phone faces user Android 加速度计和磁传感器如何提供方向信息? - How do the Android accelerometer and magnetic sensors contribute to orientation information? Android:如何同步多个 IMU 传感器(加速度计/陀螺仪/磁性)? - Android: how to synchronise multiple IMU sensors(Accelerometer/Gyroscope/Magnetic)? 从android加速度计获取倾斜角度 - Get tilt angle from the android accelerometer 传感器TYPE_ACCELEROMETER / TYPE_MAGNETIC_FIELD和TYPE_ORIENTATION之间的值不同 - Different values between sensors TYPE_ACCELEROMETER/TYPE_MAGNETIC_FIELD and TYPE_ORIENTATION 传感器TYPE_ACCELEROMETER和TYPE_MAGNETIC_FIELD-它们适用于手机,但不适用于平板电脑 - Sensors TYPE_ACCELEROMETER and TYPE_MAGNETIC_FIELD - They work on phones, but doesn't on tablets 过滤加速度计数据噪音 - Filtering accelerometer data noise 从磁传感器获取电压 - Getting Voltage from Magnetic Sensors 从磁传感器获取信息 - getting info from magnetic sensors
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM