# XY路径点无法转换为双轮电机输入

> 原文链接：https://robotics.hellobike.com/pitfalls/2014-01-10-robotics-se-2279
> 频道：pitfalls | 更新日期：2014-01-10 | 标签：auto, stackexchange, wheeled-robot, wifi, two-wheeled
> 核心摘要：将屏幕路径点依次转为位移、转角和距离，再生成左右轮电压与持续时间序列。

# XY路径点无法转换为双轮电机输入

::: v-pre
> 本文由 AI 根据公开内容整理，可能有误，请以原文为准：[2D path following robot, converting XY axis path to input on wheels](https://robotics.stackexchange.com/questions/2279/2d-path-following-robot-converting-xy-axis-path-to-input-on-wheels)（Robotics Stack Exchange #2279）

**状态**：已解决

## 问题

用户在安卓端绘制路径后得到从`(0,0)`开始的XY点列，但不知道如何转换为两侧电机的输入信号，使三轮机器人通过WiFi按约60Hz跟随路径。

## 环境

简单三轮机器人：2个驱动电机、1个平衡轮；安卓程序；WiFi控制；输入范围`-255`到`255`；无传感器反馈。

## 解决办法

1. 将连续XY点用减法转换为`(Δx, Δy)`。
2. 用勾股定理得到距离`d`，用`atan2`得到角度`θ`，并记录上一角度以计算`Δθ`。
3. 对每个`(Δθ, d)`生成两段动作：先转向，再直行。
4. 已知轮距`w`时，用`Δθ = (Δd_left - Δd_right) / w`估算左右轮位移差。
5. 根据机器人实际电压与运行时间对轮子位移的关系，选取`V_left`、`V_right`和`Δt`；直行时两轮使用相同电压。

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

## 原始参考来源 (Sources)

- [Robotics Stack Exchange #2279：2D path following robot, converting XY axis path to input on wheels](https://robotics.stackexchange.com/questions/2279/2d-path-following-robot-converting-xy-axis-path-to-input-on-wheels)