# agilex-piper motion_status立即返回0导致动作等待失效

> 原文链接：https://robotics.hellobike.com/pitfalls/2026-08-06-pyagxarm-62
> 频道：pitfalls | 更新日期：2026-08-06 | 标签：auto, github-issue, pyagxarm
> 核心摘要：SDK状态同步延迟致motion_status误判，通过在轮询前增加0.5s延时绕过缓存读取问题。

# agilex-piper motion_status立即返回0导致动作等待失效

::: v-pre
> 本文由 AI 根据公开内容整理，可能有误，请以原文为准：[[Bug] Motion Status Does Not Wait for Motion to Finish](https://github.com/agilexrobotics/pyAgxArm/issues/62)（GitHub agilexrobotics/pyagxarm #62）

**状态**：有绕过办法

## 问题

使用 `pyagxarm` SDK 时，发送运动指令后立即调用 `robot.get_arm_status()` 检查 `motion_status == 0` 会因状态同步延迟读到旧缓存值，导致等待逻辑瞬间通过而无法阻塞至动作完成。即使固件为 S-V1.8-9 版本仍存在此现象，且命令执行失败时也会错误返回 0。

## 环境

机型 agilex-piper，固件 S-V1.8-9，硬件 H-V1.2-1，节点 ARM_MC，SDK pyagxarm

## 解决办法

1. 在发送运动指令后、开始轮询 `motion_status` 之前，强制添加 `time.sleep(0.5)` 以避开 SDK 状态更新延迟窗口
2. 封装等待函数，在延时结束后再以 0.1s 间隔循环调用 `robot.get_arm_status()` 并判断 `status.msg.motion_status == 0`
3. 设置超时机制（如 5s），防止因状态异常或执行失败导致死锁
4. 注意当前 workaround 仅解决时序问题，若指令本身执行失败，`motion_status` 仍可能错误返回 0，需额外排查运动失败原因

讨论原作者：@CooperWang0912 等，版权归原作者所有。
:::

## 原始参考来源 (Sources)

- [GitHub agilexrobotics/pyagxarm #62：[Bug] Motion Status Does Not Wait for Motion to Finish](https://github.com/agilexrobotics/pyAgxArm/issues/62)