# 互补滤波器

互补滤波器是一种传感器融合算法，它将同一物理量的两种测量结果融合在一起——这两种测量结果各自在不同的频段上可靠——方法是对其中一个信号做低通滤波、对另一个做高通滤波，使两个滤波器的频率响应在每个频率上相加恰好等于一。在实践中，它最为人熟知的应用是姿态估计：陀螺仪积分得到的角度在短时间内准确，但会随时间漂移；加速度计解算得到的倾角平均而言正确，但逐时刻噪声很大；互补滤波器将二者融合。<sup>[1](https://roboticsprojecthub.com/tutorials/complementary-filter-imu/)</sup>

| 关键事实 | 详情 |
|---|---|
| 核心操作 | 对加速度计信号做低通滤波，对陀螺仪信号做高通滤波，然后相加；两个频率响应互补，因此没有哪个频段被重复计算，也没有哪个频段被遗漏<sup>[1](https://roboticsprojecthub.com/tutorials/complementary-filter-imu/)</sup> |
| 标准更新方程 | 角度 = α ×（上一时刻角度 + 陀螺仪角速率 × Δt）+（1 − α）× 加速度计角度，α 通常取 0.95–0.99<sup>[2](https://cps-cornell.github.io/course/labs/Lab5/Lab5/)</sup> |
| 增益选取 | α = τ/(τ + dt)，其中 τ 是期望的时间常数，dt 是采样周期；α 控制着“信任加速度计”与“信任陀螺仪”之间的交接频率<sup>[3](https://pear.wpi.edu/tutorials/attitudeest/imu.html)</sup> |
| 经典非线性形式 | Mahony 显式互补滤波器（Mahony、Hamel 与 Pflimlin，《IEEE 自动控制汇刊》，2008 年）只需加速度计和陀螺仪输出，可在嵌入式硬件上运行，并能在线估计陀螺仪零偏<sup>[4](https://researchportalplus.anu.edu.au/en/publications/nonlinear-complementary-filters-on-the-special-orthogonal-group/)</sup> |
| 计算开销 | 一种互补滤波方案的性能与 15 状态扩展卡尔曼滤波相近，而计算负载不到后者的 1/3<sup>[5](https://experts.umn.edu/en/publications/attitude-estimation-for-small-low-cost-uavs-a-tutorial-approach/)</sup> |
| 实践中的典型增益 | 一项四旋翼研究采用 0.98/0.02 的陀螺仪/加速度计加权<sup>[6](https://www.telkomnika.uad.ac.id/index.php/TELKOMNIKA/article/view/9020)</sup>；MathWorks Simulink 模块中加速度计默认增益为 0.01<sup>[7](https://www.mathworks.com/help/fusion/ref/complementaryfilter.html)</sup> |
| 主要局限 | 线加速度会污染加速度计的重力参考，正因如此，仅靠传统的线性互补滤波器已被证明不适合无人机姿态估计<sup>[8](https://pmc.ncbi.nlm.nih.gov/articles/PMC3231339/)</sup> |

## 为什么两种传感器互补

加速度计和陀螺仪的失效方式恰好相反。在一秒或更长的时间尺度上取平均，加速度计能正确报告重力的方向，从而给出横滚角和俯仰角，因为重力不会漂移。然而以 10 毫秒为间隔采样时，它主要报告的是飞行器自身的运动：振动和线加速度主导了信号。陀螺仪的表现则恰好相反。在 10 毫秒的尺度上，其角速率积分得到的角度基本是精确的；但过了一分钟，累积的零偏就已经毁掉了角度估计。<sup>[1](https://roboticsprojecthub.com/tutorials/complementary-filter-imu/)</sup> 用姿态航向参考系统文献的话说，陀螺仪往往具有低频漂移，而加速度计和磁力计往往具有高频噪声。<sup>[9](https://ahrs.readthedocs.io/en/stable/filters/complementary.html)</sup>

互补滤波器正是利用了这一分工。加速度计通道经过低通滤波，保留其可靠的长时平均值而抑制振动；陀螺仪通道经过高通滤波，保留其准确的短时响应而丢弃缓慢增长的漂移。这个名称来自一条设计约束：两个滤波器的频率响应在每个频率上相加必须恰好等于一，从而每个频段的信息都恰好被使用一次。<sup>[1](https://roboticsprojecthub.com/tutorials/complementary-filter-imu/)</sup>

## 一维形式

对于横滚角这样的单个倾角，最常见的离散实现是在每个时间步对两个估计做加权融合：<sup>[2](https://cps-cornell.github.io/course/labs/Lab5/Lab5/)</sup>

\[ \theta_{t+1} = \alpha \cdot (\theta_t + \omega_{t+1} \, \Delta t) + (1 - \alpha) \cdot \theta_{\mathrm{acc}} \]

其中 \( \theta_t + \omega_{t+1} \Delta t \) 是将陀螺仪角速率 \( \omega \) 在采样间隔 \( \Delta t \) 上积分得到的预测角度，\( \theta_{\mathrm{acc}} \) 是由加速度计计算出的倾角。系数 \( \alpha \) 设定陀螺仪相对于加速度计的权重；典型取值为 0.95 至 0.99，意味着快速的陀螺仪估计占主导，而加速度计提供一个小的、持续的修正，阻止漂移累积。<sup>[2](https://cps-cornell.github.io/course/labs/Lab5/Lab5/)</sup><sup> • </sup><sup>[1](https://roboticsprojecthub.com/tutorials/complementary-filter-imu/)</sup>

增益可以由期望的时间常数 \( \tau \)（即估计对加速度计参考的响应速度）和采样周期 \( dt = f_s^{-1} \) 推出：<sup>[3](https://pear.wpi.edu/tutorials/attitudeest/imu.html)</sup>

\[ \alpha = \frac{\tau}{\tau + dt} \]

加速度计角度本身由测得的重力矢量经简单三角运算得到，例如横滚角 \( \theta_x = \mathrm{arctan2}(a_y, a_z) \)，俯仰角 \( \theta_y = \mathrm{arctan2}(-a_x, \sqrt{a_y^2 + a_z^2}) \)。偏航角无法仅由加速度计获得，在没有磁力计的情况下设为零。<sup>[9](https://ahrs.readthedocs.io/en/stable/filters/complementary.html)</sup>

增益的含义很直接。当 \( \alpha = 1 \) 时，估计完全来自陀螺仪；当 \( \alpha = 0 \) 时，估计完全来自加速度计和磁力计；中间值则按比例融合二者。<sup>[9](https://ahrs.readthedocs.io/en/stable/filters/complementary.html)</sup> \( \alpha \) 越大，意味着越信任陀螺仪测量；当 \( \alpha \) 趋近于零时，估计主要基于加速度计。<sup>[10](https://robotics-lab-documentation.readthedocs.io/en/latest/texts/lab_Kalman.html)</sup>

## 非线性形式与四元数形式

一维融合可以推广到完整的三维姿态估计，此时姿态的表示必须避免奇异点。[澳大利亚国立大学](https://www.edgepedia.org/zh/australian-national-university)教授 Robert Mahony、Tarek Hamel 与 Jean-Michel Pflimlin 在 2008 年发表于《IEEE 自动控制汇刊》的论文中，将滤波问题表述为直接建立在特殊正交群 SO(3)（即旋转群）上的确定性观测器运动学。<sup>[4](https://researchportalplus.anu.edu.au/en/publications/nonlinear-complementary-filters-on-the-special-orthogonal-group/)</sup> 这项工作产生了直接互补滤波器和无源互补滤波器（二者均可扩展为在线估计陀螺仪零偏），以及显式互补滤波器——后者只需加速度计和陀螺仪输出，适合嵌入式硬件，能在在线估计陀螺仪零偏的同时给出良好的姿态估计。Lyapunov 分析确立了观测器误差的几乎全局稳定性，观测器也在机器人试验台和无线电遥控无人机上得到了验证。<sup>[4](https://researchportalplus.anu.edu.au/en/publications/nonlinear-complementary-filters-on-the-special-orthogonal-group/)</sup>

Mahony 滤波器已成为标准基准。在基于 STM32F107 的硬件平台上，Mahony 互补滤波器的姿态精度与四元数扩展卡尔曼滤波相近，而每个估计步的计算时间约为前者的十分之一；在相近的计算开销下，其平均绝对误差也小于经典线性互补滤波器。<sup>[11](https://www.mdpi.com/2072-666X/12/11/1373)</sup>

## 与卡尔曼滤波的比较

互补滤波器和[卡尔曼滤波](https://www.edgepedia.org/zh/kalman-filter)器用不同的机制解决同一个融合问题。互补滤波器在频域中使用固定权重，而卡尔曼滤波器根据对不确定性的动态估计来调整其加权。<sup>[2](https://cps-cornell.github.io/course/labs/Lab5/Lab5/)</sup> 卡尔曼滤波器在给定噪声模型的情况下最小化估计误差方差，但需要大量计算资源和对系统噪声的精确刻画。<sup>[12](https://www.mdpi.com/2076-3417/15/8/4114)</sup>

实测比较表明，在资源受限的硬件上互补滤波器更占优势。加利福尼亚大学圣克鲁兹分校教授 Gabriel Hugh Elkaim 与[明尼苏达大学](https://www.edgepedia.org/zh/university-of-minnesota)的 Demoz Gebre-Egziabher 为小型低成本无人机开发了一种互补滤波姿态方案，将其构造为比例-积分滤波器，其中比例增益修正当前估计，积分项估计陀螺仪零偏。其性能与 15 状态扩展卡尔曼滤波相近，而计算负载不到后者的 1/3。<sup>[5](https://experts.umn.edu/en/publications/attitude-estimation-for-small-low-cost-uavs-a-tutorial-approach/)</sup> 斯坦福大学的一项课程比较同样测得互补滤波器每次更新约 3 毫秒，而卡尔曼实现为 6 毫秒。<sup>[13](https://web.stanford.edu/class/ee267/Spring2016/poster_cornman_mei.pdf)</sup> 代价是统计最优性：互补滤波器以牺牲最优性换取更快的性能，并且在飞行器机动时性能会下降，因为加速度计的重力参考被污染了。<sup>[14](https://eurognc.ceas.org/archive/EuroGNC2019/pdf/CEAS-GNC-2019-036.pdf)</sup>

## 应用

凡是用低成本惯性测量单元产生稳定姿态估计的场合，都能见到互补滤波器。有文献记载的应用包括：

- **小型无人机与姿态航向参考系统。** 小型低成本无人机的姿态估计通常采用互补滤波器，融合机载加速度计、陀螺仪和磁力计传感。<sup>[15](https://arxiv.org/abs/1602.07733)</sup> 针对基于微机电系统的姿态航向参考系统，已设计出增益调度互补滤波器，对横滚和俯仰融合陀螺仪与加速度计，对航向融合陀螺仪与磁力计。<sup>[8](https://pmc.ncbi.nlm.nih.gov/articles/PMC3231339/)</sup>
- **自动驾驶仪。** PX4 包含一个 Q 姿态估计器，这是一个非常简单的基于四元数的互补滤波器，不需要 GPS、磁力计或气压计，常用于多旋翼竞速机。<sup>[16](https://docs.px4.io/main/en/advanced/switching_state_estimators)</sup> ArduPilot 的 DCM 算法被描述为其 EKF 的一种更简单的互补滤波替代方案；甚至 ArduPilot 的 EKF3 内部也使用互补滤波器，将状态从融合时间点向前传播到当前时刻。<sup>[17](https://ardupilot.org/copter/docs/common-apm-navigation-extended-kalman-filter-overview.html?highlight=gps)</sup><sup> • </sup><sup>[18](https://docs.px4.io/v1.18/en/advanced_config/tuning_the_ecl_ekf)</sup>
- **自平衡机器人与爱好者平台。** 对于自平衡机器人，陀螺仪与加速度计的一行融合被描述为几乎总是正确的答案——在 8 位微控制器上，卡尔曼滤波器带来的精度提升很小，却要付出复杂度和 CPU 时间上的巨大代价。<sup>[1](https://roboticsprojecthub.com/tutorials/complementary-filter-imu/)</sup>
- **行人导航。** 一种基于四元数平均的自适应互补滤波器用于采用足部安装的姿态航向参考系统的行人航位推算，根据步态相位调整角速度、加速度和磁场测量的权重，以低于卡尔曼滤波器的计算成本实现了较低的 RMSE。<sup>[19](https://arxiv.org/abs/2607.05451)</sup>

## 局限

加速度计通道是薄弱环节。由于倾角估计假定加速度计测量的是重力，任何线加速度或振动都会渗入姿态估计；在加速过程中，滤波器必须更多地依赖陀螺仪以限制损害。<sup>[14](https://eurognc.ceas.org/archive/EuroGNC2019/pdf/CEAS-GNC-2019-036.pdf)</sup> 正因如此，仅靠传统的线性互补滤波器已被证明不适合无人机姿态估计，这促使了增益调度和非线性变体的出现。<sup>[8](https://pmc.ncbi.nlm.nih.gov/articles/PMC3231339/)</sup> 航向通道结构相同，但参考量不同：磁力计为偏航提供低频参考，正如重力为横滚和俯仰提供参考一样。<sup>[8](https://pmc.ncbi.nlm.nih.gov/articles/PMC3231339/)</sup>

研究仍在继续扩展这一基本结构。近期工作包括将非线性与线性互补滤波器结合在同一框架中的级联架构<sup>[20](https://arxiv.org/abs/2107.03970)</sup>、在真实在轨卫星数据上验证的自适应广义互补滤波器<sup>[21](https://www.sciencedirect.com/science/article/pii/S0263224125006244)</sup>，以及在传感减少的场景下利用标量测量在 SO(3) 上进行互补滤波<sup>[22](https://arxiv.org/abs/2604.08099)</sup>。

## References

1. [Complementary Filter: Fusing Accelerometer and Gyro Data, Robotics Project Hub](https://roboticsprojecthub.com/tutorials/complementary-filter-imu/)
2. [Lab 5 – Signal Processing, Cyber-Physical Systems course](https://cps-cornell.github.io/course/labs/Lab5/Lab5/)
3. [Attitude Estimation: IMU, PEAR WPI](https://pear.wpi.edu/tutorials/attitudeest/imu.html)
4. [Mahony, Hamel & Pflimlin (2008). Nonlinear complementary filters on the special orthogonal group. IEEE Transactions on Automatic Control 53(5), 1203–1218.](https://researchportalplus.anu.edu.au/en/publications/nonlinear-complementary-filters-on-the-special-orthogonal-group/)
5. [Elkaim & Gebre-Egziabher (2016). Attitude estimation for small, low-cost UAVs: a tutorial approach. CRC Press.](https://experts.umn.edu/en/publications/attitude-estimation-for-small-low-cost-uavs-a-tutorial-approach/)
6. [Noordin et al. Sensor Fusion Algorithm by Complementary Filter for Attitude Estimation of Quadrotor with Low-Cost IMU. TELKOMNIKA.](https://www.telkomnika.uad.ac.id/index.php/TELKOMNIKA/article/view/9020)
7. [Complementary Filter – Simulink reference, MathWorks](https://www.mathworks.com/help/fusion/ref/complementaryfilter.html)
8. [Gain-Scheduled Complementary Filter Design for a MEMS Based Attitude and Heading Reference System, PMC](https://pmc.ncbi.nlm.nih.gov/articles/PMC3231339/)
9. [Complementary Filter, AHRS 0.4.0 documentation](https://ahrs.readthedocs.io/en/stable/filters/complementary.html)
10. [Orientation Estimation, HVL Robotics Førde documentation](https://robotics-lab-documentation.readthedocs.io/en/latest/texts/lab_Kalman.html)
11. [Attitude Estimation Algorithm of Portable Mobile Robot Based on Complementary Filter, Micromachines (MDPI)](https://www.mdpi.com/2072-666X/12/11/1373)
12. [Complementary Filter Optimal Tuning Methodology for Low-Cost AHRS, Applied Sciences (MDPI)](https://www.mdpi.com/2076-3417/15/8/4114)
13. [Comparison of Extended Kalman Filter and Complementary Filter, Stanford EE267](https://web.stanford.edu/class/ee267/Spring2016/poster_cornman_mei.pdf)
14. [A Robust Complementary Filter Approach for Attitude Estimation of UAVs Using AHRS, CEAS EuroGNC 2019](https://eurognc.ceas.org/archive/EuroGNC2019/pdf/CEAS-GNC-2019-036.pdf)
15. [Teague (2016). Comparison of Attitude Estimation Techniques for Low-cost Unmanned Aerial Vehicles. arXiv:1602.07733](https://arxiv.org/abs/1602.07733)
16. [Switching State Estimators, PX4 Guide](https://docs.px4.io/main/en/advanced/switching_state_estimators)
17. [Extended Kalman Filter (EKF), ArduPilot Copter documentation](https://ardupilot.org/copter/docs/common-apm-navigation-extended-kalman-filter-overview.html?highlight=gps)
18. [Using PX4's Navigation Filter (EKF2), PX4 Guide v1.18](https://docs.px4.io/v1.18/en/advanced_config/tuning_the_ecl_ekf)
19. [Quaternion-Averaging-Based Adaptive Complementary Filter for Pedestrian Dead Reckoning. arXiv:2607.05451](https://arxiv.org/abs/2607.05451)
20. [Cascaded Complementary Filter Architecture for Sensor Fusion in Attitude Estimation. arXiv:2107.03970](https://arxiv.org/abs/2107.03970)
21. [Attitude estimation using an adaptive generalized complementary filter, Measurement (Elsevier)](https://www.sciencedirect.com/science/article/pii/S0263224125006244)
22. [Complementary Filtering on SO(3) for Attitude Estimation with Scalar Measurements. arXiv:2604.08099](https://arxiv.org/abs/2604.08099)

---
*Initially written Oct 15, 2026 · Edited: Oct 25, 2026*

Topic: 技术与人造世界 › 工程与制造 › 机器人技术与自动化 › Robot software, AI, and methods › Localization, state estimation, and navigation

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/complementary-filter

English original: https://www.edgepedia.org/complementary-filter
