# Lerobot写入Goal_Position越界致STS3215电机异常运动与扭矩自启

> 原文链接：https://robotics.hellobike.com/pitfalls/2026-11-12-lerobot-3585
> 频道：pitfalls | 更新日期：2026-11-12 | 标签：auto, github-issue, lerobot
> 核心摘要：Lerobot未校验Goal_Position导致STS3215固件钳位并自启扭矩。临时解法为重置电机限位至0-4095并在_unnormalize中增加角度钳位。

# Lerobot写入Goal_Position越界致STS3215电机异常运动与扭矩自启

::: v-pre
> 本文由 AI 根据公开内容整理，可能有误，请以原文为准：[Lerobot allows writing goal positions outside of min / max](https://github.com/huggingface/lerobot/issues/3585)（GitHub huggingface/lerobot #3585）

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

## 问题

Lerobot的MotorsBus.write未校验Goal_Position是否在标定范围内。当写入值超出[Min, Max]时，Feetech STS3215固件内部将其钳位至限位边缘作为PID目标，并强制开启Torque_Enable，导致电机向非预期位置运动且无视主机disable_torque指令。部分SO-101电机即使Present_Position在范围内也会因标定限位错误而撞硬限位过载。

## 环境

Lerobot latest, Raspberry Pi, Ubuntu; SO-101 follower; Feetech STS3215舵机

## 解决办法

1. 将故障电机的Min_Position_Limit设为0、Max_Position_Limit设为4095，保留校准homing offset以恢复正确运动。
2. 修改motors_bus.py中_unnormalize函数的DEGREES分支，对position模式电机将输出值钳位至[range_min, range_max]，防止开放限位后失去软件保护。
3. 在set_operating_mode成功后缓存电机模式，仅对position模式电机执行上述钳位逻辑，避免影响Dynamixel extended_position等其他模式。
4. 本地patch write_calibration函数，确保写入限位时始终使用0和4095作为安全兜底值。

讨论原作者：@0o8o0-blip 等，版权归原作者所有。
:::

## 原始参考来源 (Sources)

- [GitHub huggingface/lerobot #3585：Lerobot allows writing goal positions outside of min / max](https://github.com/huggingface/lerobot/issues/3585)