feat: 接入双臂 MuJoCo 启动模式

This commit is contained in:
2026-08-04 13:37:31 +08:00
parent 826b929d97
commit 002484b610
3 changed files with 66 additions and 0 deletions
+28
View File
@@ -57,6 +57,26 @@ def _udp_receiver_node() -> Node:
)
def _mujoco_node() -> Node:
"""启动只读双臂 MuJoCo 运动学显示节点。"""
return Node(
package="xr_rm_mujoco",
executable="dual_arm_simulator",
name="dual_arm_simulator",
output="screen",
prefix=[XR_PYTHON],
parameters=[
_config_file("dual_arm_mujoco.yaml"),
{"robot_urdf_path": _dual_rm75_urdf()},
],
)
def _validate_mujoco_mode(arm: str, use_mujoco: bool) -> None:
if use_mujoco and arm != "both":
raise ValueError("use_mujoco:=true requires arm:=both")
def _single_arm_node(
arm: str,
use_mock: bool,
@@ -138,15 +158,21 @@ def _launch_setup(context, *args, **kwargs):
)
arm = LaunchConfiguration("arm").perform(context).strip().lower()
use_mock = _as_bool(LaunchConfiguration("use_mock").perform(context))
use_mujoco = _as_bool(
LaunchConfiguration("use_mujoco").perform(context)
)
if arm not in ("left", "right", "both"):
raise ValueError("arm must be one of: left, right, both")
_validate_mujoco_mode(arm, use_mujoco)
nodes = [_udp_receiver_node()]
if arm == "both":
nodes.extend(_dual_arm_nodes(use_mock))
else:
nodes.append(_single_arm_node(arm, use_mock))
if use_mujoco:
nodes.append(_mujoco_node())
return nodes
@@ -156,6 +182,8 @@ def generate_launch_description() -> LaunchDescription:
DeclareLaunchArgument("arm", default_value="right"),
# true 时只跑 mock,不连接 RM75false 时通过 RealMan SDK 连接真机。
DeclareLaunchArgument("use_mock", default_value="true"),
# true 时额外启动只读 MuJoCo 双臂显示,默认不改变现有启动行为。
DeclareLaunchArgument("use_mujoco", default_value="false"),
# UDP 监听参数,需要与 PICO 端或 sample_udp_sender 保持一致。
DeclareLaunchArgument("udp_host", default_value="0.0.0.0"),
DeclareLaunchArgument("udp_port", default_value="15000"),