feat(piper): add dedicated piperx types and auto URDF selection

- add piperx_leader/piperx_follower config and runtime classes reusing piper logic

- remove manual gravity_comp_urdf_path and select bundled URDF by teleop type

- add bundled piper/piperx description assets tracked via git lfs

- update README piper setup and refresh piper teleop tests
这个提交包含在:
Elvin
2026-03-07 00:48:17 +08:00
父节点 fe9869c2bd
当前提交 92d9d829b3
共有 31 个文件被更改,包括 676 次插入 和 115 次删除

查看文件

@ -14,5 +14,5 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from .config_piper_follower import PiperFollowerConfig, PiperFollowerConfigBase
from .piper_follower import PiperFollower
from .config_piper_follower import PiperFollowerConfig, PiperFollowerConfigBase, PiperXFollowerConfig
from .piper_follower import PiperFollower, PiperXFollower

查看文件

@ -35,9 +35,6 @@ class PiperFollowerConfigBase:
log_level: str = "WARNING"
startup_sleep_s: float = 0.1
# Optional role command on startup (0xFC = motion output/follower arm)
set_follower_mode_on_connect: bool = False
# Motion mode for follower arm
speed_ratio: int = 100
high_follow: bool = True
@ -65,24 +62,36 @@ class PiperFollowerConfigBase:
disable_on_disconnect: bool = False
def _validate_piper_follower_config(config: PiperFollowerConfigBase) -> None:
if not (0 <= config.speed_ratio <= 100):
raise ValueError("`speed_ratio` must be between 0 and 100.")
if config.mode_refresh_interval_s < 0:
raise ValueError("`mode_refresh_interval_s` must be >= 0.")
if config.enable_timeout_s < 0:
raise ValueError("`enable_timeout_s` must be >= 0.")
if config.calibration_scale <= 0:
raise ValueError("`calibration_scale` must be > 0.")
if not isinstance(config.require_calibration, bool):
raise ValueError("require_calibration must be true or false.")
if config.startup_sleep_s < 0:
raise ValueError("`startup_sleep_s` must be >= 0.")
if not (0 <= config.gripper_effort_default <= 5000):
raise ValueError("`gripper_effort_default` must be between 0 and 5000.")
if config.gripper_status_code not in {0x00, 0x01, 0x02, 0x03}:
raise ValueError("`gripper_status_code` must be one of 0x00, 0x01, 0x02, 0x03.")
@RobotConfig.register_subclass("piper_follower")
@dataclass
class PiperFollowerConfig(RobotConfig, PiperFollowerConfigBase):
def __post_init__(self):
super().__post_init__()
if not (0 <= self.speed_ratio <= 100):
raise ValueError("`speed_ratio` must be between 0 and 100.")
if self.mode_refresh_interval_s < 0:
raise ValueError("`mode_refresh_interval_s` must be >= 0.")
if self.enable_timeout_s < 0:
raise ValueError("`enable_timeout_s` must be >= 0.")
if self.calibration_scale <= 0:
raise ValueError("`calibration_scale` must be > 0.")
if not isinstance(self.require_calibration, bool):
raise ValueError("require_calibration must be true or false.")
if self.startup_sleep_s < 0:
raise ValueError("`startup_sleep_s` must be >= 0.")
if not (0 <= self.gripper_effort_default <= 5000):
raise ValueError("`gripper_effort_default` must be between 0 and 5000.")
if self.gripper_status_code not in {0x00, 0x01, 0x02, 0x03}:
raise ValueError("`gripper_status_code` must be one of 0x00, 0x01, 0x02, 0x03.")
_validate_piper_follower_config(self)
@RobotConfig.register_subclass("piperx_follower")
@dataclass
class PiperXFollowerConfig(RobotConfig, PiperFollowerConfigBase):
def __post_init__(self):
super().__post_init__()
_validate_piper_follower_config(self)

查看文件

@ -24,17 +24,19 @@ from lerobot.processor import RobotAction, RobotObservation
from lerobot.utils.decorators import check_if_already_connected, check_if_not_connected
from lerobot.utils.piper_sdk import (
PIPER_ACTION_KEYS,
guard_piper_ctrl_mode_on_connect,
PIPER_JOINT_ACTION_KEYS,
PIPER_JOINT_NAMES,
get_piper_sdk,
milli_to_unit,
parse_piper_log_level,
unit_to_milli,
wait_enable_piper,
)
from lerobot.utils.utils import enter_pressed, move_cursor_up
from ..robot import Robot
from .config_piper_follower import PiperFollowerConfig
from .config_piper_follower import PiperFollowerConfig, PiperXFollowerConfig
logger = logging.getLogger(__name__)
PIPER_CALIB_KEYS = list(PIPER_ACTION_KEYS)
@ -47,7 +49,7 @@ class PiperFollower(Robot):
config_class = PiperFollowerConfig
name = "piper_follower"
def __init__(self, config: PiperFollowerConfig):
def __init__(self, config: PiperFollowerConfig | PiperXFollowerConfig):
super().__init__(config)
self.config = config
self._is_connected = False
@ -85,14 +87,11 @@ class PiperFollower(Robot):
self.arm.ConnectPort()
if self.config.startup_sleep_s > 0:
time.sleep(self.config.startup_sleep_s)
guard_piper_ctrl_mode_on_connect(arm=self.arm, interface_name=self.config.port)
self._is_connected = True
connected_cameras = []
try:
if self.config.set_follower_mode_on_connect:
self.arm.MasterSlaveConfig(0xFC, 0x00, 0x00, 0x00)
time.sleep(0.05)
self.configure()
should_auto_calibrate = (
not self.is_calibrated
@ -190,12 +189,7 @@ class PiperFollower(Robot):
self._send_motion_mode()
def _wait_enable(self, timeout_s: float) -> bool:
deadline = time.monotonic() + timeout_s
while time.monotonic() < deadline:
if bool(self.arm.EnablePiper()):
return True
time.sleep(0.02)
return False
return wait_enable_piper(self.arm, timeout_s)
def _read_raw_observation(self) -> RobotObservation:
joint_msg = self.arm.GetArmJointMsgs()
@ -259,7 +253,7 @@ class PiperFollower(Robot):
def send_action(self, action: RobotAction) -> RobotAction:
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."
f"{self} is not calibrated. Run `lerobot-calibrate --robot.type={self.config.type} --robot.id={self.id}` first."
)
self._refresh_motion_mode_if_needed()
@ -308,3 +302,8 @@ class PiperFollower(Robot):
cam.disconnect()
self._is_connected = False
logger.info("%s disconnected.", self)
class PiperXFollower(PiperFollower):
config_class = PiperXFollowerConfig
name = "piperx_follower"

查看文件

@ -68,6 +68,10 @@ def make_robot_from_config(config: RobotConfig) -> Robot:
from .piper_follower import PiperFollower
return PiperFollower(config)
elif config.type == "piperx_follower":
from .piper_follower import PiperXFollower
return PiperXFollower(config)
elif config.type == "bi_openarm_follower":
from .bi_openarm_follower import BiOpenArmFollower