# 差速机器人增量编码器如何更新位姿

> 原文链接：https://robotics.hellobike.com/pitfalls/2014-07-23-robotics-se-1653
> 频道：pitfalls | 更新日期：2014-07-23 | 标签：auto, stackexchange, mobile-robot, kinematics, motion, two-wheeled
> 核心摘要：不要假设轮子直线运动，可按每个时间步的圆弧运动计算差速机器人新位姿。

# 差速机器人增量编码器如何更新位姿

::: v-pre
> 本文由 AI 根据公开内容整理，可能有误，请以原文为准：[Calculate position of differential drive robot](https://robotics.stackexchange.com/questions/1653/calculate-position-of-differential-drive-robot)（Robotics Stack Exchange #1653）

**状态**：已解决

## 问题

提问者用左右轮增量距离计算差速机器人位置时，不确定更新 `x`、`y` 应使用旧 `theta` 还是新 `theta`，以及几何中心不在轮间中心时如何同步更新位置和朝向。

## 环境

Linux / ROS 机器人软件与控制通用开发环境

## 解决办法

1. 不用左右轮直线近似；每个时间步把机器人从点 A 到点 B 视为沿圆弧运动。
2. 若 `fabs(leftDelta - rightDelta) < 1.0e-6`，按直行处理：`new_x = x + leftDelta * cos(heading)`，`new_y = y + rightDelta * sin(heading)`，`new_heading = heading`。
3. 否则计算 `R = unitsAxisWidth * (leftDelta + rightDelta) / (2 * (rightDelta - leftDelta))`，`wd = (rightDelta - leftDelta) / unitsAxisWidth`。
4. 更新为 `new_x = x + R * sin(wd + heading) - R * sin(heading)`，`new_y = y - R * cos(wd + heading) + R * cos(heading)…

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

## 原始参考来源 (Sources)

- [Robotics Stack Exchange #1653：Calculate position of differential drive robot](https://robotics.stackexchange.com/questions/1653/calculate-position-of-differential-drive-robot)