Android的加速度过滤?加速度、Android

2023-09-04 09:49:03 作者:谈情不如逗狗

我看到很多例子有关筛选Accelermeter的价值观,以抵消重力(高通滤波器)。

I saw many examples about filtering Accelermeter's values, to cancel out the gravity (High-pass filter).

但其中大多数是一阶的,这被认为是简单的,但延迟非常明显,不是最好的(虽然我什么都不知道的过滤器或DSP)。

But most of them were 1st order one, which is said to be simple, but laggy and not the best one (though I know nothing about the filters or DSP).

有人在这里说,存在于DSP用于感应运动更好的解决方案。很遗憾,我不能想象会是什么感觉,因为我完全外行到外地。

Somebody in here said that there exists the better solution used in DSP to sense the motion. Regretfully I can't even imagine what it would be, as I am completely outsider to the field.

我希望有人能告诉的过滤器,可以在与传感器处理至少使用类型。当然,即使简要介绍了具体的算法将非常高兴:)

I hope somebody could tell at least the type of filters that can be used when dealing with the sensor. Of course, even brief introduction to the specific algorithm will be very pleased :)

在此先感谢。

推荐答案

您想使用Android的 SensorListener()类。例如,施瓦茨无护套是托管在谷歌code,看起来像它应该是非常有用的(书面克拉克雪夫)开源的Andr​​oid项目。

You want to utilize Android's SensorListener() Class. For example, "The Schwartz Unsheathed" is open source Android project hosted on Google Code that looks like it should be quite useful (written by Clark Scheff).

您可以通过SVN HTTP检查出其来源/$c$c.google.com/p/the-schwartz-unsheathed/source/checkout 或者只是浏览它在网络上。源被分成一个活动( TheSchwartz.java )和视图( GraphView.java )。 GraphView.java包含 SensorListener()广告 onSensorChanged()类这哪里是加速处理发生。行284和285:

You can check out its source via SVN http://code.google.com/p/the-schwartz-unsheathed/source/checkout or just browse it on the web. The source is broken up into an Activity (TheSchwartz.java) and a View (GraphView.java). GraphView.java contains SensorListener() ad onSensorChanged() classes which is where the accelerometer processing occurs. Lines 284 and 285:

magnitude = (float)Math.sqrt(values[0]*values[0]+values[1]*values[1]+values[2]*values[2]);
magnitude = Math.abs(magnitude - SensorManager.GRAVITY_EARTH);

幅度值的评估没有动静,一打或Android手机的摇摆。我知道这不筛选数据中的信号处理感觉,但它确实显示出了一种传感器的数据进行分类。希望它能帮助。

The value of magnitude is evaluated for no movement, a "hit" or a "swing" of the Android phone. I realize this does not filter the data in a signal processing sense, but it does show a way to classify sensor data. Hope it helps.