# IMU 双重积分位移结果严重漂移怎么办

> 原文链接：https://robotics.hellobike.com/pitfalls/2023-09-22-robotics-se-16757
> 频道：pitfalls | 更新日期：2023-09-22 | 标签：auto, stackexchange, arduino, imu, uav, ardupilot
> 核心摘要：IMU 直接积分会因传感器偏置产生漂移，需先估计姿态并融合重力、磁力计或 GPS 修正。

# IMU 双重积分位移结果严重漂移怎么办

::: v-pre
> 本文由 AI 根据公开内容整理，可能有误，请以原文为准：[what is the algorithm to get position (Linear displacement and linear velocity ) using IMU (Like MPU6050)?](https://robotics.stackexchange.com/questions/16757/what-is-the-algorithm-to-get-position-linear-displacement-and-linear-velocity)（Robotics Stack Exchange #16757）

**状态**：已解决

## 问题

无人机项目中用 IMU 做线性位移估计，采样时间 0.1s，实际移动 1 米时计算结果有时为 768cm、2 米甚至 100 米。

## 环境

无人机项目；IMU 类似 MPU6050；参考 Ardupilot、Kalman filter；采样时间 0.1s。

## 解决办法

1. 将 IMU 放在已知初始位置和姿态，读取加速度计与陀螺仪。
2. 对陀螺仪数值积分，如 `angle += gyroReading*deltaTime`，得到当前姿态。
3. 用当前姿态构造旋转矩阵，将加速度从 IMU 机体系转换到世界系。
4. 对世界系加速度积分得速度，再对速度积分得位置，如 `position += speed*deltaTime`。
5. 由于传感器偏置会造成速度、位置、姿态漂移，可用重力向量修正 x/y 姿态，用磁力计修正 z 姿态，用 GPS 修正位置漂移；也可使用 Madgwick filter。

原问题作者：Robokishan；采纳答案作者：Chuck。原内容依 CC BY-SA 4.0 授权，本页摘要同样依 CC BY-SA 4.0 授权。
:::

## 原始参考来源 (Sources)

- [Robotics Stack Exchange #16757：what is the algorithm to get position (Linear displacement and linear velocity ) using IMU (Like MPU6050)?](https://robotics.stackexchange.com/questions/16757/what-is-the-algorithm-to-get-position-linear-displacement-and-linear-velocity)