From 45b01719e3498d85f6741c1bed83df99699dbbc4 Mon Sep 17 00:00:00 2001 From: lgv Date: Thu, 19 Nov 2026 19:00:19 +0800 Subject: [PATCH] feat(xiaozhao): split simulation and real device profiles --- cmvr-es/config/cmvr_es.pb.txt | 2 +- ..._arm.pb.txt => xiaozhao_mujoco_arm.pb.txt} | 12 +- ...ead.pb.txt => xiaozhao_mujoco_head.pb.txt} | 6 +- .../devices/arm/xiaozhao_tchl_arm.pb.txt | 330 ++++++++++++++++++ .../devices/camera/xiaozhao_camera.pb.txt | 59 ++-- .../camera/xiaozhao_mujoco_camera.pb.txt | 63 ++++ cmvr-es/config/devices/dexhand/dexhand.pb.txt | 2 +- ...s.pb.txt => xiaozhao_mujoco_motors.pb.txt} | 8 +- .../devices/motor/xiaozhao_tchl_motors.pb.txt | 92 +++++ ...ager.pb.txt => real_device_manager.pb.txt} | 123 ++----- .../config/manager/sim_device_manager.pb.txt | 96 +++++ cmvr-es/config/manager/task_manager.pb.txt | 6 +- .../self_collision_task_xiaozhao_left.pb.txt | 2 +- .../self_collision_task_xiaozhao_right.pb.txt | 2 +- .../touch_screen_task_xiaozhao_mujoco.pb.txt | 8 +- cmvr-es/devices/agv/seer_robokit/README.md | 4 +- .../src/realsense_camera_test.cpp | 2 +- .../src/touch_screen_task_test.cpp | 6 +- cmvr-es/test/mujoco_manual_ui_test.cpp | 3 + docs/ethercat_motor_tutorial.md | 2 +- model/README.md | 45 +-- model/xiaozhao/collision/README.md | 4 +- scripts/test_wait_network_devices.py | 21 +- scripts/wait_network_devices.py | 7 +- 24 files changed, 722 insertions(+), 183 deletions(-) rename cmvr-es/config/devices/arm/{xiaozhao_arm.pb.txt => xiaozhao_mujoco_arm.pb.txt} (97%) rename cmvr-es/config/devices/arm/{xiaozhao_head.pb.txt => xiaozhao_mujoco_head.pb.txt} (84%) create mode 100644 cmvr-es/config/devices/arm/xiaozhao_tchl_arm.pb.txt create mode 100644 cmvr-es/config/devices/camera/xiaozhao_mujoco_camera.pb.txt rename cmvr-es/config/devices/motor/{xiaozhao_motors.pb.txt => xiaozhao_mujoco_motors.pb.txt} (95%) create mode 100644 cmvr-es/config/devices/motor/xiaozhao_tchl_motors.pb.txt rename cmvr-es/config/manager/{device_manager.pb.txt => real_device_manager.pb.txt} (74%) create mode 100644 cmvr-es/config/manager/sim_device_manager.pb.txt diff --git a/cmvr-es/config/cmvr_es.pb.txt b/cmvr-es/config/cmvr_es.pb.txt index f5674fb8..77e4ea16 100644 --- a/cmvr-es/config/cmvr_es.pb.txt +++ b/cmvr-es/config/cmvr_es.pb.txt @@ -1,5 +1,5 @@ cmvr_es { logger_config_file: "logger/logger.pb.txt" - device_manager_config_file: "manager/device_manager.pb.txt" + device_manager_config_file: "manager/real_device_manager.pb.txt" task_manager_config_file: "manager/task_manager.pb.txt" } diff --git a/cmvr-es/config/devices/arm/xiaozhao_arm.pb.txt b/cmvr-es/config/devices/arm/xiaozhao_mujoco_arm.pb.txt similarity index 97% rename from cmvr-es/config/devices/arm/xiaozhao_arm.pb.txt rename to cmvr-es/config/devices/arm/xiaozhao_mujoco_arm.pb.txt index e99b6f4b..7975f168 100644 --- a/cmvr-es/config/devices/arm/xiaozhao_arm.pb.txt +++ b/cmvr-es/config/devices/arm/xiaozhao_mujoco_arm.pb.txt @@ -4,10 +4,10 @@ arm { robot_arms { - id: "xiaozhao_left_arm" + id: "xiaozhao_mujoco_left_arm" motor { - motor_system_id: "xiaozhao_left_arm_motors" - motor_group_ids: "xiaozhao_left_arm_motors" + motor_system_id: "xiaozhao_mujoco_left_arm_motors" + motor_group_ids: "xiaozhao_mujoco_left_arm_motors" dof: 7 joint_names: "joint1-left" joint_names: "joint2-left" @@ -167,10 +167,10 @@ arm { } robot_arms { - id: "xiaozhao_right_arm" + id: "xiaozhao_mujoco_right_arm" motor { - motor_system_id: "xiaozhao_right_arm_motors" - motor_group_ids: "xiaozhao_right_arm_motors" + motor_system_id: "xiaozhao_mujoco_right_arm_motors" + motor_group_ids: "xiaozhao_mujoco_right_arm_motors" dof: 7 joint_names: "joint1-right" joint_names: "joint2-right" diff --git a/cmvr-es/config/devices/arm/xiaozhao_head.pb.txt b/cmvr-es/config/devices/arm/xiaozhao_mujoco_head.pb.txt similarity index 84% rename from cmvr-es/config/devices/arm/xiaozhao_head.pb.txt rename to cmvr-es/config/devices/arm/xiaozhao_mujoco_head.pb.txt index 6803f199..465c7e9a 100644 --- a/cmvr-es/config/devices/arm/xiaozhao_head.pb.txt +++ b/cmvr-es/config/devices/arm/xiaozhao_mujoco_head.pb.txt @@ -2,11 +2,11 @@ # MoveJ 目标顺序为 neck-joint1、neck-joint2、neck-joint3,单位为弧度。 arm { robot_arms { - id: "xiaozhao_head" + id: "xiaozhao_mujoco_head" motor { - motor_system_id: "xiaozhao_head_motors" - motor_group_ids: "xiaozhao_head_motors" + motor_system_id: "xiaozhao_mujoco_head_motors" + motor_group_ids: "xiaozhao_mujoco_head_motors" dof: 3 joint_names: "neck-joint1" joint_names: "neck-joint2" diff --git a/cmvr-es/config/devices/arm/xiaozhao_tchl_arm.pb.txt b/cmvr-es/config/devices/arm/xiaozhao_tchl_arm.pb.txt new file mode 100644 index 00000000..c8faa407 --- /dev/null +++ b/cmvr-es/config/devices/arm/xiaozhao_tchl_arm.pb.txt @@ -0,0 +1,330 @@ +# 小赵 TCHL 实机双臂配置,所有关节位置使用 rad。 +# TCP 与第七连杆同向,局部偏移左 (0.007, 0.23, -0.045) m、右 (0.007, -0.23, -0.045) m。 +# 两臂分别规划 MoveP。关节路径碰撞检测的最小间距为 10 mm。 +arm { + robot_arms { + id: "xiaozhao_tchl_right_arm" + motor { + motor_system_id: "xiaozhao_tchl_motors" + motor_group_ids: "xiaozhao_tchl_motors" + dof: 7 + joint_names: "joint1-right" + joint_names: "joint2-right" + joint_names: "joint3-right" + joint_names: "joint4-right" + joint_names: "joint5-right" + joint_names: "joint6-right" + joint_names: "joint7-right" + upd_freq: 1000 + buffer_size: 50 + default_vel: 0.5 + default_acc: 2.0 + } + kinematics { + pinocchio_qp_ik_solver { + urdf_path: "model/xiaozhao/urdf/xiaozhao.urdf" + base_frame_name: "base_link" + flange_frame_name: "link7-right" + tcp_frame_name: "tcp-right" + lambda: 1e-4 + w_posrot: 0.5 + max_iters: 100 + tol: 1e-6 + qp_time_limit: 1e-2 + joint_limit_policy { + limits { + enable: true + source: JOINT_LIMIT_SOURCE_CUSTOM + joints { joint_name: "joint1-right" q_lb: -3.14 q_ub: 3.14 qd: 1.0 qdd: 5.0 } + joints { joint_name: "joint2-right" q_lb: -1.57 q_ub: 1.57 qd: 1.0 qdd: 5.0 } + joints { joint_name: "joint3-right" q_lb: -3.14 q_ub: 3.14 qd: 1.0 qdd: 5.0 } + joints { joint_name: "joint4-right" q_lb: -2.35 q_ub: 0 qd: 1.0 qdd: 5.0 } + joints { joint_name: "joint5-right" q_lb: -3.14 q_ub: 3.14 qd: 1.0 qdd: 5.0 } + joints { joint_name: "joint6-right" q_lb: -0.45 q_ub: 0.785 qd: 1.0 qdd: 5.0 } + joints { joint_name: "joint7-right" q_lb: -1.05 q_ub: 1.05 qd: 1.0 qdd: 5.0 } + } + soft_limit { + enable: true + margin_ratio: 0.01 + min_margin_rad: 0.01 + } + avoidance { + enable: false + } + } + } + } + motion { + joint_path { + algorithm: RRT_CONNECT + rrt_connect { + timeout_s: 2.0 + range_rad: 0.2 + collision_check_step_rad: 0.02 + } + collision_checker { + urdf_path: "model/xiaozhao/collision/xiaozhao_collision.urdf" + ignored_pairs { first: "link5-right" second: "link7-right" } + } + minimum_distance_m: 0.01 + } + joint_trajectory_smoother { + sample_period_s: 0.001 + quintic_bspline { + control_point_spacing_rad: 0.05 + } + } + move_j { + settle_timeout_s: 3.0 + settle_position_tolerance_rad: 0.002 + settle_velocity_tolerance_rad_s: 0.02 + settle_stable_sample_count: 3 + } + move_l { + pinocchio_cartesian_motion_planner { + sample_period_s: 0.001 + position_gain: 4.0 + rotation_gain: 4.0 + line_deviation_check { + enable: true + line_deviation_warn_m: 0.01 + line_deviation_stop_m: 0.03 + line_direction_warn_deg: 20.0 + line_direction_stop_deg: 45.0 + line_direction_reset_deg: 10.0 + line_check_min_distance_m: 0.005 + } + joint_continuity_check { + enable: true + max_joint_delta_rad: 0.05 + max_joint_velocity_rad_s: 1.0 + max_joint_acceleration_rad_s2: 5.0 + } + cartesian_step_feasibility_check { + enable: true + min_linear_speed_ratio: 0.2 + max_linear_direction_deviation_deg: 10.0 + min_angular_speed_ratio: 0.2 + max_angular_direction_deviation_deg: 10.0 + min_desired_linear_speed: 1e-4 + min_desired_angular_speed: 1e-4 + } + } + } + speed_l { + pinocchio_cartesian_motion_planner { + linear_velocity_max: 0.1 + linear_acceleration_max: 0.5 + linear_jerk_max: 5.0 + angular_velocity_max: 0.5 + angular_acceleration_max: 2.0 + angular_jerk_max: 10.0 + linear_target_replan_threshold: 1e-4 + angular_target_replan_threshold: 1e-4 + enforce_joint_acceleration_limits: true + adaptive_speed { + enable: true + lookahead_s: 0.15 + min_speed_ratio: 0.10 + } + line_deviation_check { + enable: true + line_deviation_warn_m: 0.01 + line_deviation_stop_m: 0.03 + line_direction_warn_deg: 20.0 + line_direction_stop_deg: 45.0 + line_direction_reset_deg: 10.0 + line_check_min_distance_m: 0.005 + } + joint_velocity_check { + enable: true + max_joint_velocity_rad_s: 1.0 + max_joint_acceleration_rad_s2: 5.0 + } + cartesian_velocity_feasibility_check { + enable: true + min_linear_speed_ratio: 0.2 + max_linear_direction_deviation_deg: 10.0 + min_angular_speed_ratio: 0.2 + max_angular_direction_deviation_deg: 10.0 + min_desired_linear_speed: 0.01 + min_desired_angular_speed: 1e-4 + } + } + speed_l_controller { + cartesian_velocity_controller { + control_period_s: 0.001 + stop_twist_norm: 1e-9 + stop_command_velocity_norm: 1e-3 + stop_measured_velocity_norm: 1e-2 + stop_acceleration: 2.0 + stop_timeout_s: 2.0 + } + } + } + } + } + + robot_arms { + id: "xiaozhao_tchl_left_arm" + motor { + motor_system_id: "xiaozhao_tchl_motors" + motor_group_ids: "xiaozhao_tchl_motors" + dof: 7 + joint_names: "joint1-left" + joint_names: "joint2-left" + joint_names: "joint3-left" + joint_names: "joint4-left" + joint_names: "joint5-left" + joint_names: "joint6-left" + joint_names: "joint7-left" + upd_freq: 1000 + buffer_size: 50 + default_vel: 0.5 + default_acc: 2.0 + } + kinematics { + pinocchio_qp_ik_solver { + urdf_path: "model/xiaozhao/urdf/xiaozhao.urdf" + base_frame_name: "base_link" + flange_frame_name: "link7-left" + tcp_frame_name: "tcp-left" + lambda: 1e-4 + w_posrot: 0.5 + max_iters: 100 + tol: 1e-6 + qp_time_limit: 1e-2 + joint_limit_policy { + limits { + enable: true + source: JOINT_LIMIT_SOURCE_CUSTOM + joints { joint_name: "joint1-left" q_lb: -3.14 q_ub: 3.14 qd: 1.0 qdd: 5.0 } + joints { joint_name: "joint2-left" q_lb: -1.57 q_ub: 1.57 qd: 1.0 qdd: 5.0 } + joints { joint_name: "joint3-left" q_lb: -3.14 q_ub: 3.14 qd: 1.0 qdd: 5.0 } + joints { joint_name: "joint4-left" q_lb: 0 q_ub: 2.35 qd: 1.0 qdd: 5.0 } + joints { joint_name: "joint5-left" q_lb: -3.14 q_ub: 3.14 qd: 1.0 qdd: 5.0 } + joints { joint_name: "joint6-left" q_lb: -0.785 q_ub: 0.45 qd: 1.0 qdd: 5.0 } + joints { joint_name: "joint7-left" q_lb: -1.05 q_ub: 1.05 qd: 1.0 qdd: 5.0 } + } + soft_limit { + enable: true + margin_ratio: 0.01 + min_margin_rad: 0.01 + } + avoidance { + enable: false + } + } + } + } + motion { + joint_path { + algorithm: RRT_CONNECT + rrt_connect { + timeout_s: 2.0 + range_rad: 0.2 + collision_check_step_rad: 0.02 + } + collision_checker { + urdf_path: "model/xiaozhao/collision/xiaozhao_collision.urdf" + ignored_pairs { first: "link5-left" second: "link7-left" } + } + minimum_distance_m: 0.01 + } + joint_trajectory_smoother { + sample_period_s: 0.001 + quintic_bspline { + control_point_spacing_rad: 0.05 + } + } + move_j { + settle_timeout_s: 3.0 + settle_position_tolerance_rad: 0.002 + settle_velocity_tolerance_rad_s: 0.02 + settle_stable_sample_count: 3 + } + move_l { + pinocchio_cartesian_motion_planner { + sample_period_s: 0.001 + position_gain: 4.0 + rotation_gain: 4.0 + line_deviation_check { + enable: true + line_deviation_warn_m: 0.01 + line_deviation_stop_m: 0.03 + line_direction_warn_deg: 20.0 + line_direction_stop_deg: 45.0 + line_direction_reset_deg: 10.0 + line_check_min_distance_m: 0.005 + } + joint_continuity_check { + enable: true + max_joint_delta_rad: 0.05 + max_joint_velocity_rad_s: 1.0 + max_joint_acceleration_rad_s2: 5.0 + } + cartesian_step_feasibility_check { + enable: true + min_linear_speed_ratio: 0.2 + max_linear_direction_deviation_deg: 10.0 + min_angular_speed_ratio: 0.2 + max_angular_direction_deviation_deg: 10.0 + min_desired_linear_speed: 1e-4 + min_desired_angular_speed: 1e-4 + } + } + } + speed_l { + pinocchio_cartesian_motion_planner { + linear_velocity_max: 0.1 + linear_acceleration_max: 0.5 + linear_jerk_max: 5.0 + angular_velocity_max: 0.5 + angular_acceleration_max: 2.0 + angular_jerk_max: 10.0 + linear_target_replan_threshold: 1e-4 + angular_target_replan_threshold: 1e-4 + enforce_joint_acceleration_limits: true + adaptive_speed { + enable: true + lookahead_s: 0.15 + min_speed_ratio: 0.10 + } + line_deviation_check { + enable: true + line_deviation_warn_m: 0.01 + line_deviation_stop_m: 0.03 + line_direction_warn_deg: 20.0 + line_direction_stop_deg: 45.0 + line_direction_reset_deg: 10.0 + line_check_min_distance_m: 0.005 + } + joint_velocity_check { + enable: true + max_joint_velocity_rad_s: 1.0 + max_joint_acceleration_rad_s2: 5.0 + } + cartesian_velocity_feasibility_check { + enable: true + min_linear_speed_ratio: 0.2 + max_linear_direction_deviation_deg: 10.0 + min_angular_speed_ratio: 0.2 + max_angular_direction_deviation_deg: 10.0 + min_desired_linear_speed: 0.01 + min_desired_angular_speed: 1e-4 + } + } + speed_l_controller { + cartesian_velocity_controller { + control_period_s: 0.001 + stop_twist_norm: 1e-9 + stop_command_velocity_norm: 1e-3 + stop_measured_velocity_norm: 1e-2 + stop_acceleration: 2.0 + stop_timeout_s: 2.0 + } + } + } + } + } +} diff --git a/cmvr-es/config/devices/camera/xiaozhao_camera.pb.txt b/cmvr-es/config/devices/camera/xiaozhao_camera.pb.txt index 8a88213d..f319a831 100644 --- a/cmvr-es/config/devices/camera/xiaozhao_camera.pb.txt +++ b/cmvr-es/config/devices/camera/xiaozhao_camera.pb.txt @@ -1,63 +1,50 @@ -# xiaozhao 触屏仿真相机。手相机保持 1280x720 点击像素坐标。 -# 头部相机使用 2560x1440,提高 16 mm 屏幕 Tag 的像素尺寸与姿态估计稳定性。 +# 小赵实机相机。每路使用该安装位置对应的 RealSense 序列号。 camera { cameras { - id: "mujoco_hand_cam" - mujoco { - world_id: "mujoco_world" - camera_name: "hand_cam" - render { + id: "head_carme" + realsense { + serialNumber: "243122075389" + camera_mode: CAMERA_MODE_VIDEO + capture { width: 1280 height: 720 fps: 30 - stream_mode: STREAM_MODE_RGBD + stream_mode: STREAM_MODE_RGB } encoder { - width: 480 - height: 320 + width: 640 + height: 360 fps: 30 codec: "H264" enable_stream_timestamp: true buffer_size: 30 } - consume_new_frame_only: false - viewer_pip { - enable: false - left: -10 - bottom: 10 - width: 320 - height: 180 - } + align_mode: ALIGN_MODE_COLOR + sync: false } } cameras { - id: "mujoco_external_touch_cam" - mujoco { - world_id: "mujoco_world" - camera_name: "external_touch_cam" - render { - width: 2560 - height: 1440 + id: "right_hand_carme" + realsense { + serialNumber: "263122071711" + camera_mode: CAMERA_MODE_VIDEO + capture { + width: 1280 + height: 720 fps: 30 - stream_mode: STREAM_MODE_RGBD + stream_mode: STREAM_MODE_RGB } encoder { - width: 480 - height: 320 + width: 640 + height: 360 fps: 30 codec: "H264" enable_stream_timestamp: true buffer_size: 30 } - consume_new_frame_only: false - viewer_pip { - enable: false - left: 10 - bottom: 10 - width: 320 - height: 180 - } + align_mode: ALIGN_MODE_COLOR + sync: false } } } diff --git a/cmvr-es/config/devices/camera/xiaozhao_mujoco_camera.pb.txt b/cmvr-es/config/devices/camera/xiaozhao_mujoco_camera.pb.txt new file mode 100644 index 00000000..250c99ff --- /dev/null +++ b/cmvr-es/config/devices/camera/xiaozhao_mujoco_camera.pb.txt @@ -0,0 +1,63 @@ +# xiaozhao 触屏仿真相机。手相机保持 1280x720 点击像素坐标。 +# 头部相机使用 2560x1440,提高 16 mm 屏幕 Tag 的像素尺寸与姿态估计稳定性。 +camera { + cameras { + id: "xiaozhao_mujoco_hand_cam" + mujoco { + world_id: "mujoco_world" + camera_name: "hand_cam" + render { + width: 1280 + height: 720 + fps: 30 + stream_mode: STREAM_MODE_RGBD + } + encoder { + width: 480 + height: 320 + fps: 30 + codec: "H264" + enable_stream_timestamp: true + buffer_size: 30 + } + consume_new_frame_only: false + viewer_pip { + enable: false + left: -10 + bottom: 10 + width: 320 + height: 180 + } + } + } + + cameras { + id: "xiaozhao_mujoco_external_touch_cam" + mujoco { + world_id: "mujoco_world" + camera_name: "external_touch_cam" + render { + width: 2560 + height: 1440 + fps: 30 + stream_mode: STREAM_MODE_RGBD + } + encoder { + width: 480 + height: 320 + fps: 30 + codec: "H264" + enable_stream_timestamp: true + buffer_size: 30 + } + consume_new_frame_only: false + viewer_pip { + enable: false + left: 10 + bottom: 10 + width: 320 + height: 180 + } + } + } +} diff --git a/cmvr-es/config/devices/dexhand/dexhand.pb.txt b/cmvr-es/config/devices/dexhand/dexhand.pb.txt index 1cd6e8f9..f2260be1 100644 --- a/cmvr-es/config/devices/dexhand/dexhand.pb.txt +++ b/cmvr-es/config/devices/dexhand/dexhand.pb.txt @@ -12,7 +12,7 @@ dexhand { } # LiteS001 uses the same six-axis OYMotion CAN control protocol as AP001, - # but it has no tactile sensor matrix. Add this id to device_manager.pb.txt + # but it has no tactile sensor matrix. Add this id to real_device_manager.pb.txt # when the LiteS001 is installed; do not enable it together with AP001 when # both entries address the same physical CAN hand id. dexhands { diff --git a/cmvr-es/config/devices/motor/xiaozhao_motors.pb.txt b/cmvr-es/config/devices/motor/xiaozhao_mujoco_motors.pb.txt similarity index 95% rename from cmvr-es/config/devices/motor/xiaozhao_motors.pb.txt rename to cmvr-es/config/devices/motor/xiaozhao_mujoco_motors.pb.txt index 834534dc..eb3b818e 100644 --- a/cmvr-es/config/devices/motor/xiaozhao_motors.pb.txt +++ b/cmvr-es/config/devices/motor/xiaozhao_mujoco_motors.pb.txt @@ -1,10 +1,10 @@ # MuJoCo 仿真限值:位置范围与 xiaozhao/config/joint_limits.csv 一致。 # URDF 的 velocity/effort 为占位值,速度和加速度在这里显式设置。 motor { - id: "xiaozhao_motors" + id: "xiaozhao_mujoco_motors" motor_groups { - id: "xiaozhao_left_arm_motors" + id: "xiaozhao_mujoco_left_arm_motors" bus_type: MOTOR_BUS_MUJOCO vendor: MOTOR_VENDOR_MUJOCO protocol: MOTOR_PROTOCOL_MUJOCO @@ -34,7 +34,7 @@ motor { } motor_groups { - id: "xiaozhao_right_arm_motors" + id: "xiaozhao_mujoco_right_arm_motors" bus_type: MOTOR_BUS_MUJOCO vendor: MOTOR_VENDOR_MUJOCO protocol: MOTOR_PROTOCOL_MUJOCO @@ -64,7 +64,7 @@ motor { } motor_groups { - id: "xiaozhao_head_motors" + id: "xiaozhao_mujoco_head_motors" bus_type: MOTOR_BUS_MUJOCO vendor: MOTOR_VENDOR_MUJOCO protocol: MOTOR_PROTOCOL_MUJOCO diff --git a/cmvr-es/config/devices/motor/xiaozhao_tchl_motors.pb.txt b/cmvr-es/config/devices/motor/xiaozhao_tchl_motors.pb.txt new file mode 100644 index 00000000..1f423512 --- /dev/null +++ b/cmvr-es/config/devices/motor/xiaozhao_tchl_motors.pb.txt @@ -0,0 +1,92 @@ +# 双臂共用一个 EtherCAT 主站。接线、编码器计数和减速比沿用 TCHL 双臂模板。 +# 启用前按实机核对从站顺序、关节方向、零位、编码器计数、减速比和限位。 +motor { + id: "xiaozhao_tchl_motors" + + motor_groups { + id: "xiaozhao_tchl_motors" + bus_type: MOTOR_BUS_ETHERCAT + vendor: MOTOR_VENDOR_TCHL + protocol: MOTOR_PROTOCOL_ETHERCAT_CIA402 + + ethercat { + master_index: 0 + cycle_us: 1000 + slave_op_timeout_ms: 12000 + slave_state_poll_period_ms: 10 + + cia402 { + state_transition_timeout_ms: 1200 + velocity_stop_timeout_ms: 2000 + status_poll_period_ms: 10 + stopped_velocity_tolerance_rad_s: 0.001 + } + + zero_calibration { + timeout_ms: 2000 + poll_period_ms: 10 + stable_sample_count: 5 + position_tolerance_counts: 10000 + stable_delta_counts: 1000 + } + + dc { + enable: false + } + + # 分线器位于位置 0。端口 1 接右臂,J1 到 J7 对应位置 1 到 7。 + slaves { motor_id: 1 alias: 0 position: 1 } + slaves { motor_id: 2 alias: 0 position: 2 } + slaves { motor_id: 3 alias: 0 position: 3 } + slaves { motor_id: 4 alias: 0 position: 4 } + slaves { motor_id: 5 alias: 0 position: 5 } + slaves { motor_id: 6 alias: 0 position: 6 } + slaves { motor_id: 7 alias: 0 position: 7 } + # 端口 2 接左臂,J1 到 J7 对应位置 8 到 14。 + slaves { motor_id: 8 alias: 0 position: 8 } + slaves { motor_id: 9 alias: 0 position: 9 } + slaves { motor_id: 10 alias: 0 position: 10 } + slaves { motor_id: 11 alias: 0 position: 11 } + slaves { motor_id: 12 alias: 0 position: 12 } + slaves { motor_id: 13 alias: 0 position: 13 } + slaves { motor_id: 14 alias: 0 position: 14 } + } + + # 初始软件限位沿用小赵模型。位置、速度和加速度分别使用 rad、rad/s 和 rad/s²。 + joint_limits { + enable: true + source: JOINT_LIMIT_SOURCE_CUSTOM + joints { joint_name: "joint1-right" q_lb: -3.14 q_ub: 3.14 qd: 1.0 qdd: 5.0 } + joints { joint_name: "joint2-right" q_lb: -1.57 q_ub: 1.57 qd: 1.0 qdd: 5.0 } + joints { joint_name: "joint3-right" q_lb: -3.14 q_ub: 3.14 qd: 1.0 qdd: 5.0 } + joints { joint_name: "joint4-right" q_lb: -2.35 q_ub: 0 qd: 1.0 qdd: 5.0 } + joints { joint_name: "joint5-right" q_lb: -3.14 q_ub: 3.14 qd: 1.0 qdd: 5.0 } + joints { joint_name: "joint6-right" q_lb: -0.45 q_ub: 0.785 qd: 1.0 qdd: 5.0 } + joints { joint_name: "joint7-right" q_lb: -1.05 q_ub: 1.05 qd: 1.0 qdd: 5.0 } + joints { joint_name: "joint1-left" q_lb: -3.14 q_ub: 3.14 qd: 1.0 qdd: 5.0 } + joints { joint_name: "joint2-left" q_lb: -1.57 q_ub: 1.57 qd: 1.0 qdd: 5.0 } + joints { joint_name: "joint3-left" q_lb: -3.14 q_ub: 3.14 qd: 1.0 qdd: 5.0 } + joints { joint_name: "joint4-left" q_lb: 0 q_ub: 2.35 qd: 1.0 qdd: 5.0 } + joints { joint_name: "joint5-left" q_lb: -3.14 q_ub: 3.14 qd: 1.0 qdd: 5.0 } + joints { joint_name: "joint6-left" q_lb: -0.785 q_ub: 0.45 qd: 1.0 qdd: 5.0 } + joints { joint_name: "joint7-left" q_lb: -1.05 q_ub: 1.05 qd: 1.0 qdd: 5.0 } + } + + motors { + motors { id: 1 joint_name: "joint1-right" encoder_counts_per_rev: 131072 gear_ratio: 101.0 } + motors { id: 2 joint_name: "joint2-right" encoder_counts_per_rev: 131072 gear_ratio: 101.0 } + motors { id: 3 joint_name: "joint3-right" encoder_counts_per_rev: 131072 gear_ratio: 101.0 } + motors { id: 4 joint_name: "joint4-right" encoder_counts_per_rev: 131072 gear_ratio: 101.0 } + motors { id: 5 joint_name: "joint5-right" encoder_counts_per_rev: 131072 gear_ratio: 101.0 } + motors { id: 6 joint_name: "joint6-right" encoder_counts_per_rev: 131072 gear_ratio: 101.0 } + motors { id: 7 joint_name: "joint7-right" encoder_counts_per_rev: 131072 gear_ratio: 101.0 } + motors { id: 8 joint_name: "joint1-left" encoder_counts_per_rev: 131072 gear_ratio: 101.0 } + motors { id: 9 joint_name: "joint2-left" encoder_counts_per_rev: 131072 gear_ratio: 101.0 } + motors { id: 10 joint_name: "joint3-left" encoder_counts_per_rev: 131072 gear_ratio: 101.0 } + motors { id: 11 joint_name: "joint4-left" encoder_counts_per_rev: 131072 gear_ratio: 101.0 } + motors { id: 12 joint_name: "joint5-left" encoder_counts_per_rev: 131072 gear_ratio: 101.0 } + motors { id: 13 joint_name: "joint6-left" encoder_counts_per_rev: 131072 gear_ratio: 101.0 } + motors { id: 14 joint_name: "joint7-left" encoder_counts_per_rev: 131072 gear_ratio: 101.0 } + } + } +} diff --git a/cmvr-es/config/manager/device_manager.pb.txt b/cmvr-es/config/manager/real_device_manager.pb.txt similarity index 74% rename from cmvr-es/config/manager/device_manager.pb.txt rename to cmvr-es/config/manager/real_device_manager.pb.txt index 6278ca46..5ad13e95 100644 --- a/cmvr-es/config/manager/device_manager.pb.txt +++ b/cmvr-es/config/manager/real_device_manager.pb.txt @@ -2,86 +2,15 @@ device_manager { name: "cmvr_es" version: "0.1" description: "cmvr edge system version 0.1" - # xiaozhao 双臂、颈部与右臂触屏仿真:先创建 world,再创建电机、机械臂、viewer 和传感器。 devices { - id: "mujoco_world" - type: DEVICE_TYPE_MUJOCO_WORLD - config_file: "devices/mujoco/xiaozhao_world.pb.txt" - enable: false - } - - devices { - id: "xiaozhao_left_arm_motors" - type: DEVICE_TYPE_MOTOR_SYSTEM - config_file: "devices/motor/xiaozhao_motors.pb.txt" - enable: false - } - - devices { - id: "xiaozhao_right_arm_motors" - type: DEVICE_TYPE_MOTOR_SYSTEM - config_file: "devices/motor/xiaozhao_motors.pb.txt" - enable: false - } - - devices { - id: "xiaozhao_head_motors" - type: DEVICE_TYPE_MOTOR_SYSTEM - config_file: "devices/motor/xiaozhao_motors.pb.txt" - enable: false - } - - devices { - id: "xiaozhao_left_arm" - type: DEVICE_TYPE_ROBOT_ARM - config_file: "devices/arm/xiaozhao_arm.pb.txt" - enable: false - } - - devices { - id: "xiaozhao_right_arm" - type: DEVICE_TYPE_ROBOT_ARM - config_file: "devices/arm/xiaozhao_arm.pb.txt" - enable: false - } - - devices { - id: "xiaozhao_head" - type: DEVICE_TYPE_ROBOT_ARM - config_file: "devices/arm/xiaozhao_head.pb.txt" - enable: false - } - - devices { - id: "right_arm_mujoco_motors" - type: DEVICE_TYPE_MOTOR_SYSTEM - config_file: "devices/motor/mujoco_motors.pb.txt" - enable: false - } - - devices { - id: "mujoco_right_arm" - type: DEVICE_TYPE_ROBOT_ARM - config_file: "devices/arm/arm_mujoco_qp.pb.txt" - enable: false - } - - devices { - id: "mujoco_viewer" - type: DEVICE_TYPE_MUJOCO_VIEWER - config_file: "devices/mujoco/mujoco_viewer.pb.txt" - enable: false - } - - devices { - id: "mujoco_hand_cam" + id: "head_carme" type: DEVICE_TYPE_CAMERA config_file: "devices/camera/xiaozhao_camera.pb.txt" enable: false } devices { - id: "mujoco_external_touch_cam" + id: "right_hand_carme" type: DEVICE_TYPE_CAMERA config_file: "devices/camera/xiaozhao_camera.pb.txt" enable: false @@ -94,13 +23,12 @@ device_manager { enable: false } - devices { - id: "left_hand_cam" - type: DEVICE_TYPE_CAMERA - config_file: "devices/camera/camera.pb.txt" - enable: false - } - + devices { + id: "left_hand_cam" + type: DEVICE_TYPE_CAMERA + config_file: "devices/camera/camera.pb.txt" + enable: false + } devices { id: "right_hand_ap001" @@ -130,13 +58,6 @@ device_manager { enable: false } - devices { - id: "mujoco_zero_touch" - type: DEVICE_TYPE_TOUCH - config_file: "devices/touch/touch.pb.txt" - enable: false - } - devices { id: "left_arm_can_motors" type: DEVICE_TYPE_MOTOR_SYSTEM @@ -277,30 +198,56 @@ device_manager { enable: false } + # 小赵实机双臂共用一个 TCHL EtherCAT 电机组。 + devices { + id: "xiaozhao_tchl_motors" + type: DEVICE_TYPE_MOTOR_SYSTEM + config_file: "devices/motor/xiaozhao_tchl_motors.pb.txt" + enable: true + } + + devices { + id: "xiaozhao_tchl_right_arm" + type: DEVICE_TYPE_ROBOT_ARM + config_file: "devices/arm/xiaozhao_tchl_arm.pb.txt" + enable: true + } + + devices { + id: "xiaozhao_tchl_left_arm" + type: DEVICE_TYPE_ROBOT_ARM + config_file: "devices/arm/xiaozhao_tchl_arm.pb.txt" + enable: true + } + devices { id: "tchl_single_axis" type: DEVICE_TYPE_MOTOR_SYSTEM config_file: "devices/motor/tchl_motors.pb.txt" enable: false } + devices { id: "lingkong_can_motors" type: DEVICE_TYPE_MOTOR_SYSTEM config_file: "devices/motor/lingkong_motors.pb.txt" enable: false } + devices { id: "lingkong_arm" type: DEVICE_TYPE_ROBOT_ARM config_file: "devices/arm/lingkong_arm.pb.txt" enable: false } + devices { id: "tchl_joint_motors" type: DEVICE_TYPE_MOTOR_SYSTEM config_file: "devices/motor/tchl_multi_motors.pb.txt" enable: false } + devices { id: "tchl_arm" type: DEVICE_TYPE_ROBOT_ARM @@ -315,12 +262,14 @@ device_manager { config_file: "devices/motor/lingkong_mixed_motors.pb.txt" enable: false } + devices { id: "lingkong_mixed_arm" type: DEVICE_TYPE_ROBOT_ARM config_file: "devices/arm/lingkong_mixed_arm.pb.txt" enable: false } + devices { id: "usb_head" type: DEVICE_TYPE_BIO_HEAD_ROBOT diff --git a/cmvr-es/config/manager/sim_device_manager.pb.txt b/cmvr-es/config/manager/sim_device_manager.pb.txt new file mode 100644 index 00000000..41edb54a --- /dev/null +++ b/cmvr-es/config/manager/sim_device_manager.pb.txt @@ -0,0 +1,96 @@ +device_manager { + name: "cmvr_es" + version: "0.1" + description: "cmvr edge system version 0.1" + # xiaozhao 双臂、颈部与右臂触屏仿真:先创建 world,再创建电机、机械臂、viewer 和传感器。 + devices { + id: "mujoco_world" + type: DEVICE_TYPE_MUJOCO_WORLD + config_file: "devices/mujoco/xiaozhao_world.pb.txt" + enable: false + } + + devices { + id: "xiaozhao_mujoco_left_arm_motors" + type: DEVICE_TYPE_MOTOR_SYSTEM + config_file: "devices/motor/xiaozhao_mujoco_motors.pb.txt" + enable: false + } + + devices { + id: "xiaozhao_mujoco_right_arm_motors" + type: DEVICE_TYPE_MOTOR_SYSTEM + config_file: "devices/motor/xiaozhao_mujoco_motors.pb.txt" + enable: false + } + + devices { + id: "xiaozhao_mujoco_head_motors" + type: DEVICE_TYPE_MOTOR_SYSTEM + config_file: "devices/motor/xiaozhao_mujoco_motors.pb.txt" + enable: false + } + + devices { + id: "xiaozhao_mujoco_left_arm" + type: DEVICE_TYPE_ROBOT_ARM + config_file: "devices/arm/xiaozhao_mujoco_arm.pb.txt" + enable: false + } + + devices { + id: "xiaozhao_mujoco_right_arm" + type: DEVICE_TYPE_ROBOT_ARM + config_file: "devices/arm/xiaozhao_mujoco_arm.pb.txt" + enable: false + } + + devices { + id: "xiaozhao_mujoco_head" + type: DEVICE_TYPE_ROBOT_ARM + config_file: "devices/arm/xiaozhao_mujoco_head.pb.txt" + enable: false + } + + devices { + id: "right_arm_mujoco_motors" + type: DEVICE_TYPE_MOTOR_SYSTEM + config_file: "devices/motor/mujoco_motors.pb.txt" + enable: false + } + + devices { + id: "mujoco_right_arm" + type: DEVICE_TYPE_ROBOT_ARM + config_file: "devices/arm/arm_mujoco_qp.pb.txt" + enable: false + } + + devices { + id: "mujoco_viewer" + type: DEVICE_TYPE_MUJOCO_VIEWER + config_file: "devices/mujoco/mujoco_viewer.pb.txt" + enable: false + } + + devices { + id: "xiaozhao_mujoco_hand_cam" + type: DEVICE_TYPE_CAMERA + config_file: "devices/camera/xiaozhao_mujoco_camera.pb.txt" + enable: false + } + + devices { + id: "xiaozhao_mujoco_external_touch_cam" + type: DEVICE_TYPE_CAMERA + config_file: "devices/camera/xiaozhao_mujoco_camera.pb.txt" + enable: false + } + + devices { + id: "mujoco_zero_touch" + type: DEVICE_TYPE_TOUCH + config_file: "devices/touch/touch.pb.txt" + enable: false + } +} diff --git a/cmvr-es/config/manager/task_manager.pb.txt b/cmvr-es/config/manager/task_manager.pb.txt index a95113c1..b9c0796f 100644 --- a/cmvr-es/config/manager/task_manager.pb.txt +++ b/cmvr-es/config/manager/task_manager.pb.txt @@ -6,7 +6,7 @@ task_manager { run_mode: TASK_RUN_MODE_PERIODIC_STEP control_period_s: 0.001 config_file: "tasks/touch_screen_task/touch_screen_task_xiaozhao_mujoco.pb.txt" - enable: true + enable: false } tasks { id: "grpc_server" @@ -23,7 +23,7 @@ task_manager { config_file: "tasks/self_collision_task/self_collision_task.pb.txt" enable: false } - # 小赵 MuJoCo 当前仅启用右臂实时自碰撞监控。 + # 小赵 MuJoCo 实时自碰撞监控。 tasks { id: "xiaozhao_left_arm_self_collision" type: TASK_TYPE_SELF_COLLISION @@ -38,7 +38,7 @@ task_manager { run_mode: TASK_RUN_MODE_PERIODIC_STEP control_period_s: 0.002 config_file: "tasks/self_collision_task/self_collision_task_xiaozhao_right.pb.txt" - enable: true + enable: false } tasks { id: "quic_edge" diff --git a/cmvr-es/config/tasks/self_collision_task/self_collision_task_xiaozhao_left.pb.txt b/cmvr-es/config/tasks/self_collision_task/self_collision_task_xiaozhao_left.pb.txt index fc092a6c..0e48e426 100644 --- a/cmvr-es/config/tasks/self_collision_task/self_collision_task_xiaozhao_left.pb.txt +++ b/cmvr-es/config/tasks/self_collision_task/self_collision_task_xiaozhao_left.pb.txt @@ -1,7 +1,7 @@ # 小赵左臂独立自碰撞检测:仅本臂 + 固定 base,排除另一臂与活动头部。 self_collision_task { id: "xiaozhao_left_arm_self_collision" - arm_id: "xiaozhao_left_arm" + arm_id: "xiaozhao_mujoco_left_arm" checker { urdf_path: "model/xiaozhao/collision/xiaozhao_collision.urdf" diff --git a/cmvr-es/config/tasks/self_collision_task/self_collision_task_xiaozhao_right.pb.txt b/cmvr-es/config/tasks/self_collision_task/self_collision_task_xiaozhao_right.pb.txt index c2f0f679..798d4d57 100644 --- a/cmvr-es/config/tasks/self_collision_task/self_collision_task_xiaozhao_right.pb.txt +++ b/cmvr-es/config/tasks/self_collision_task/self_collision_task_xiaozhao_right.pb.txt @@ -1,7 +1,7 @@ # 小赵右臂独立自碰撞检测:仅本臂 + 固定 base,排除另一臂与活动头部。 self_collision_task { id: "xiaozhao_right_arm_self_collision" - arm_id: "xiaozhao_right_arm" + arm_id: "xiaozhao_mujoco_right_arm" checker { urdf_path: "model/xiaozhao/collision/xiaozhao_collision.urdf" diff --git a/cmvr-es/config/tasks/touch_screen_task/touch_screen_task_xiaozhao_mujoco.pb.txt b/cmvr-es/config/tasks/touch_screen_task/touch_screen_task_xiaozhao_mujoco.pb.txt index f9f31711..f66ed3ef 100644 --- a/cmvr-es/config/tasks/touch_screen_task/touch_screen_task_xiaozhao_mujoco.pb.txt +++ b/cmvr-es/config/tasks/touch_screen_task/touch_screen_task_xiaozhao_mujoco.pb.txt @@ -7,13 +7,13 @@ touch_screen_task { debug_coordinate_axis_length_m: 0.02 devices { - arm_id: "xiaozhao_right_arm" - head_id: "xiaozhao_head" + arm_id: "xiaozhao_mujoco_right_arm" + head_id: "xiaozhao_mujoco_head" # ZeroSimTouch 始终返回零力,用于测试无接触时的前进限距和回撤流程。 touch_id: "mujoco_zero_touch" # 手部相机和外部相机的 DeviceManager ID。 - camera_id: "mujoco_hand_cam" - external_camera_id: "mujoco_external_touch_cam" + camera_id: "xiaozhao_mujoco_hand_cam" + external_camera_id: "xiaozhao_mujoco_external_touch_cam" } # 任务 init() 时同步执行一次头部 MoveJ,到位后任务才进入 IDLE。 diff --git a/cmvr-es/devices/agv/seer_robokit/README.md b/cmvr-es/devices/agv/seer_robokit/README.md index 3e1134d1..65a9cf77 100644 --- a/cmvr-es/devices/agv/seer_robokit/README.md +++ b/cmvr-es/devices/agv/seer_robokit/README.md @@ -38,7 +38,7 @@ - 设备配置: [`../../../config/devices/agv/agv.pb.txt`](../../../config/devices/agv/agv.pb.txt) - DeviceManager 配置: - [`../../../config/manager/device_manager.pb.txt`](../../../config/manager/device_manager.pb.txt) + [`../../../config/manager/real_device_manager.pb.txt`](../../../config/manager/real_device_manager.pb.txt) - gRPC API: [`../../../../protos/cmvr/api/agv_service.proto`](../../../../protos/cmvr/api/agv_service.proto)、 [`../../../../protos/cmvr/api/agv_command.proto`](../../../../protos/cmvr/api/agv_command.proto)、 @@ -72,7 +72,7 @@ agv { } ``` -还要在 `device_manager.pb.txt` 中确认同一个设备 id,并在完成现场安全检查后把 +还要在 `real_device_manager.pb.txt` 中确认同一个设备 id,并在完成现场安全检查后把 `enable` 改为 `true`。源码默认配置故意保持关闭。 ```textproto diff --git a/cmvr-es/devices/camera/realsense_camera/src/realsense_camera_test.cpp b/cmvr-es/devices/camera/realsense_camera/src/realsense_camera_test.cpp index d66d9495..7b0b3530 100644 --- a/cmvr-es/devices/camera/realsense_camera/src/realsense_camera_test.cpp +++ b/cmvr-es/devices/camera/realsense_camera/src/realsense_camera_test.cpp @@ -19,7 +19,7 @@ DeviceManager& getTestDeviceManager() { static bool initialized = [] { cmvr::ConfigHelper::setConfigRootFromFile("cmvr-es/config/cmvr_es.pb.txt"); cmvr::config::DeviceManagerRootConfig root_cfg; - if (!cmvr::ConfigHelper::loadConfigFile("manager/device_manager.pb.txt", root_cfg)) { + if (!cmvr::ConfigHelper::loadConfigFile("manager/real_device_manager.pb.txt", root_cfg)) { throw std::runtime_error("Failed to load test DeviceManagerConfig"); } DeviceManager::getInstance(root_cfg.device_manager()); diff --git a/cmvr-es/task/touch_screen_task/src/touch_screen_task_test.cpp b/cmvr-es/task/touch_screen_task/src/touch_screen_task_test.cpp index 582e34ff..c8ee4a4b 100644 --- a/cmvr-es/task/touch_screen_task/src/touch_screen_task_test.cpp +++ b/cmvr-es/task/touch_screen_task/src/touch_screen_task_test.cpp @@ -397,7 +397,7 @@ cmvr::device::DeviceManager& getTestDeviceManager() { static bool initialized = [] { cmvr::ConfigHelper::setConfigRootFromFile("cmvr-es/config/cmvr_es.pb.txt"); cmvr::config::DeviceManagerRootConfig root_cfg; - if (!cmvr::ConfigHelper::loadConfigFile("manager/device_manager.pb.txt", root_cfg)) { + if (!cmvr::ConfigHelper::loadConfigFile("manager/real_device_manager.pb.txt", root_cfg)) { throw std::runtime_error("Failed to load test DeviceManagerConfig"); } cmvr::device::DeviceManager::getInstance(root_cfg.device_manager()); @@ -1137,7 +1137,7 @@ TEST(TouchScreenTaskTest, MotorArmConfigurationsSupportMoveP) { ASSERT_FALSE(project_root.empty()); for (const auto* file_name : {"arm.pb.txt", "arm_qp.pb.txt", "arm_mujoco.pb.txt", "arm_mujoco_qp.pb.txt", "ethercat_dual_arm.pb.txt", - "arm_gen2_mujoco.pb.txt", "xiaozhao_arm.pb.txt"}) { + "arm_gen2_mujoco.pb.txt", "xiaozhao_mujoco_arm.pb.txt"}) { SCOPED_TRACE(file_name); cmvr::config::ArmRootConfig root; ASSERT_TRUE(ProtoMessageIo::getProtoFromAsciiFile( @@ -1354,7 +1354,7 @@ TEST(TouchScreenTaskTest, RunEyeToHandTouchInMujoco) { const auto touch_config = loadMujocoTouchConfig(project_root); cmvr::config::DeviceManagerRootConfig runtime_devices; ASSERT_TRUE(cmvr::ConfigHelper::loadConfigFile( - "manager/device_manager.pb.txt", runtime_devices)); + "manager/sim_device_manager.pb.txt", runtime_devices)); const auto& entries = runtime_devices.device_manager().devices(); const auto arm_entry = std::find_if(entries.begin(), entries.end(), [](const auto& entry) { return entry.id() == "mujoco_right_arm"; diff --git a/cmvr-es/test/mujoco_manual_ui_test.cpp b/cmvr-es/test/mujoco_manual_ui_test.cpp index bbdf21d5..88bb1397 100644 --- a/cmvr-es/test/mujoco_manual_ui_test.cpp +++ b/cmvr-es/test/mujoco_manual_ui_test.cpp @@ -190,6 +190,9 @@ TEST(MujocoManualUiTest, RunMujocoArm) const std::string arm_id = manualArmId(); auto arm = devices.getDevice(arm_id); auto mujoco_camera = devices.getDevice("mujoco_hand_cam"); + if (!mujoco_camera) { + mujoco_camera = devices.getDevice("xiaozhao_mujoco_hand_cam"); + } auto viewer = runtime.mujocoViewer("mujoco_viewer"); auto mujoco_world = cmvr::simulate::MujocoWorldDevice::worldFor("mujoco_world"); diff --git a/docs/ethercat_motor_tutorial.md b/docs/ethercat_motor_tutorial.md index 8f5b5870..5b6f62b5 100644 --- a/docs/ethercat_motor_tutorial.md +++ b/docs/ethercat_motor_tutorial.md @@ -141,7 +141,7 @@ motor { 修改: ```text -cmvr-es/config/manager/device_manager.pb.txt +cmvr-es/config/manager/real_device_manager.pb.txt ``` 加入: diff --git a/model/README.md b/model/README.md index 2ae6aaa9..8da27969 100644 --- a/model/README.md +++ b/model/README.md @@ -2,11 +2,14 @@ ## 启动 xiaozhao MuJoCo 仿真 -默认设备配置 `cmvr-es/config/manager/device_manager.pb.txt` 已选择 +仿真设备清单 `cmvr-es/config/manager/sim_device_manager.pb.txt` 中的 MuJoCo world 使用 `devices/mujoco/xiaozhao_world.pb.txt`,加载 `model/xiaozhao/xml/scene.xml`。 场景包含机器人、地面、灯光、触控测试屏幕、手部/外部相机和共 17 个位置执行器(双臂 14 个、颈部 3 个),仿真步长为 1 ms。 -已启用 MuJoCo world、viewer、xiaozhao 双臂与颈部电机、左右臂、头部、两路仿真相机、 -零力触觉设备、右臂触屏任务和 gRPC 控制服务。原 xiaoyan 的电机、机械臂及真实硬件保持关闭。 +切换到该仿真时,启用 MuJoCo world、viewer、小赵的双臂与颈部电机、左右臂、头部、两路仿真相机、 +零力触觉设备、右臂触屏任务和 gRPC 控制服务。 +在运行所用的 `cmvr_es.pb.txt` 中,将 `device_manager_config_file` 设为 +`"manager/sim_device_manager.pb.txt"`。源码安装时使用 `cmvr-es/config/cmvr_es.pb.txt`, +已有安装使用 `output/bin/config/cmvr_es.pb.txt`。 xiaozhao 的双臂关节名为 `joint1-left`…`joint7-left` 和 `joint1-right`…`joint7-right`,不能直接复用原模型的机械臂配置。 @@ -28,9 +31,9 @@ J2 `[-1.57, 0.44]`、J3 `[-0.44, 0.44]` rad;首关节已补偿现有基座绕 模型现有 17 个活动关节及对应的位置执行器,限位 CSV 包含双臂和颈部。 `actuators.xml` 中的 `neck-joint1_pos`~`neck-joint3_pos` 追加在双臂执行器之后, 保持双臂索引不变;颈部初始 `kp=80`、`dampratio=1`,控制量为弧度,范围与 URDF 限位一致。 -颈部已通过 `xiaozhao_head_motors` 接入 CMVR,并注册为 3DOF 机械臂 `xiaozhao_head`, -使用 `devices/arm/xiaozhao_head.pb.txt`,复用 MoveJ 关节控制,无需配置运动学求解器。 -头部接管控制后,通过 ArmService 的 `xiaozhao_head` 控制三轴目标角。 +颈部已通过 `xiaozhao_mujoco_head_motors` 接入 CMVR,并注册为 3DOF 机械臂 `xiaozhao_mujoco_head`, +使用 `devices/arm/xiaozhao_mujoco_head.pb.txt`,复用 MoveJ 关节控制,无需配置运动学求解器。 +头部接管控制后,通过 ArmService 的 `xiaozhao_mujoco_head` 控制三轴目标角。 颈部真正的零位(`qpos=0`)是直立的;Control 面板中的数值是执行器目标角度。 头部与下段颈部的凸包在内部机构处重叠,曾把零目标下的 J3 推到约 19.62°。 颈部仅排除 `neck_Link1`/`neck_Link3` 这一对内部碰撞,保留其他碰撞、关节原点、轴向及限位。 @@ -85,12 +88,12 @@ blender --background --factory-startup --threads 4 --python-exit-code 1 \ 相机相对 Base/世界的外参随脖子关节位置变化。 加载 `scene.xml` 即可显示整套场景,模型文件也已同步到 `output/bin/model/xiaozhao`。 小赵使用独立配置 `cmvr-es/config/tasks/touch_screen_task/touch_screen_task_xiaozhao_mujoco.pb.txt`, -绑定 `xiaozhao_right_arm`、`mujoco_hand_cam`、`mujoco_external_touch_cam` 和 `mujoco_zero_touch`。 -两路相机使用 `devices/camera/xiaozhao_camera.pb.txt`,手相机原图为 1280 × 720, +绑定 `xiaozhao_mujoco_right_arm`、`xiaozhao_mujoco_hand_cam`、`xiaozhao_mujoco_external_touch_cam` 和 `mujoco_zero_touch`。 +两路相机使用 `devices/camera/xiaozhao_mujoco_camera.pb.txt`,手相机原图为 1280 × 720, 头部相机为 2560 × 1440;旧居中屏幕布局下,16 mm 屏幕 Tag 在头部相机的 720p 图中 存在明显姿态误估,因此保留 1440p。旧布局测得的屏幕 Tag 姿态误差约 0.26°、 G/H 相对位置误差约 1.3 mm,不作为当前 S05 参考布局的精度结论。 -触控配置中的 `devices.head_id` 指向 `xiaozhao_head`;`head_initialization.enable: true` +触控配置中的 `devices.head_id` 指向 `xiaozhao_mujoco_head`;`head_initialization.enable: true` 使任务在初始化期间执行一次头部 MoveJ,三轴 `neck-joint1/2/3` 的初始角设为 `[0, -0.1, 0.1]` rad, 速度 `0.25 rad/s`、加速度 `0.5 rad/s²`。可直接修改 `head_initialization.joint_positions`。 头部到位后任务才进入 IDLE,随后等待 gRPC `HlcService.touch(u, v)`;每次 touch 不重复移动头部。 @@ -106,7 +109,7 @@ G/H 相对位置误差约 1.3 mm,不作为当前 S05 参考布局的精度结 对应物理手部正立、TCP +Z 沿屏幕向上;不能仅按 body 坐标将 rz 改成 0。 触屏测试前,先将右臂 MoveJ 到新配置 `initialization.joint_positions` 给出的初始位,再获取 -`mujoco_hand_cam` 的 RGB 图像并点击屏幕上的目标。`u/v` 使用原始图像的 1280 × 720 像素坐标; +`xiaozhao_mujoco_hand_cam` 的 RGB 图像并点击屏幕上的目标。`u/v` 使用原始图像的 1280 × 720 像素坐标; 上位机 RGB Image 页面会按原图尺寸换算点击坐标。不要使用外部相机或编码视频的像素直接调用 touch。 每次 touch 请求还会确认初始位,点击后不要手动改变机械臂姿态。 `initialization.motion_method` 统一选择三个回初始位开关(`before_start`、`after_finish`、`after_failure`)启用时调用的关节运动。 @@ -138,13 +141,13 @@ TCP 目标停在屏幕前 5 cm,沿 Tool -Y 以 0.02 m/s 前进最多 2 cm, 以下本次变更,无需重新编译: ```bash -cp cmvr-es/config/manager/device_manager.pb.txt output/bin/config/manager/ +cp cmvr-es/config/manager/sim_device_manager.pb.txt output/bin/config/manager/ cp cmvr-es/config/manager/task_manager.pb.txt output/bin/config/manager/ cp cmvr-es/config/devices/mujoco/xiaozhao_world.pb.txt output/bin/config/devices/mujoco/ -cp cmvr-es/config/devices/motor/xiaozhao_motors.pb.txt output/bin/config/devices/motor/ -cp cmvr-es/config/devices/arm/xiaozhao_arm.pb.txt output/bin/config/devices/arm/ -cp cmvr-es/config/devices/arm/xiaozhao_head.pb.txt output/bin/config/devices/arm/ -cp cmvr-es/config/devices/camera/xiaozhao_camera.pb.txt output/bin/config/devices/camera/ +cp cmvr-es/config/devices/motor/xiaozhao_mujoco_motors.pb.txt output/bin/config/devices/motor/ +cp cmvr-es/config/devices/arm/xiaozhao_mujoco_arm.pb.txt output/bin/config/devices/arm/ +cp cmvr-es/config/devices/arm/xiaozhao_mujoco_head.pb.txt output/bin/config/devices/arm/ +cp cmvr-es/config/devices/camera/xiaozhao_mujoco_camera.pb.txt output/bin/config/devices/camera/ cp cmvr-es/config/tasks/touch_screen_task/touch_screen_task_xiaozhao_mujoco.pb.txt output/bin/config/tasks/touch_screen_task/ cp cmvr-es/config/tasks/self_collision_task/self_collision_task_xiaozhao_{left,right}.pb.txt output/bin/config/tasks/self_collision_task/ cp -a model/xiaozhao output/bin/model/ @@ -155,13 +158,13 @@ MuJoCo 窗口关闭后程序退出。修改配置后需要重启程序才能生 ### 控制左右臂 -机械臂配置为 `cmvr-es/config/devices/arm/xiaozhao_arm.pb.txt`, -电机配置为 `cmvr-es/config/devices/motor/xiaozhao_motors.pb.txt`。 +机械臂配置为 `cmvr-es/config/devices/arm/xiaozhao_mujoco_arm.pb.txt`, +电机配置为 `cmvr-es/config/devices/motor/xiaozhao_mujoco_motors.pb.txt`。 | 机械臂设备 ID | 电机组 / motor_system_id | 关节顺序 | 默认 TCP | | --- | --- | --- | --- | -| `xiaozhao_left_arm` | `xiaozhao_left_arm_motors` | `joint1-left`…`joint7-left` | `tcp-left` | -| `xiaozhao_right_arm` | `xiaozhao_right_arm_motors` | `joint1-right`…`joint7-right` | `tcp-right` | +| `xiaozhao_mujoco_left_arm` | `xiaozhao_mujoco_left_arm_motors` | `joint1-left`…`joint7-left` | `tcp-left` | +| `xiaozhao_mujoco_right_arm` | `xiaozhao_mujoco_right_arm_motors` | `joint1-right`…`joint7-right` | `tcp-right` | 两臂均使用 QP 逆运动学,基准坐标系为 `base_link`,法兰仍为 `link7-left/right`。 TCP 与各自第七连杆的坐标轴方向一致,仅作固定平移:左侧相对 `link7-left` @@ -200,8 +203,8 @@ MuJoCo 触控当前启用右臂自碰撞监控,左臂的独立监控任务已 | 机械臂 | J1~J7,单位 ° | | --- | --- | -| `xiaozhao_left_arm` | `90, -30, 0, -90, 0, -30, -15` | -| `xiaozhao_right_arm` | `-90, 30, 0, 90, 0, 30, 15` | +| `xiaozhao_mujoco_left_arm` | `90, -30, 0, -90, 0, -30, -15` | +| `xiaozhao_mujoco_right_arm` | `-90, 30, 0, 90, 0, 30, 15` | 使用 `ARM_FRAME_BASE`,基准为 `base_link`,TCP 分别为 `tcp-left` / `tcp-right`。 调用 `getPose` 时,`base_link` 填 `base_link`,`ee_link` 按左右臂填 `tcp-left` 或 `tcp-right`。 diff --git a/model/xiaozhao/collision/README.md b/model/xiaozhao/collision/README.md index e9892ea0..4b660f16 100644 --- a/model/xiaozhao/collision/README.md +++ b/model/xiaozhao/collision/README.md @@ -111,12 +111,12 @@ Python 分块测试与 C++ collision checker 测试覆盖倒角分层、层间 ## 在线任务状态 -两套配置分别绑定 `xiaozhao_left_arm`、`xiaozhao_right_arm`: +两套配置分别绑定 `xiaozhao_mujoco_left_arm`、`xiaozhao_mujoco_right_arm`: - `cmvr-es/config/tasks/self_collision_task/self_collision_task_xiaozhao_left.pb.txt` - `cmvr-es/config/tasks/self_collision_task/self_collision_task_xiaozhao_right.pb.txt` -`cmvr-es/config/manager/task_manager.pb.txt` 仅启用右臂周期任务,左臂实时监控已关闭。 +在 `cmvr-es/config/manager/task_manager.pb.txt` 中可按需启用左右臂的周期监控任务。 右臂简化碰撞体间距进入 20 mm 时预警,达到 5 mm 时触发右臂保护停止。 两臂各自忽略同侧 `link5 ↔ link7`。当前右臂触控初姿的 J4 为 `-1.46915 rad`, 该姿态下 `link5-right ↔ link7-right` 的原始 STL 表面间距约为 8.9 mm。 diff --git a/scripts/test_wait_network_devices.py b/scripts/test_wait_network_devices.py index 1542792c..bf38425b 100644 --- a/scripts/test_wait_network_devices.py +++ b/scripts/test_wait_network_devices.py @@ -15,7 +15,12 @@ class ReadinessTest(unittest.TestCase): self.root = Path(self.temp.name) (self.root / "manager").mkdir() (self.root / "devices").mkdir() - (self.root / "manager/device_manager.pb.txt").write_text('''device_manager { + self.app_config = self.root / "cmvr_es.pb.txt" + self.real_manager = self.root / "manager/real_devices.pb.txt" + self.app_config.write_text('''cmvr_es { + device_manager_config_file: "manager/real_devices.pb.txt" + }''') + self.real_manager.write_text('''device_manager { devices { id: "aubo_arm" type: DEVICE_TYPE_ROBOT_ARM config_file: "devices/arm.pb.txt" enable: true } devices { id: "src1100" type: DEVICE_TYPE_AGV config_file: "devices/agv.pb.txt" enable: true } devices { id: "disabled" type: DEVICE_TYPE_AGV config_file: "not-present" enable: false } @@ -39,9 +44,16 @@ class ReadinessTest(unittest.TestCase): self.assertEqual([p.port for p in values], [30004, 19204, 19205, 19206, 19207, 19301]) self.assertEqual(values[1].host, "192.168.192.5") + def test_switching_manager_configuration_changes_endpoints(self): + (self.root / "manager/sim_devices.pb.txt").write_text("device_manager {}") + self.assertTrue(readiness.endpoints(self.root)) + self.app_config.write_text('''cmvr_es { + device_manager_config_file: "manager/sim_devices.pb.txt" + }''') + self.assertEqual(readiness.endpoints(self.root), []) + def test_disabled_devices_do_not_block(self): - manager = self.root / "manager/device_manager.pb.txt" - manager.write_text(manager.read_text().replace("enable: true", "enable: false")) + self.real_manager.write_text(self.real_manager.read_text().replace("enable: true", "enable: false")) self.assertEqual(readiness.endpoints(self.root), []) def test_disabled_push_not_required(self): @@ -62,8 +74,7 @@ class ReadinessTest(unittest.TestCase): self.assertEqual(readiness.scalar(values[0], "id"), "x}#//{") def test_path_escape_rejected(self): - path = self.root / "manager/device_manager.pb.txt" - path.write_text(path.read_text().replace("devices/arm.pb.txt", "../elsewhere")) + self.real_manager.write_text(self.real_manager.read_text().replace("devices/arm.pb.txt", "../elsewhere")) with self.assertRaises(ValueError): readiness.endpoints(self.root) diff --git a/scripts/wait_network_devices.py b/scripts/wait_network_devices.py index d62eeffb..4f05e9f4 100755 --- a/scripts/wait_network_devices.py +++ b/scripts/wait_network_devices.py @@ -67,7 +67,12 @@ def scalar(text, key, default=None): def endpoints(config_dir): root = Path(config_dir).resolve() - manager = (root / "manager/device_manager.pb.txt").read_text(encoding="utf-8") + app_config = (root / "cmvr_es.pb.txt").read_text(encoding="utf-8") + app = next(blocks(app_config, "cmvr_es"), "") + manager_file = scalar(app, "device_manager_config_file") + if not manager_file: + raise ValueError("missing device_manager_config_file in cmvr_es.pb.txt") + manager = (root / manager_file).read_text(encoding="utf-8") result = [] for device in blocks(manager, "devices"): if scalar(device, "enable", "false") != "true":