Android 低通滤波器和高通滤波器 [英] Android Low pass filter and High pass filter

查看:88
本文介绍了Android 低通滤波器和高通滤波器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常基本的问题.Android加速度计的低通滤波器和高通滤波器是什么?

I have a very basic question. What is Low Pass filter and High Pass filter in case of Android Accelerometer?

当我看到加速度计传感器的输出时,我看到如果我不使用任何过滤器,(案例:我的手机在桌子上闲置)我得到了 z 轴 +ve 值.现在,如果我考虑使用基本物理学,它会为我提供小 g 的精确值(9.8approx),即重力加速度.

When I see the output from the Accelerometer Sensor, I see If I don't use any filter, (Case : I kept my cell phone idle on table) I get z Axis +ve value. Now If I think using basic physics, it gives me exact value(9.8approx) for small g i.e Acceleration due to gravity.

为了获得线性加速度,如果我向手机添加任何力,它会改变加速度计的值,但我应用的是 g + a.那么要获得 a 为什么我不能直接从我从加速度计获得的值中减去?

To get the linear acceleration, If I add any force to phone it will change the Accelerometer value, but it will be g + a that I applied. So to get a why can't I just subtract directly from the value I am getting from Accelerometer?

有什么用?
我理解的低通基本定义:允许低值,高通:允许高值.

What is the use?
A basic definition I understand for low pass: To allow low value, High Pass : To allow high value.

推荐答案

如果您查看文档,您将看到 SensorEvent 返回一个表示所有力向量的数组.http://developer.android.com/reference/android/hardware/SensorEvent.html#values这是加速度的分量分解到每个轴的方式:

If you look at the documentation you will see that SensorEvent returns an array which represents the vector of all the forces. http://developer.android.com/reference/android/hardware/SensorEvent.html#values This is how the components of the acceleration break down into each axis:

 values[0] //acceleration on x axis
 values[1] //acceleration on y axis
 values[2] //acceleration on z axis

您需要找到重力作用的方向,然后将其分解为各个组成部分.重力的大小将始终为 9.8,但方向以及它如何分解为组成部分会发生变化.假设我们可以获得重力的值并将该向量存储在一个数组中,如gravity[3]:

You need to find which direction gravity is operating in then decompose that into its component parts. The magnitude of the gravity force will always be 9.8 but the direction, and hence how it breaks down into the component parts, will change. Assuming that we could get the value of gravity and store that vector in an array like gravity[3]:

 gravity[0] //gravity x axis
 gravity[1] //gravity y axis
 gravity[2] //gravity z axis

手机上的总加速度TT = g + a.为了得到 a 我们需要 a = T - g:

The total acceleration, T, on the phone is T = g + a. To get just a we would need a = T - g:

 linear_acceleration[0] = event.values[0] - gravity[0];
 linear_acceleration[1] = event.values[1] - gravity[1];
 linear_acceleration[2] = event.values[2] - gravity[2];

请注意这是如何逐个元素计算所有内容的,因为它是向量运算.

Notice how this calculates everything element by element because it's a vector operation.

棘手的部分是找到重力,因为手机中只有一个加速度计可以同时测量重力和其他力.我们想从一个传感器中找到 2 种不同的力.如果我们只能在一个孤立的时间点观察力,我们将无法提取信息.然而,我们确实会在一定时间范围内获取样本,并且通过观察力如何随时间变化,我们可以提取信息.

The tricky part is finding gravity because there is only one accelerometer in the phone which measures both the gravity AND the other forces at the same time. We have 2 different forces that we want to find from the one sensor. If we could only look at the forces at an isolated point in time we wouldn't be able to extract the information. However we do get samples over a range of times and by looking at how the forces change over time we can extract the information.

这意味着我们需要根据这些力的变化速度筛选出来自该来源的结果.重力加速度的大小不会快速变化,因为它根本没有变化.重力是一种恒定的力.然而,其他力量会随着时间的推移而改变.如果我们使用高通滤波器过滤掉缓慢变化的力,如重力,那么剩下的力就是快速变化的力,比如施加到手机上的力.这就是使用高通滤波器的原因.

This means we need to filter out the results from that one source based on how quickly those forces change. The magnitude of acceleration due to gravity does not change quickly because it doesn't change at all. Gravity is a constant force. However other forces will change over time. If we filter out the slow changing forces like gravity by using a high-pass filter then the remaining forces are the fast changing ones like the forces being applied to the phone. This is why the high-pass filter is used.

这篇关于Android 低通滤波器和高通滤波器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆