镜像自地址
https://github.com/MINT-SJTU/Evo-RL.git
已同步 2026-11-20 18:17:06 +00:00
feat(piper): add bimanual PiPER/PiPER-X support and refresh docs
- add bi_piper/bi_piperx follower and leader implementations with configs - wire bimanual Piper types into factories, scripts, and async inference mappings - add pairing validation and bimanual parsing/teleop test coverage - update README news and AgileX teleop/data-collection command templates
这个提交包含在:
@ -26,4 +26,13 @@ DEFAULT_OBS_QUEUE_TIMEOUT = 2
|
||||
SUPPORTED_POLICIES = ["act", "smolvla", "diffusion", "tdmpc", "vqbet", "pi0", "pi05", "groot"]
|
||||
|
||||
# TODO: Add all other robots
|
||||
SUPPORTED_ROBOTS = ["so100_follower", "so101_follower", "bi_so_follower", "omx_follower"]
|
||||
SUPPORTED_ROBOTS = [
|
||||
"so100_follower",
|
||||
"so101_follower",
|
||||
"bi_so_follower",
|
||||
"piper_follower",
|
||||
"piperx_follower",
|
||||
"bi_piper_follower",
|
||||
"bi_piperx_follower",
|
||||
"omx_follower",
|
||||
]
|
||||
|
||||
@ -52,10 +52,12 @@ from lerobot.cameras.realsense.configuration_realsense import RealSenseCameraCon
|
||||
from lerobot.robots import ( # noqa: F401
|
||||
Robot,
|
||||
RobotConfig,
|
||||
bi_piper_follower,
|
||||
bi_so_follower,
|
||||
koch_follower,
|
||||
make_robot_from_config,
|
||||
omx_follower,
|
||||
piper_follower,
|
||||
so_follower,
|
||||
)
|
||||
from lerobot.transport import (
|
||||
|
||||
@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# Copyright 2026 The HuggingFace Inc. team. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from .bi_piper_follower import BiPiperFollower, BiPiperXFollower
|
||||
from .config_bi_piper_follower import BiPiperFollowerConfig, BiPiperXFollowerConfig
|
||||
@ -0,0 +1,171 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# Copyright 2026 The HuggingFace Inc. team. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import logging
|
||||
from functools import cached_property
|
||||
|
||||
from lerobot.processor import RobotAction, RobotObservation
|
||||
from lerobot.robots.piper_follower import (
|
||||
PiperFollower,
|
||||
PiperFollowerConfig,
|
||||
PiperXFollower,
|
||||
PiperXFollowerConfig,
|
||||
)
|
||||
from lerobot.utils.decorators import check_if_already_connected, check_if_not_connected
|
||||
|
||||
from ..robot import Robot
|
||||
from .config_bi_piper_follower import BiPiperFollowerConfig, BiPiperXFollowerConfig
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class BiPiperFollower(Robot):
|
||||
"""Bimanual PiPER/PiPER-X follower arms."""
|
||||
|
||||
config_class = BiPiperFollowerConfig
|
||||
name = "bi_piper_follower"
|
||||
_side_field_names = (
|
||||
"port",
|
||||
"judge_flag",
|
||||
"can_auto_init",
|
||||
"log_level",
|
||||
"startup_sleep_s",
|
||||
"speed_ratio",
|
||||
"high_follow",
|
||||
"mode_refresh_interval_s",
|
||||
"enable_on_connect",
|
||||
"enable_timeout_s",
|
||||
"calibration_scale",
|
||||
"require_calibration",
|
||||
"sync_gripper",
|
||||
"gripper_effort_default",
|
||||
"gripper_status_code",
|
||||
"cameras",
|
||||
"disable_on_disconnect",
|
||||
)
|
||||
|
||||
def _build_arm_config(self, arm_config_cls, side_cfg, side: str):
|
||||
kwargs = {name: getattr(side_cfg, name) for name in self._side_field_names}
|
||||
kwargs["id"] = f"{self.config.id}_{side}" if self.config.id else None
|
||||
kwargs["calibration_dir"] = self.config.calibration_dir
|
||||
return arm_config_cls(**kwargs)
|
||||
|
||||
def __init__(self, config: BiPiperFollowerConfig | BiPiperXFollowerConfig):
|
||||
super().__init__(config)
|
||||
self.config = config
|
||||
|
||||
if config.type == "bi_piperx_follower":
|
||||
arm_config_cls = PiperXFollowerConfig
|
||||
arm_cls = PiperXFollower
|
||||
else:
|
||||
arm_config_cls = PiperFollowerConfig
|
||||
arm_cls = PiperFollower
|
||||
|
||||
left_arm_config = self._build_arm_config(arm_config_cls, config.left_arm_config, "left")
|
||||
right_arm_config = self._build_arm_config(arm_config_cls, config.right_arm_config, "right")
|
||||
|
||||
self.left_arm = arm_cls(left_arm_config)
|
||||
self.right_arm = arm_cls(right_arm_config)
|
||||
|
||||
# Only for compatibility with other parts of the codebase that expect `robot.cameras`.
|
||||
self.cameras = {**self.left_arm.cameras, **self.right_arm.cameras}
|
||||
|
||||
@property
|
||||
def _motors_ft(self) -> dict[str, type]:
|
||||
left_arm_motors_ft = self.left_arm._motors_ft
|
||||
right_arm_motors_ft = self.right_arm._motors_ft
|
||||
return {
|
||||
**{f"left_{k}": v for k, v in left_arm_motors_ft.items()},
|
||||
**{f"right_{k}": v for k, v in right_arm_motors_ft.items()},
|
||||
}
|
||||
|
||||
@property
|
||||
def _cameras_ft(self) -> dict[str, tuple]:
|
||||
left_arm_cameras_ft = self.left_arm._cameras_ft
|
||||
right_arm_cameras_ft = self.right_arm._cameras_ft
|
||||
return {
|
||||
**{f"left_{k}": v for k, v in left_arm_cameras_ft.items()},
|
||||
**{f"right_{k}": v for k, v in right_arm_cameras_ft.items()},
|
||||
}
|
||||
|
||||
@cached_property
|
||||
def observation_features(self) -> dict[str, type | tuple]:
|
||||
return {**self._motors_ft, **self._cameras_ft}
|
||||
|
||||
@cached_property
|
||||
def action_features(self) -> dict[str, type]:
|
||||
return self._motors_ft
|
||||
|
||||
@property
|
||||
def is_connected(self) -> bool:
|
||||
return self.left_arm.is_connected and self.right_arm.is_connected
|
||||
|
||||
@check_if_already_connected
|
||||
def connect(self, calibrate: bool = True) -> None:
|
||||
self.left_arm.connect(calibrate)
|
||||
self.right_arm.connect(calibrate)
|
||||
|
||||
@property
|
||||
def is_calibrated(self) -> bool:
|
||||
return self.left_arm.is_calibrated and self.right_arm.is_calibrated
|
||||
|
||||
def calibrate(self) -> None:
|
||||
self.left_arm.calibrate()
|
||||
self.right_arm.calibrate()
|
||||
|
||||
def configure(self) -> None:
|
||||
self.left_arm.configure()
|
||||
self.right_arm.configure()
|
||||
|
||||
def setup_motors(self) -> None:
|
||||
self.left_arm.setup_motors()
|
||||
self.right_arm.setup_motors()
|
||||
|
||||
@check_if_not_connected
|
||||
def get_observation(self) -> RobotObservation:
|
||||
obs_dict: RobotObservation = {}
|
||||
left_obs = self.left_arm.get_observation()
|
||||
obs_dict.update({f"left_{key}": value for key, value in left_obs.items()})
|
||||
right_obs = self.right_arm.get_observation()
|
||||
obs_dict.update({f"right_{key}": value for key, value in right_obs.items()})
|
||||
return obs_dict
|
||||
|
||||
@check_if_not_connected
|
||||
def send_action(self, action: RobotAction) -> RobotAction:
|
||||
left_action: RobotAction = {}
|
||||
right_action: RobotAction = {}
|
||||
for key, value in action.items():
|
||||
if key.startswith("left_"):
|
||||
left_action[key.removeprefix("left_")] = value
|
||||
elif key.startswith("right_"):
|
||||
right_action[key.removeprefix("right_")] = value
|
||||
|
||||
sent_action_left = self.left_arm.send_action(left_action)
|
||||
sent_action_right = self.right_arm.send_action(right_action)
|
||||
|
||||
prefixed_sent_action_left = {f"left_{key}": value for key, value in sent_action_left.items()}
|
||||
prefixed_sent_action_right = {f"right_{key}": value for key, value in sent_action_right.items()}
|
||||
return {**prefixed_sent_action_left, **prefixed_sent_action_right}
|
||||
|
||||
@check_if_not_connected
|
||||
def disconnect(self):
|
||||
self.left_arm.disconnect()
|
||||
self.right_arm.disconnect()
|
||||
|
||||
|
||||
class BiPiperXFollower(BiPiperFollower):
|
||||
config_class = BiPiperXFollowerConfig
|
||||
name = "bi_piperx_follower"
|
||||
@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# Copyright 2026 The HuggingFace Inc. team. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from dataclasses import dataclass
|
||||
|
||||
from lerobot.robots.piper_follower import PiperFollowerConfigBase
|
||||
|
||||
from ..config import RobotConfig
|
||||
|
||||
|
||||
@RobotConfig.register_subclass("bi_piper_follower")
|
||||
@dataclass
|
||||
class BiPiperFollowerConfig(RobotConfig):
|
||||
"""Configuration class for bimanual PiPER follower robots."""
|
||||
|
||||
left_arm_config: PiperFollowerConfigBase
|
||||
right_arm_config: PiperFollowerConfigBase
|
||||
|
||||
|
||||
@RobotConfig.register_subclass("bi_piperx_follower")
|
||||
@dataclass
|
||||
class BiPiperXFollowerConfig(RobotConfig):
|
||||
"""Configuration class for bimanual PiPER-X follower robots."""
|
||||
|
||||
left_arm_config: PiperFollowerConfigBase
|
||||
right_arm_config: PiperFollowerConfigBase
|
||||
@ -72,6 +72,10 @@ def make_robot_from_config(config: RobotConfig) -> Robot:
|
||||
from .piper_follower import PiperXFollower
|
||||
|
||||
return PiperXFollower(config)
|
||||
elif config.type in {"bi_piper_follower", "bi_piperx_follower"}:
|
||||
from .bi_piper_follower import BiPiperFollower, BiPiperXFollower
|
||||
|
||||
return BiPiperXFollower(config) if config.type == "bi_piperx_follower" else BiPiperFollower(config)
|
||||
elif config.type == "bi_openarm_follower":
|
||||
from .bi_openarm_follower import BiOpenArmFollower
|
||||
|
||||
|
||||
@ -37,6 +37,7 @@ from lerobot.robots import ( # noqa: F401
|
||||
Robot,
|
||||
RobotConfig,
|
||||
bi_openarm_follower,
|
||||
bi_piper_follower,
|
||||
bi_so_follower,
|
||||
hope_jr,
|
||||
koch_follower,
|
||||
@ -51,6 +52,7 @@ from lerobot.teleoperators import ( # noqa: F401
|
||||
Teleoperator,
|
||||
TeleoperatorConfig,
|
||||
bi_openarm_leader,
|
||||
bi_piper_leader,
|
||||
bi_so_leader,
|
||||
homunculus,
|
||||
koch_leader,
|
||||
|
||||
@ -86,6 +86,7 @@ from lerobot.processor.rename_processor import rename_stats
|
||||
from lerobot.robots import ( # noqa: F401
|
||||
RobotConfig,
|
||||
bi_openarm_follower,
|
||||
bi_piper_follower,
|
||||
bi_so_follower,
|
||||
earthrover_mini_plus,
|
||||
hope_jr,
|
||||
@ -108,6 +109,7 @@ from lerobot.scripts.recording_loop import record_loop
|
||||
from lerobot.teleoperators import ( # noqa: F401
|
||||
TeleoperatorConfig,
|
||||
bi_openarm_leader,
|
||||
bi_piper_leader,
|
||||
bi_so_leader,
|
||||
homunculus,
|
||||
koch_leader,
|
||||
@ -123,6 +125,7 @@ from lerobot.utils.constants import ACTION
|
||||
from lerobot.utils.control_utils import (
|
||||
init_keyboard_listener,
|
||||
is_headless,
|
||||
sanity_check_bimanual_piper_pair,
|
||||
sanity_check_dataset_name,
|
||||
sanity_check_dataset_robot_compatibility,
|
||||
)
|
||||
@ -249,6 +252,7 @@ class RecordConfig:
|
||||
|
||||
if self.teleop is None and self.policy is None:
|
||||
raise ValueError("Choose a policy, a teleoperator or both to control the robot")
|
||||
sanity_check_bimanual_piper_pair(self.robot, self.teleop)
|
||||
if not self.intervention_toggle_key or len(self.intervention_toggle_key) != 1:
|
||||
raise ValueError("`intervention_toggle_key` must be a single character.")
|
||||
|
||||
|
||||
@ -54,6 +54,7 @@ from lerobot.robots import ( # noqa: F401
|
||||
Robot,
|
||||
RobotConfig,
|
||||
bi_openarm_follower,
|
||||
bi_piper_follower,
|
||||
bi_so_follower,
|
||||
earthrover_mini_plus,
|
||||
hope_jr,
|
||||
|
||||
@ -30,6 +30,7 @@ import draccus
|
||||
|
||||
from lerobot.robots import ( # noqa: F401
|
||||
RobotConfig,
|
||||
bi_piper_follower,
|
||||
bi_so_follower,
|
||||
koch_follower,
|
||||
lekiwi,
|
||||
@ -39,6 +40,7 @@ from lerobot.robots import ( # noqa: F401
|
||||
)
|
||||
from lerobot.teleoperators import ( # noqa: F401
|
||||
TeleoperatorConfig,
|
||||
bi_piper_leader,
|
||||
bi_so_leader,
|
||||
koch_leader,
|
||||
make_teleoperator_from_config,
|
||||
@ -55,6 +57,10 @@ COMPATIBLE_DEVICES = [
|
||||
"so100_leader",
|
||||
"so101_follower",
|
||||
"so101_leader",
|
||||
"bi_piper_follower",
|
||||
"bi_piperx_follower",
|
||||
"bi_piper_leader",
|
||||
"bi_piperx_leader",
|
||||
"lekiwi",
|
||||
]
|
||||
|
||||
|
||||
@ -71,6 +71,7 @@ from lerobot.robots import ( # noqa: F401
|
||||
Robot,
|
||||
RobotConfig,
|
||||
bi_openarm_follower,
|
||||
bi_piper_follower,
|
||||
bi_so_follower,
|
||||
earthrover_mini_plus,
|
||||
hope_jr,
|
||||
@ -87,6 +88,7 @@ from lerobot.teleoperators import ( # noqa: F401
|
||||
Teleoperator,
|
||||
TeleoperatorConfig,
|
||||
bi_openarm_leader,
|
||||
bi_piper_leader,
|
||||
bi_so_leader,
|
||||
gamepad,
|
||||
homunculus,
|
||||
@ -100,6 +102,7 @@ from lerobot.teleoperators import ( # noqa: F401
|
||||
so_leader,
|
||||
unitree_g1,
|
||||
)
|
||||
from lerobot.utils.control_utils import sanity_check_bimanual_piper_pair
|
||||
from lerobot.utils.import_utils import register_third_party_plugins
|
||||
from lerobot.utils.robot_utils import precise_sleep
|
||||
from lerobot.utils.utils import init_logging, move_cursor_up
|
||||
@ -206,6 +209,7 @@ def teleop_loop(
|
||||
@parser.wrap()
|
||||
def teleoperate(cfg: TeleoperateConfig):
|
||||
init_logging()
|
||||
sanity_check_bimanual_piper_pair(cfg.robot, cfg.teleop)
|
||||
logging.info(pformat(asdict(cfg)))
|
||||
if cfg.display_data:
|
||||
init_rerun(session_name="teleoperation", ip=cfg.display_ip, port=cfg.display_port)
|
||||
|
||||
@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# Copyright 2026 The HuggingFace Inc. team. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from .bi_piper_leader import BiPiperLeader, BiPiperXLeader
|
||||
from .config_bi_piper_leader import BiPiperLeaderConfig, BiPiperXLeaderConfig
|
||||
@ -0,0 +1,163 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# Copyright 2026 The HuggingFace Inc. team. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import logging
|
||||
from functools import cached_property
|
||||
from typing import Any
|
||||
|
||||
from lerobot.processor import RobotAction
|
||||
from lerobot.teleoperators.piper_leader import (
|
||||
PiperLeader,
|
||||
PiperLeaderConfig,
|
||||
PiperXLeader,
|
||||
PiperXLeaderConfig,
|
||||
)
|
||||
from lerobot.utils.decorators import check_if_already_connected, check_if_not_connected
|
||||
|
||||
from ..teleoperator import Teleoperator
|
||||
from .config_bi_piper_leader import BiPiperLeaderConfig, BiPiperXLeaderConfig
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class BiPiperLeader(Teleoperator):
|
||||
"""Bimanual PiPER/PiPER-X leader arms."""
|
||||
|
||||
config_class = BiPiperLeaderConfig
|
||||
name = "bi_piper_leader"
|
||||
_side_field_names = (
|
||||
"port",
|
||||
"judge_flag",
|
||||
"can_auto_init",
|
||||
"log_level",
|
||||
"startup_sleep_s",
|
||||
"manual_control",
|
||||
"prefer_ctrl_messages",
|
||||
"fallback_to_feedback",
|
||||
"sync_gripper",
|
||||
"gripper_effort_default",
|
||||
"gripper_status_code",
|
||||
"command_speed_ratio",
|
||||
"command_high_follow",
|
||||
"mode_refresh_interval_s",
|
||||
"enable_timeout_s",
|
||||
"gravity_comp_control_hz",
|
||||
"gravity_comp_tx_ratio",
|
||||
"gravity_comp_torque_limit",
|
||||
"gravity_comp_mit_kp",
|
||||
"gravity_comp_mit_kd",
|
||||
"gravity_comp_base_rpy_deg",
|
||||
"calibration_scale",
|
||||
"require_calibration",
|
||||
"disable_on_disconnect",
|
||||
)
|
||||
|
||||
def _build_arm_config(self, arm_config_cls, side_cfg, side: str):
|
||||
kwargs = {name: getattr(side_cfg, name) for name in self._side_field_names}
|
||||
kwargs["id"] = f"{self.config.id}_{side}" if self.config.id else None
|
||||
kwargs["calibration_dir"] = self.config.calibration_dir
|
||||
return arm_config_cls(**kwargs)
|
||||
|
||||
def __init__(self, config: BiPiperLeaderConfig | BiPiperXLeaderConfig):
|
||||
super().__init__(config)
|
||||
self.config = config
|
||||
|
||||
if config.type == "bi_piperx_leader":
|
||||
arm_config_cls = PiperXLeaderConfig
|
||||
arm_cls = PiperXLeader
|
||||
else:
|
||||
arm_config_cls = PiperLeaderConfig
|
||||
arm_cls = PiperLeader
|
||||
|
||||
left_arm_config = self._build_arm_config(arm_config_cls, config.left_arm_config, "left")
|
||||
right_arm_config = self._build_arm_config(arm_config_cls, config.right_arm_config, "right")
|
||||
|
||||
self.left_arm = arm_cls(left_arm_config)
|
||||
self.right_arm = arm_cls(right_arm_config)
|
||||
|
||||
@cached_property
|
||||
def action_features(self) -> dict[str, type]:
|
||||
left_arm_features = self.left_arm.action_features
|
||||
right_arm_features = self.right_arm.action_features
|
||||
return {
|
||||
**{f"left_{k}": v for k, v in left_arm_features.items()},
|
||||
**{f"right_{k}": v for k, v in right_arm_features.items()},
|
||||
}
|
||||
|
||||
@cached_property
|
||||
def feedback_features(self) -> dict[str, type]:
|
||||
return {}
|
||||
|
||||
@property
|
||||
def is_connected(self) -> bool:
|
||||
return self.left_arm.is_connected and self.right_arm.is_connected
|
||||
|
||||
@check_if_already_connected
|
||||
def connect(self, calibrate: bool = True) -> None:
|
||||
self.left_arm.connect(calibrate)
|
||||
self.right_arm.connect(calibrate)
|
||||
|
||||
@property
|
||||
def is_calibrated(self) -> bool:
|
||||
return self.left_arm.is_calibrated and self.right_arm.is_calibrated
|
||||
|
||||
def calibrate(self) -> None:
|
||||
self.left_arm.calibrate()
|
||||
self.right_arm.calibrate()
|
||||
|
||||
def configure(self) -> None:
|
||||
self.left_arm.configure()
|
||||
self.right_arm.configure()
|
||||
|
||||
def setup_motors(self) -> None:
|
||||
self.left_arm.setup_motors()
|
||||
self.right_arm.setup_motors()
|
||||
|
||||
@check_if_not_connected
|
||||
def set_manual_control(self, enabled: bool) -> None:
|
||||
self.left_arm.set_manual_control(enabled)
|
||||
self.right_arm.set_manual_control(enabled)
|
||||
|
||||
@check_if_not_connected
|
||||
def get_action(self) -> RobotAction:
|
||||
action_dict: RobotAction = {}
|
||||
left_action = self.left_arm.get_action()
|
||||
action_dict.update({f"left_{key}": value for key, value in left_action.items()})
|
||||
right_action = self.right_arm.get_action()
|
||||
action_dict.update({f"right_{key}": value for key, value in right_action.items()})
|
||||
return action_dict
|
||||
|
||||
@check_if_not_connected
|
||||
def send_feedback(self, feedback: dict[str, Any]) -> None:
|
||||
left_feedback: dict[str, Any] = {}
|
||||
right_feedback: dict[str, Any] = {}
|
||||
for key, value in feedback.items():
|
||||
if key.startswith("left_"):
|
||||
left_feedback[key.removeprefix("left_")] = value
|
||||
elif key.startswith("right_"):
|
||||
right_feedback[key.removeprefix("right_")] = value
|
||||
self.left_arm.send_feedback(left_feedback)
|
||||
self.right_arm.send_feedback(right_feedback)
|
||||
|
||||
@check_if_not_connected
|
||||
def disconnect(self) -> None:
|
||||
self.left_arm.disconnect()
|
||||
self.right_arm.disconnect()
|
||||
|
||||
|
||||
class BiPiperXLeader(BiPiperLeader):
|
||||
config_class = BiPiperXLeaderConfig
|
||||
name = "bi_piperx_leader"
|
||||
@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# Copyright 2026 The HuggingFace Inc. team. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from dataclasses import dataclass
|
||||
|
||||
from lerobot.teleoperators.piper_leader import PiperLeaderConfigBase
|
||||
|
||||
from ..config import TeleoperatorConfig
|
||||
|
||||
|
||||
@TeleoperatorConfig.register_subclass("bi_piper_leader")
|
||||
@dataclass
|
||||
class BiPiperLeaderConfig(TeleoperatorConfig):
|
||||
"""Configuration class for bimanual PiPER leader teleoperators."""
|
||||
|
||||
left_arm_config: PiperLeaderConfigBase
|
||||
right_arm_config: PiperLeaderConfigBase
|
||||
|
||||
|
||||
@TeleoperatorConfig.register_subclass("bi_piperx_leader")
|
||||
@dataclass
|
||||
class BiPiperXLeaderConfig(TeleoperatorConfig):
|
||||
"""Configuration class for bimanual PiPER-X leader teleoperators."""
|
||||
|
||||
left_arm_config: PiperLeaderConfigBase
|
||||
right_arm_config: PiperLeaderConfigBase
|
||||
@ -99,6 +99,10 @@ def make_teleoperator_from_config(config: TeleoperatorConfig) -> "Teleoperator":
|
||||
from .piper_leader import PiperXLeader
|
||||
|
||||
return PiperXLeader(config)
|
||||
elif config.type in {"bi_piper_leader", "bi_piperx_leader"}:
|
||||
from .bi_piper_leader import BiPiperLeader, BiPiperXLeader
|
||||
|
||||
return BiPiperXLeader(config) if config.type == "bi_piperx_leader" else BiPiperLeader(config)
|
||||
elif config.type == "bi_openarm_leader":
|
||||
from .bi_openarm_leader import BiOpenArmLeader
|
||||
|
||||
|
||||
@ -262,3 +262,28 @@ def sanity_check_dataset_robot_compatibility(
|
||||
raise ValueError(
|
||||
"Dataset metadata compatibility check failed with mismatches:\n" + "\n".join(mismatches)
|
||||
)
|
||||
|
||||
|
||||
def sanity_check_bimanual_piper_pair(robot_cfg, teleop_cfg) -> None:
|
||||
"""Ensure bimanual PiPER configs are not mixed between PiPER and PiPER-X variants."""
|
||||
if teleop_cfg is None:
|
||||
return
|
||||
|
||||
robot_type = getattr(robot_cfg, "type", None)
|
||||
teleop_type = getattr(teleop_cfg, "type", None)
|
||||
expected_teleop_by_robot = {
|
||||
"bi_piper_follower": "bi_piper_leader",
|
||||
"bi_piperx_follower": "bi_piperx_leader",
|
||||
}
|
||||
expected_robot_by_teleop = {teleop: robot for robot, teleop in expected_teleop_by_robot.items()}
|
||||
|
||||
if robot_type in expected_teleop_by_robot and teleop_type != expected_teleop_by_robot[robot_type]:
|
||||
expected = expected_teleop_by_robot[robot_type]
|
||||
raise ValueError(
|
||||
f"In bimanual PiPER mode, '{robot_type}' must be paired with '{expected}', got '{teleop_type}'."
|
||||
)
|
||||
if teleop_type in expected_robot_by_teleop and robot_type != expected_robot_by_teleop[teleop_type]:
|
||||
expected = expected_robot_by_teleop[teleop_type]
|
||||
raise ValueError(
|
||||
f"In bimanual PiPER mode, '{teleop_type}' must be paired with '{expected}', got '{robot_type}'."
|
||||
)
|
||||
|
||||
在新工单中引用
屏蔽一个用户