feat(piper): require calibration by default with opt-out mode

- set piper calibration_mode default to required and keep off as explicit opt-out

- remove auto pairing policy and simplify runtime calibration gating

- update README and add test for uncalibrated control when calibration_mode=off
这个提交包含在:
Elvin
2026-03-05 21:49:39 +08:00
父节点 7a9aeb3850
当前提交 294a370657
共有 7 个文件被更改,包括 85 次插入 和 10 次删除

查看文件

@ -17,6 +17,7 @@
from dataclasses import dataclass, field
from lerobot.cameras import CameraConfig
from lerobot.utils.piper_sdk import PIPER_CALIBRATION_MODES
from ..config import RobotConfig
@ -49,6 +50,10 @@ class PiperFollowerConfigBase:
# Calibration precision:
# homing_offset/range_min/range_max are stored as "degree * calibration_scale".
calibration_scale: int = 1000
# Calibration policy:
# - required: always require calibration
# - off: never require calibration
calibration_mode: str = "required"
# Gripper forwarding behavior
sync_gripper: bool = True
@ -75,6 +80,8 @@ class PiperFollowerConfig(RobotConfig, PiperFollowerConfigBase):
raise ValueError("`enable_timeout_s` must be >= 0.")
if self.calibration_scale <= 0:
raise ValueError("`calibration_scale` must be > 0.")
if self.calibration_mode not in PIPER_CALIBRATION_MODES:
raise ValueError("`calibration_mode` must be one of: required, off.")
if self.startup_sleep_s < 0:
raise ValueError("`startup_sleep_s` must be >= 0.")
if not (0 <= self.gripper_effort_default <= 5000):

查看文件

@ -30,6 +30,7 @@ from lerobot.utils.piper_sdk import (
get_piper_sdk,
milli_to_unit,
parse_piper_log_level,
should_require_piper_calibration,
unit_to_milli,
)
from lerobot.utils.utils import enter_pressed, move_cursor_up
@ -100,7 +101,7 @@ class PiperFollower(Robot):
should_enable = self.config.enable_on_connect and calibrate
if should_enable and not self._wait_enable(self.config.enable_timeout_s):
logger.warning("Piper follower did not report enabled state before timeout.")
if not self.is_calibrated and calibrate:
if not self.is_calibrated and calibrate and should_require_piper_calibration(self.config.calibration_mode):
logger.info("No piper-follower calibration file found for '%s'. Running lerobot-calibrate flow.", self.id)
self.calibrate()
@ -116,6 +117,9 @@ class PiperFollower(Robot):
logger.info("%s connected.", self)
def _use_uncalibrated_passthrough(self) -> bool:
return not self.is_calibrated and not should_require_piper_calibration(self.config.calibration_mode)
@property
def is_calibrated(self) -> bool:
if not all(key in self.calibration for key in PIPER_CALIB_KEYS):
@ -247,7 +251,7 @@ class PiperFollower(Robot):
@check_if_not_connected
def send_action(self, action: RobotAction) -> RobotAction:
if not self.is_calibrated:
if not self.is_calibrated and not self._use_uncalibrated_passthrough():
raise RuntimeError(
f"{self} is not calibrated. Run `lerobot-calibrate --robot.type=piper_follower --robot.id={self.id}` first."
)
@ -259,7 +263,10 @@ class PiperFollower(Robot):
joint_keys = PIPER_JOINT_ACTION_KEYS
has_all_joints = all(key in action for key in joint_keys)
if has_all_joints:
joint_targets = [self._offset_to_target(key, action[key]) for key in joint_keys]
if self._use_uncalibrated_passthrough():
joint_targets = [action[key] for key in joint_keys]
else:
joint_targets = [self._offset_to_target(key, action[key]) for key in joint_keys]
joint_commands = [unit_to_milli(value) for value in joint_targets]
self.arm.JointCtrl(*joint_commands)
sent_action.update({key: milli_to_unit(raw) for key, raw in zip(joint_keys, joint_commands, strict=True)})
@ -267,7 +274,10 @@ class PiperFollower(Robot):
logger.debug("Ignoring partial Piper joint action. Need all six joint keys to send command.")
if self.config.sync_gripper and "gripper.pos" in action:
gripper_target = self._offset_to_target("gripper.pos", action["gripper.pos"])
if self._use_uncalibrated_passthrough():
gripper_target = action["gripper.pos"]
else:
gripper_target = self._offset_to_target("gripper.pos", action["gripper.pos"])
gripper_pos_raw = unit_to_milli(gripper_target)
self.arm.GripperCtrl(
gripper_pos_raw,