最近我参与处理来自不同设备的传感器的数据。这些传感器包括加速度计的,陀螺仪,磁强计等,这一切开始时我想隔离重力和偶然发现了这个链接(在Android android_frameworks_base /服务/ sensorservice/SecondOrderLowPassFilter.cpp代码):关于一般过滤器的文档
/*
* Copyright (C) 2010 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdint.h>
#include <sys/types.h>
#include <math.h>
#include <cutils/log.h>
#include "SecondOrderLowPassFilter.h"
// ---------------------------------------------------------------------------
namespace android {
// ---------------------------------------------------------------------------
SecondOrderLowPassFilter::SecondOrderLowPassFilter(float Q, float fc)
: iQ(1.0f/Q), fc(fc)
{
}
void SecondOrderLowPassFilter::setSamplingPeriod(float dT)
{
K = tanf(float(M_PI) * fc * dT);
iD = 1.0f/(K*K + K*iQ + 1);
a0 = K*K*iD;
a1 = 2.0f * a0;
b1 = 2.0f*(K*K - 1)*iD;
b2 = (K*K - K*iQ + 1)*iD;
}
// ---------------------------------------------------------------------------
BiquadFilter::BiquadFilter(const SecondOrderLowPassFilter& s)
: s(s)
{
}
float BiquadFilter::init(float x)
{
x1 = x2 = x;
y1 = y2 = x;
return x;
}
float BiquadFilter::operator()(float x)
{
float y = (x + x2)*s.a0 + x1*s.a1 - y1*s.b1 - y2*s.b2;
x2 = x1;
y2 = y1;
x1 = x;
y1 = y;
return y;
}
// ---------------------------------------------------------------------------
CascadedBiquadFilter::CascadedBiquadFilter(const SecondOrderLowPassFilter& s)
: mA(s), mB(s)
{
}
float CascadedBiquadFilter::init(float x)
{
mA.init(x);
mB.init(x);
return x;
}
float CascadedBiquadFilter::operator()(float x)
{
return mB(mA(x));
}
// ---------------------------------------------------------------------------
}; // namespace android
虽然该代码确实工作得很好我觉得我需要了解一些关于过滤器哲学的基本知识。例如,也许我需要改变该过滤器中的某些东西。
我开始阅读维基百科(卡尔曼,低通,...),但我仍然觉得我需要在开始修改别人的代码之前更好地理解/理解这个理论。
所以我问你,SO用户,我可以阅读什么,以便有一个比过滤器更普遍的想法?任何链接,资源,文档都会很好。
另外:我有一个工程师学位,但没有完全研究过滤器,除了一些傅里叶变换(DFT)时,研究信号处理。数学不应该是一个大问题。
我在问这个问题,因为我看到有很多有关过滤器的问题。
非常感谢,
尤利安
您可以在这里得到很好的答案,而且在http://dsp.stackexchange.com/ –
@INS:谷歌于codesearch一直关机。你可以给另一个链接吗? – Ashwin
@Ashwin完成。我已将源代码放在问题 – INS