feat(mujoco): integrate xiaozhao dual-arm and touch simulation

Update xiaozhao geometry, base axes, TCPs, neck joints and actuators.
Add mesh generation tools, simplified visuals, screen and hand tags,
and hand/head camera attachments.

Configure both arms and enable the right-arm visual touch workflow with
updated calibration, a camera-visible initial pose and higher-resolution
external perception. Keep touch tests distance-limited with ZeroSimTouch.

Release MuJoCo joint state control on torqueOff, latch the disabled state
until torqueOn, and add regression coverage for actuator and fallback modes.

Validation: isolated device/task initialization, camera acquisition and
AprilTag pose checks passed. Full visual-servo motion was not validated.
This commit is contained in:
lgv 2026-11-17 17:26:05 +08:00
parent aabc5a9fef
commit 90bae95654
74 changed files with 1958645 additions and 1451497 deletions

View File

@ -0,0 +1,304 @@
# xiaozhao 双臂 MuJoCo 控制,所有关节位置使用 rad。
# TCP 与第七连杆同向,局部偏移左 (0.007, 0.23, -0.045) m、右 (0.007, -0.23, -0.045) m;尚未配置 moveP 避障路径规划。
arm {
robot_arms {
id: "xiaozhao_left_arm"
motor {
motor_system_id: "xiaozhao_left_arm_motors"
motor_group_ids: "xiaozhao_left_arm_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: -2.355 q_ub: 0 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_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_right_arm"
motor {
motor_system_id: "xiaozhao_right_arm_motors"
motor_group_ids: "xiaozhao_right_arm_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: 0 q_ub: 2.355 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_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
}
}
}
}
}
}

View File

@ -0,0 +1,63 @@
# xiaozhao 触屏仿真相机。手相机保持 1280x720 点击像素坐标。
# 头部相机使用 2560x1440,提高 16 mm 屏幕 Tag 的像素尺寸与姿态估计稳定性。
camera {
cameras {
id: "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: "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
}
}
}
}

View File

@ -0,0 +1,65 @@
# MuJoCo 仿真限值:位置范围与 xiaozhao/config/joint_limits.csv 一致。
# URDF 的 velocity/effort 为占位值,速度和加速度在这里显式设置。
motor {
id: "xiaozhao_motors"
motor_groups {
id: "xiaozhao_left_arm_motors"
bus_type: MOTOR_BUS_MUJOCO
vendor: MOTOR_VENDOR_MUJOCO
protocol: MOTOR_PROTOCOL_MUJOCO
mujoco {
world_id: "mujoco_world"
}
joint_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: -2.355 q_ub: 0 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-left" }
motors { id: 2 joint_name: "joint2-left" }
motors { id: 3 joint_name: "joint3-left" }
motors { id: 4 joint_name: "joint4-left" }
motors { id: 5 joint_name: "joint5-left" }
motors { id: 6 joint_name: "joint6-left" }
motors { id: 7 joint_name: "joint7-left" }
}
}
motor_groups {
id: "xiaozhao_right_arm_motors"
bus_type: MOTOR_BUS_MUJOCO
vendor: MOTOR_VENDOR_MUJOCO
protocol: MOTOR_PROTOCOL_MUJOCO
mujoco {
world_id: "mujoco_world"
}
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: 0 q_ub: 2.355 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 }
}
motors {
motors { id: 1 joint_name: "joint1-right" }
motors { id: 2 joint_name: "joint2-right" }
motors { id: 3 joint_name: "joint3-right" }
motors { id: 4 joint_name: "joint4-right" }
motors { id: 5 joint_name: "joint5-right" }
motors { id: 6 joint_name: "joint6-right" }
motors { id: 7 joint_name: "joint7-right" }
}
}
}

View File

@ -0,0 +1,7 @@
worlds {
id: "mujoco_world"
model_path: "model/xiaozhao/xml/scene.xml"
timestep_s: 0.001
realtime_factor: 1.0
require_actuator: true
}

View File

@ -2,10 +2,39 @@ 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/right_arm_eye_to_hand_world.pb.txt"
config_file: "devices/mujoco/xiaozhao_world.pb.txt"
enable: true
}
devices {
id: "xiaozhao_left_arm_motors"
type: DEVICE_TYPE_MOTOR_SYSTEM
config_file: "devices/motor/xiaozhao_motors.pb.txt"
enable: true
}
devices {
id: "xiaozhao_right_arm_motors"
type: DEVICE_TYPE_MOTOR_SYSTEM
config_file: "devices/motor/xiaozhao_motors.pb.txt"
enable: true
}
devices {
id: "xiaozhao_left_arm"
type: DEVICE_TYPE_ROBOT_ARM
config_file: "devices/arm/xiaozhao_arm.pb.txt"
enable: true
}
devices {
id: "xiaozhao_right_arm"
type: DEVICE_TYPE_ROBOT_ARM
config_file: "devices/arm/xiaozhao_arm.pb.txt"
enable: true
}
@ -13,14 +42,14 @@ device_manager {
id: "right_arm_mujoco_motors"
type: DEVICE_TYPE_MOTOR_SYSTEM
config_file: "devices/motor/mujoco_motors.pb.txt"
enable: true
enable: false
}
devices {
id: "mujoco_right_arm"
type: DEVICE_TYPE_ROBOT_ARM
config_file: "devices/arm/arm_mujoco_qp.pb.txt"
enable: true
enable: false
}
devices {
@ -33,14 +62,14 @@ device_manager {
devices {
id: "mujoco_hand_cam"
type: DEVICE_TYPE_CAMERA
config_file: "devices/camera/camera.pb.txt"
config_file: "devices/camera/xiaozhao_camera.pb.txt"
enable: true
}
devices {
id: "mujoco_external_touch_cam"
type: DEVICE_TYPE_CAMERA
config_file: "devices/camera/camera.pb.txt"
config_file: "devices/camera/xiaozhao_camera.pb.txt"
enable: true
}

View File

@ -1,10 +1,11 @@
task_manager {
# xiaozhao 右臂触屏流程仿真;任务启动后等待 gRPC touch 请求,不自动运动。
tasks {
id: "touch_screen"
type: TASK_TYPE_TOUCH_SCREEN
run_mode: TASK_RUN_MODE_PERIODIC_STEP
control_period_s: 0.001
config_file: "tasks/touch_screen_task/touch_screen_task_mujoco.pb.txt"
config_file: "tasks/touch_screen_task/touch_screen_task_xiaozhao_mujoco.pb.txt"
enable: true
}
tasks {

View File

@ -36,15 +36,16 @@ touch_screen_task {
}
perception {
# 屏幕 Tag G 与手部 Tag H 的 ID 和物理边长,单位为米。
# 屏幕 Tag G 与手部 Tag H 的 ID 和黑框外缘边长(不含外围白边),单位为米。
# 当前 MuJoCo 标签整张含白边为 20 mm,黑框外缘为 16 mm。
tags {
screen {
id: 1
size_m: 0.03
size_m: 0.016
}
hand {
id: 0
size_m: 0.03
size_m: 0.016
}
}
# 手部相机:用于点击目标点和手部目标跟踪。

View File

@ -0,0 +1,148 @@
# xiaozhao 右臂视觉触屏流程仿真;ZeroSimTouch 不模拟真实接触力。
touch_screen_task {
id: "touch_screen"
# 是否在外部相机编码后的 gRPC 视频流中绘制 G/H 坐标系,仅影响显示帧;未配置时默认开启。
debug_draw_coordinate_frames: true
# G/H 坐标轴长度,单位为米。
debug_coordinate_axis_length_m: 0.02
devices {
arm_id: "xiaozhao_right_arm"
# ZeroSimTouch 始终返回零力,用于测试无接触时的前进限距和回撤流程。
touch_id: "mujoco_zero_touch"
# 手部相机和外部相机的 DeviceManager ID。
camera_id: "mujoco_hand_cam"
external_camera_id: "mujoco_external_touch_cam"
}
initialization {
# 开始前使用 MoveJ 回到初始关节位置。
before_start: true
# 小赵尚未配置 motion.joint_path,关闭依赖 MoveP 的完成/失败回位。
# 每次测试前仍通过上面的 MoveJ 回到初始位。
after_finish: false
after_failure: false
# 正前方屏幕起姿:TCP 约 (0.50738, -0.12160, 0.43024) m,头部三关节保持零位。
# 此姿态下手相机识别屏幕 Tag,头部相机同时识别屏幕/手部 Tag。
joint_positions { joint_name: "joint1-right" rad: 1.8647731978 }
joint_positions { joint_name: "joint2-right" rad: 0.9322349780 }
joint_positions { joint_name: "joint3-right" rad: -0.3888895185 }
joint_positions { joint_name: "joint4-right" rad: 1.7262026729 }
joint_positions { joint_name: "joint5-right" rad: -1.3492569035 }
joint_positions { joint_name: "joint6-right" rad: -0.2361915889 }
joint_positions { joint_name: "joint7-right" rad: -0.9300000000 }
velocity: 0.5
acceleration: 1.0
# 当前关节位置误差小于该值时跳过初始位置回位,单位为弧度。
skip_position_tolerance_rad: 0.001
# 当前关节速度小于该值时才允许跳过初始位置回位,单位为弧度/秒。
skip_velocity_tolerance_rad_s: 0.01
}
perception {
# 屏幕 Tag G 与手部 Tag H 的 ID 和黑框外缘边长(不含外围白边),单位为米。
# 当前 MuJoCo 标签整张含白边为 20 mm,黑框外缘为 16 mm。
tags {
screen {
id: 1
size_m: 0.016
}
hand {
id: 0
size_m: 0.016
}
}
# 手部相机:用于点击目标点和手部目标跟踪。
hand_camera {
depth_policy: TOUCH_SCREEN_DEPTH_POLICY_NONE
target_point_method: TOUCH_SCREEN_TARGET_POINT_METHOD_TAG_PLANE
}
}
approach {
# 暂不使用 MoveP 预接近;从初始位直接进入 PBVS 视觉对齐。
enable: false
velocity: 0.65 # rad/s
acceleration: 1.7 # rad/s^2
jerk: 30.0 # rad/s^3
timeout_s: 10.0
# TCP 沿屏幕外法向的最小距离,仅检查 TCP,不覆盖整臂碰撞。
minimum_clearance_m: 0.01
}
alignment {
calibration {
# 手部 Tag H 到 TCP P 的固定安装变换 T_H_P,来自 xiaozhao MJCF。
hand_tag_to_tcp {
m00: 1.0 m01: 0.0 m02: 0.0 m03: -0.0275
m10: 0.0 m11: 0.0 m12: -1.0 m13: 0.081
m20: 0.0 m21: 1.0 m22: 0.0 m23: -0.1354
m30: 0.0 m31: 0.0 m32: 0.0 m33: 1.0
}
}
pbvs {
position_gain { x: 2.0 y: 2.0 z: 1.5 }
rotation_gain { x: 1.5 y: 1.5 z: 1.5 }
vmax6 { x: 0.03 y: 0.03 z: 0.02 rx: 0.15 ry: 0.15 rz: 0.15 }
amax6 { x: 0.10 y: 0.10 z: 0.10 rx: 0.50 ry: 0.50 rz: 0.50 }
twist_filter_alpha: 1.0
}
target {
# Hand Tag H 相对于屏幕 Tag G 的目标姿态,单位为弧度。
# rx、ry、rz 表示绕固定 G 坐标轴 X、Y、Z 依次旋转。
# 旋转组合为 R_G_H = Rz(rz) * Ry(ry) * Rx(rx)。
# PBVS 会结合上面的 T_H_P 将该目标转换为 TCP P 的目标姿态。
hand_orientation_G {
rx: 0.0
ry: 0.0
# 使用检测得到的 G:屏幕纹理使 G 相对 MJCF body 绕 Z 旋转 pi,H 与 body 同向。
# 因此这里的 pi 对应物理手部正立、TCP +Z 向上;设为 0 反而会翻转手腕。
rz: 3.141592653589793
}
# 点击目标点到 TCP 预对齐位置的偏移,表达在 G 坐标系,单位为米。
position_offset_G {
x: 0.0
y: 0.0
z: 0.05
}
mode: TOUCH_SCREEN_ALIGN_MODE_RX_RY_AND_POSITION
}
error_threshold {
x: 0.005
y: 0.005
z: 0.005
rx: 0.08726646259971647
ry: 0.08726646259971647
rz: 0.08726646259971647
}
stable_frames: 5
# 对齐及到位暂停各自的超时时间(秒);暂停从对齐成功时重新计时。
timeout_s: 30.0
# 到位后暂停;暂停超时结束任务,after_failure 为 true 时尝试回初始位置。
pause_when_reached: false
}
touch {
speed_l {
twist_tool { x: 0.0 y: -0.02 z: 0.0 rx: 0.0 ry: 0.0 rz: 0.0 }
acceleration: 0.10
linear_jerk: 1.0 # m/s^3,不超过小赵 SpeedL 的 5.0 上限。
# 零力不会触发接触;达到此距离后回撤,最终状态为 TOUCH_FORWARD_TIMEOUT。
max_distance_m: 0.02
}
tactile {
criterion: TOUCH_SCREEN_TACTILE_CRITERION_FZ
force_threshold: 0.1 # N
}
dwell_time_s: 0.0
}
retract {
twist_tool { x: 0.0 y: 0.02 z: 0.0 rx: 0.0 ry: 0.0 rz: 0.0 }
acceleration: 0.10
linear_jerk: 1.0 # m/s^3
# TCP 后退目标距离,单位为米。
distance_m: 0.02
}
}

View File

@ -172,7 +172,7 @@ private:
// Joint-motion position-limit tolerance and post-trajectory settling criteria. These defaults preserve the
// historical behavior when the optional arm configuration fields are absent.
double move_j_joint_limit_tolerance_rad_{1e-5};
double move_j_joint_limit_tolerance_rad_{1e-4};
double move_j_settle_timeout_s_{2.0};
double move_j_position_tolerance_rad_{2e-3};
double move_j_velocity_tolerance_rad_s_{2e-2};

View File

@ -13,3 +13,8 @@ target_link_libraries(mujoco_motor_driver
add_library(cmvr_es::device::mujoco_motor_driver ALIAS mujoco_motor_driver)
install(TARGETS mujoco_motor_driver LIBRARY DESTINATION lib)
add_executable(mujoco_motor_test src/mujoco_motor_test.cpp)
target_link_libraries(mujoco_motor_test PRIVATE
cmvr_es::device::mujoco_motor_driver
gtest gtest_main pthread)

View File

@ -59,7 +59,7 @@ public:
std::vector<double>& velocities);
private:
bool holdPosition_();
bool holdPosition_(bool enable_torque = false);
double clampQ_(double q) const;
double clampQd_(double qd) const;
std::shared_ptr<simulate::MujocoWorld> worldLocked_() const;
@ -70,6 +70,8 @@ private:
double limit_qdd_upper_{0.0};
double limit_qdd_lower_{0.0};
bool initialized_{false};
// Preserve commands after init, but require torqueOn after an explicit torqueOff.
bool torque_disabled_{false};
};
} // namespace cmvr::device

View File

@ -58,15 +58,19 @@ msgs::RunMode MujocoMotor::getMode()
bool MujocoMotor::torqueOn()
{
return holdPosition_();
return holdPosition_(true);
}
bool MujocoMotor::torqueOff()
{
const bool ok = holdPosition_();
std::scoped_lock lock(mtx_);
const auto world = worldLocked_();
if (!world || !world->releaseJointControl(info_.joint_name)) {
return false;
}
torque_disabled_ = true;
mode_ = msgs::RUN_MODE_UNSPECIFIED;
return ok;
return true;
}
bool MujocoMotor::brakeRelease()
@ -111,17 +115,22 @@ void MujocoMotor::setLimitQdd(const double u_qdd, const double l_qdd)
info_.limit_qdd = std::max(limit_qdd_upper_, std::abs(limit_qdd_lower_));
}
bool MujocoMotor::holdPosition_()
bool MujocoMotor::holdPosition_(const bool enable_torque)
{
std::scoped_lock lock(mtx_);
// A late stop/trajectory cleanup must not re-lock a released joint.
if (torque_disabled_ && !enable_torque) {
return true;
}
const auto world = worldLocked_();
double q = 0.0;
if (!world || !world->getJointPosition(info_.joint_name, q)) {
if (!world || !world->getJointPosition(info_.joint_name, q) ||
!world->setJointTargetState(info_.joint_name, q, 0.0)) {
return false;
}
std::scoped_lock lock(mtx_);
target_q_ = q;
mode_ = msgs::RUN_MODE_CYCLIC_SYNC_POSITION;
world->setJointTargetState(info_.joint_name, q, 0.0);
torque_disabled_ = false;
return true;
}
@ -132,7 +141,7 @@ bool MujocoMotor::commandProfilePosition(const double target_q,
(void)max_qdd;
std::scoped_lock lock(mtx_);
const auto world = worldLocked_();
if (!world) {
if (!world || torque_disabled_) {
return false;
}
mode_ = msgs::RUN_MODE_PROFILE_POSITION;
@ -146,7 +155,7 @@ bool MujocoMotor::commandProfileVelocity(const double target_qd, const double ma
(void)max_qdd;
std::scoped_lock lock(mtx_);
const auto world = worldLocked_();
if (!world) {
if (!world || torque_disabled_) {
return false;
}
mode_ = msgs::RUN_MODE_PROFILE_VELOCITY;
@ -158,7 +167,7 @@ bool MujocoMotor::commandCyclicPosition(const double target_q,
{
std::scoped_lock lock(mtx_);
const auto world = worldLocked_();
if (!world) {
if (!world || torque_disabled_) {
return false;
}
mode_ = msgs::RUN_MODE_CYCLIC_SYNC_POSITION;
@ -170,7 +179,7 @@ bool MujocoMotor::commandCyclicVelocity(const double target_qd)
{
std::scoped_lock lock(mtx_);
const auto world = worldLocked_();
if (!world) {
if (!world || torque_disabled_) {
return false;
}
mode_ = msgs::RUN_MODE_CYCLIC_SYNC_VELOCITY;
@ -239,21 +248,15 @@ bool MujocoMotor::commandCyclicPositionsAtomic(
}
std::shared_ptr<simulate::MujocoWorld> world;
std::vector<std::string> joint_names;
std::vector<double> clamped_positions;
std::vector<double> clamped_velocities;
joint_names.reserve(motors.size());
clamped_positions.reserve(motors.size());
clamped_velocities.reserve(motors.size());
std::vector<MujocoMotor*> selected;
selected.reserve(motors.size());
for (std::size_t i = 0; i < motors.size(); ++i) {
const auto motor = std::dynamic_pointer_cast<MujocoMotor>(motors[i]);
if (!motor) {
if (!motor || !std::isfinite(positions[i]) || !std::isfinite(velocities[i]) ||
std::find(selected.begin(), selected.end(), motor.get()) != selected.end()) {
return false;
}
std::scoped_lock lock(motor->mtx_);
auto motor_world = motor->worldLocked_();
const auto motor_world = motor->worldLocked_();
if (!motor_world) {
return false;
}
@ -263,12 +266,33 @@ bool MujocoMotor::commandCyclicPositionsAtomic(
CMVR_LOG(ERROR) << "[MujocoMotor] batch target motors belong to different worlds";
return false;
}
selected.push_back(motor.get());
}
// Keep torqueOff and the entire batch commit mutually exclusive, using
// the same lock order as atomic velocity commands.
auto lock_order = selected;
std::sort(lock_order.begin(), lock_order.end(), std::less<MujocoMotor*>{});
std::vector<std::unique_lock<std::mutex>> locks;
locks.reserve(lock_order.size());
for (auto* motor : lock_order) {
locks.emplace_back(motor->mtx_);
}
std::vector<std::string> joint_names;
std::vector<double> clamped_positions;
std::vector<double> clamped_velocities;
joint_names.reserve(motors.size());
clamped_positions.reserve(motors.size());
clamped_velocities.reserve(motors.size());
for (std::size_t i = 0; i < selected.size(); ++i) {
const auto* motor = selected[i];
if (!motor->initialized_ || motor->torque_disabled_) {
return false;
}
joint_names.push_back(motor->info_.joint_name);
clamped_positions.push_back(motor->clampQ_(positions[i]));
clamped_velocities.push_back(motor->clampQd_(velocities[i]));
}
if (!world || !world->setJointTargetStates(joint_names, clamped_positions, clamped_velocities)) {
if (world) {
CMVR_LOG(ERROR) << "[MujocoMotor] failed to set batch joint targets: " << world->lastError();
@ -276,14 +300,9 @@ bool MujocoMotor::commandCyclicPositionsAtomic(
return false;
}
for (std::size_t i = 0; i < motors.size(); ++i) {
const auto motor = std::dynamic_pointer_cast<MujocoMotor>(motors[i]);
if (!motor) {
return false;
}
std::scoped_lock lock(motor->mtx_);
motor->target_q_ = clamped_positions[i];
motor->mode_ = msgs::RUN_MODE_CYCLIC_SYNC_POSITION;
for (std::size_t i = 0; i < selected.size(); ++i) {
selected[i]->target_q_ = clamped_positions[i];
selected[i]->mode_ = msgs::RUN_MODE_CYCLIC_SYNC_POSITION;
}
return true;
}
@ -324,7 +343,7 @@ bool MujocoMotor::commandCyclicVelocitiesAtomic(
names.reserve(selected.size());
clamped_velocities.reserve(selected.size());
for (std::size_t i = 0; i < selected.size(); ++i) {
if (!selected[i]->initialized_) {
if (!selected[i]->initialized_ || selected[i]->torque_disabled_) {
return false;
}
names.push_back(selected[i]->info_.joint_name);

View File

@ -0,0 +1,229 @@
#include "motor/drivers/mujoco/include/mujoco_motor.h"
#include <chrono>
#include <cstdlib>
#include <filesystem>
#include <fstream>
#include <memory>
#include <mutex>
#include <thread>
#include <unistd.h>
#include <gtest/gtest.h>
namespace cmvr::device {
namespace {
class MujocoMotorReleaseTest : public ::testing::TestWithParam<bool> {
protected:
void SetUp() override
{
char filename[] = "/tmp/cmvr_mujoco_motor_test_XXXXXX";
const int fd = mkstemp(filename);
ASSERT_GE(fd, 0);
close(fd);
model_path_ = filename;
std::ofstream model_file(model_path_);
ASSERT_TRUE(model_file.good());
model_file << R"(<mujoco model="motor_release_test">
<option timestep="0.001" gravity="0 0 0" integrator="implicitfast"/>
<worldbody>
<body pos="0 0 0">
<joint name="left_joint" type="slide" axis="1 0 0"/>
<geom type="sphere" size="0.1" mass="1" contype="0" conaffinity="0"/>
</body>
<body pos="0 1 0">
<joint name="right_joint" type="slide" axis="1 0 0"/>
<geom type="sphere" size="0.1" mass="1" contype="0" conaffinity="0"/>
</body>
</worldbody>
)";
if (GetParam()) {
model_file << R"( <actuator>
<position name="left_pos" joint="left_joint" kp="100" kv="2"/>
<position name="right_pos" joint="right_joint" kp="100" kv="2"/>
</actuator>
)";
}
model_file << "</mujoco>\n";
model_file.close();
ASSERT_FALSE(model_file.fail());
world_ = std::make_shared<simulate::MujocoWorld>();
simulate::MujocoWorld::Options options;
options.model_path = model_path_.string();
options.realtime_factor = 10.0;
options.require_actuator = GetParam();
options.allow_state_control_fallback = !GetParam();
ASSERT_TRUE(world_->load(options)) << world_->lastError();
left_ = std::make_shared<MujocoMotor>("left_joint", world_, 1);
right_ = std::make_shared<MujocoMotor>("right_joint", world_, 2);
ASSERT_TRUE(left_->init());
ASSERT_TRUE(right_->init());
}
void TearDown() override
{
if (world_) {
world_->stop();
}
left_.reset();
right_.reset();
world_.reset();
if (!model_path_.empty()) {
std::error_code error;
std::filesystem::remove(model_path_, error);
}
}
// Stop between phases so torqueOn/quickStop capture a deterministic current
// position. Every phase still runs the real MujocoWorld simulation thread.
bool simulateFor(const double left_force,
const double right_force,
const double duration_s = 0.2)
{
double end_time;
{
std::lock_guard<std::mutex> lock(world_->mutex());
auto* data = world_->data();
const auto* model = world_->model();
const int left_id = mj_name2id(model, mjOBJ_JOINT, "left_joint");
const int right_id = mj_name2id(model, mjOBJ_JOINT, "right_joint");
data->qfrc_applied[model->jnt_dofadr[left_id]] = left_force;
data->qfrc_applied[model->jnt_dofadr[right_id]] = right_force;
end_time = data->time + duration_s;
}
if (!world_->start()) {
return false;
}
bool completed = false;
const auto deadline = std::chrono::steady_clock::now() + std::chrono::seconds(3);
while (std::chrono::steady_clock::now() < deadline) {
{
std::lock_guard<std::mutex> lock(world_->mutex());
completed = world_->data()->time >= end_time;
}
if (completed) {
break;
}
std::this_thread::sleep_for(std::chrono::milliseconds(1));
}
world_->stop();
return completed;
}
std::filesystem::path model_path_;
std::shared_ptr<simulate::MujocoWorld> world_;
std::shared_ptr<MujocoMotor> left_;
std::shared_ptr<MujocoMotor> right_;
};
TEST_P(MujocoMotorReleaseTest, InitializedJointsRespondToExternalForce)
{
const double left_start = left_->getQ();
const double right_start = right_->getQ();
ASSERT_TRUE(simulateFor(5.0, -5.0));
EXPECT_GT(left_->getQ() - left_start, 0.01);
EXPECT_LT(right_->getQ() - right_start, -0.01);
}
TEST_P(MujocoMotorReleaseTest, TorqueOnHoldsAgainstExternalForce)
{
ASSERT_TRUE(simulateFor(5.0, -5.0));
ASSERT_TRUE(left_->torqueOn());
ASSERT_TRUE(right_->torqueOn());
const double left_hold = left_->getQ();
const double right_hold = right_->getQ();
ASSERT_TRUE(simulateFor(-5.0, 5.0));
EXPECT_NEAR(left_->getQ(), left_hold, 1e-9);
EXPECT_NEAR(right_->getQ(), right_hold, 1e-9);
EXPECT_NEAR(left_->getQd(), 0.0, 1e-9);
EXPECT_NEAR(right_->getQd(), 0.0, 1e-9);
}
TEST_P(MujocoMotorReleaseTest, TorqueOffReleasesOnlySelectedJointAndReenableHoldsNewPosition)
{
ASSERT_TRUE(left_->torqueOn());
ASSERT_TRUE(right_->torqueOn());
ASSERT_TRUE(left_->commandCyclicPosition(0.2));
ASSERT_TRUE(right_->commandCyclicPosition(-0.15));
ASSERT_TRUE(simulateFor(5.0, -5.0));
ASSERT_NEAR(left_->getQ(), 0.2, 1e-9);
ASSERT_NEAR(right_->getQ(), -0.15, 1e-9);
ASSERT_TRUE(left_->torqueOff());
EXPECT_EQ(left_->getMode(), msgs::RUN_MODE_UNSPECIFIED);
// Release restores the initial position-following actuator behavior. A
// position actuator can still damp motion; zero actuator force is not the
// contract. External forces must move qpos instead of it being overwritten.
ASSERT_TRUE(simulateFor(5.0, -5.0));
const double released_position = left_->getQ();
EXPECT_GT(released_position - 0.2, 0.01);
EXPECT_NEAR(right_->getQ(), -0.15, 1e-9);
ASSERT_TRUE(left_->torqueOn());
ASSERT_TRUE(simulateFor(-5.0, 5.0));
EXPECT_NEAR(left_->getQ(), released_position, 1e-9);
EXPECT_NEAR(left_->getQd(), 0.0, 1e-9);
EXPECT_NEAR(right_->getQ(), -0.15, 1e-9);
}
TEST_P(MujocoMotorReleaseTest, QuickStopStillHoldsCurrentPosition)
{
ASSERT_TRUE(left_->commandCyclicPosition(0.2));
ASSERT_TRUE(simulateFor(0.0, 0.0));
ASSERT_TRUE(left_->commandCyclicVelocity(0.1));
ASSERT_TRUE(simulateFor(5.0, 0.0));
ASSERT_TRUE(left_->quickStop());
const double stopped_position = left_->getQ();
ASSERT_TRUE(simulateFor(-5.0, 0.0));
EXPECT_NEAR(left_->getQ(), stopped_position, 1e-9);
EXPECT_NEAR(left_->getQd(), 0.0, 1e-9);
}
TEST_P(MujocoMotorReleaseTest, TorqueOffRejectsLateCommandsAndOnlyTorqueOnReenables)
{
ASSERT_TRUE(left_->commandCyclicPosition(0.2));
ASSERT_TRUE(right_->commandCyclicPosition(-0.15));
ASSERT_TRUE(simulateFor(0.0, 0.0));
ASSERT_TRUE(left_->torqueOff());
EXPECT_FALSE(left_->commandProfilePosition(0.5));
EXPECT_FALSE(left_->commandProfileVelocity(1.0));
EXPECT_FALSE(left_->commandCyclicPosition(0.5));
EXPECT_FALSE(left_->commandCyclicVelocity(1.0));
// The enabled joint deliberately comes first: validation must reject the
// whole batch without partially changing its target or control mode.
const std::vector<std::shared_ptr<AbstractMotor>> motors{right_, left_};
EXPECT_FALSE(MujocoMotor::commandCyclicPositionsAtomic(
motors, {0.7, 0.5}, {0.0, 0.0}));
EXPECT_FALSE(MujocoMotor::commandCyclicVelocitiesAtomic(motors, {1.0, 1.0}));
ASSERT_TRUE(left_->setMode(msgs::RUN_MODE_CYCLIC_SYNC_POSITION));
ASSERT_TRUE(left_->quickStop());
ASSERT_TRUE(simulateFor(5.0, -5.0));
const double released_position = left_->getQ();
EXPECT_GT(released_position - 0.2, 0.01);
EXPECT_NEAR(right_->getQ(), -0.15, 1e-9);
ASSERT_TRUE(left_->torqueOn());
ASSERT_TRUE(simulateFor(-5.0, 5.0));
EXPECT_NEAR(left_->getQ(), released_position, 1e-9);
ASSERT_TRUE(left_->commandCyclicPosition(0.4));
ASSERT_TRUE(simulateFor(-5.0, 5.0));
EXPECT_NEAR(left_->getQ(), 0.4, 1e-9);
}
INSTANTIATE_TEST_SUITE_P(
ActuatorAndStateFallback,
MujocoMotorReleaseTest,
::testing::Bool(),
[](const ::testing::TestParamInfo<bool>& info) {
return info.param ? "PositionActuators" : "NoActuatorFallback";
});
} // namespace
} // namespace cmvr::device

View File

@ -66,6 +66,9 @@ public:
std::vector<double>& velocities) const;
bool setJointPosition(const std::string& joint_name, double position);
bool setJointVelocity(const std::string& joint_name, double velocity);
// Restore the uncommanded behavior from load/reset without changing qpos/qvel.
// Position servos follow feedback; their configured damping remains active.
bool releaseJointControl(const std::string& joint_name);
bool setJointTargetPosition(const std::string& joint_name, double position);
bool setJointTargetState(const std::string& joint_name,
double position,

View File

@ -366,6 +366,24 @@ bool MujocoWorld::setJointVelocity(const std::string& joint_name, const double v
return true;
}
bool MujocoWorld::releaseJointControl(const std::string& joint_name)
{
std::lock_guard<std::mutex> lock(mutex_);
JointHandle* joint = nullptr;
if (!findJointLocked(joint_name, joint)) {
return false;
}
joint->position_reference = data_->qpos[joint->qpos_adr];
joint->target_position = joint->position_reference;
joint->target_velocity = 0.0;
joint->mode = TargetMode::HoldPosition;
if (joint->actuator_id >= 0) {
data_->ctrl[joint->actuator_id] =
clampControl(model_, joint->actuator_id, joint->position_reference);
}
return true;
}
bool MujocoWorld::setJointTargetPosition(const std::string& joint_name, const double position)
{
std::lock_guard<std::mutex> lock(mutex_);

View File

@ -752,8 +752,8 @@ TEST(TouchScreenTaskTest, ConfigFilesUseStructuredSchema) {
EXPECT_DOUBLE_EQ(config.alignment().target().position_offset_g().z(), 0.05);
EXPECT_EQ(tags.screen().id(), 1);
EXPECT_EQ(tags.hand().id(), 0);
EXPECT_DOUBLE_EQ(tags.screen().size_m(), 0.03);
EXPECT_DOUBLE_EQ(tags.hand().size_m(), 0.03);
EXPECT_DOUBLE_EQ(tags.screen().size_m(), 0.016);
EXPECT_DOUBLE_EQ(tags.hand().size_m(), 0.016);
EXPECT_EQ(config.devices().camera_id(), "mujoco_hand_cam");
EXPECT_EQ(config.devices().external_camera_id(), "mujoco_external_touch_cam");
EXPECT_DOUBLE_EQ(orientation.rx(), 0.0);

View File

@ -1,5 +1,206 @@
# 模型工具
## 启动 xiaozhao MuJoCo 仿真
默认设备配置 `cmvr-es/config/manager/device_manager.pb.txt` 已选择
`devices/mujoco/xiaozhao_world.pb.txt`,加载 `model/xiaozhao/xml/scene.xml`。
场景包含机器人、地面、灯光、触控测试屏幕、手部/外部相机和共 17 个位置执行器(双臂 14 个、颈部 3 个),仿真步长为 1 ms。
已启用 MuJoCo world、viewer、xiaozhao 两组电机、左右臂、两路仿真相机、
零力触觉设备、右臂触屏任务和 gRPC 控制服务。原 xiaoyan 的电机、机械臂及真实硬件保持关闭。
xiaozhao 的双臂关节名为 `joint1-left`…`joint7-left` 和
`joint1-right`…`joint7-right`,不能直接复用原模型的机械臂配置。
模型最初基于 urdf6 导入的 18 个 STL,颈部现已同步 `model/00 0930Body-urdf7.SLDASM`;其中
`link7-right.STL` 已替换为完整 `link7-left.STL` 关于局部 XY 平面的镜像(Z 坐标取反),左右手各使用一份完整 STL。
两侧手部 STL 已从各 268,502 面减至 21,479 面,减少约 92%;URDF 保持原路径即可读取轻量手部。
`neck_Link1`~`neck_Link3`、`neck-joint1`~`neck-joint3` 已按 urdf7 更新。双臂的关节定义、
限位、TCP 和惯量保持原配置;J3/J4 仅调整 visual/collision origin,适配新网格的局部坐标。
颈部沿用源 URDF 的 `0 0 1` 轴向及限位:J1 `[-1.57, 1.57]`、
J2 `[-1.57, 0.44]`、J3 `[-0.44, 0.44]` rad;首关节已补偿现有基座绕 Z 轴的 +90° 变换。
颈部 J3 相对 `neck_Link2` 的 origin 更新为 `(0, 0.0035, -0.035) m`,安装旋转保持原值。
头部网格、质心和相机的局部坐标随 `neck_Link3` 原点调整,均平移 `(0, 0.015, 0.0035) m`;
颈部网格及轻量外观同步更新,头部零位外形和相机安装窗口保持一致。
模型现有 17 个活动关节及对应的位置执行器,限位 CSV 包含双臂和颈部。
`actuators.xml` 中的 `neck-joint1_pos`~`neck-joint3_pos` 追加在双臂执行器之后,
保持双臂索引不变;颈部初始 `kp=80`、`dampratio=1`,控制量为弧度,范围与 URDF 限位一致。
可通过 MuJoCo 的 Control 面板调整三个颈部目标角;颈部尚未接入 CMVR 电机设备配置。
颈部真正的零位(`qpos=0`)是直立的;Control 面板中的数值是执行器目标角度。
头部与下段颈部的凸包在内部机构处重叠,曾把零目标下的 J3 推到约 19.62°。
颈部仅排除 `neck_Link1`/`neck_Link3` 这一对内部碰撞,保留其他碰撞、关节原点、轴向及限位。
此规则及原有两条肩部排除统一放在 `xml/contact_exclusions.xml`,由 `scene.xml` 加载一次;
从 URDF 重新生成机器人 XML 不会覆盖碰撞配置。修改排除规则后重新加载 `scene.xml` 即可。
原生 MuJoCo 3.3.7 验证:零目标运行 10 秒后 J3 约 −0.001°、J2 约 +0.087°;
三组非零目标及回零的最大稳态误差约 0.168°,未产生仿真警告。
`base_link.obj` 是当前基座 STL 的无损转换;`link7-left.obj`、`link7-right.obj`
保留减面前的高精度几何,继续用于 MuJoCo 手部碰撞及轻量网格的重建源。
右手 visual/collision 保留既有 `Rx(pi)` 安装旋转;旧 `hand-right-mirrored` 资产文件保留,但不再加载或叠加。
只重新生成轻量手部(需要 Blender 4.5):
```bash
blender --background --factory-startup --threads 4 --python-exit-code 1 \
--python model/xiaozhao/simplify_visual_meshes.py -- --hands-only
```
省略 `-- --hands-only` 可重新生成全部轻量外观。两种模式均从高精度 OBJ 生成左手,
再精确镜像生成右手,同步两侧 STL 与 visual;不会对轻量手部重复减面。
当前 18 个网格的高精度源共 1,904,402 面,URDF 引用的 STL 共 1,410,356 面,
MuJoCo 外观共 538,499 面。手部全部顶点和面中心的双向检查最大距离约 0.871 mm,
不代表连续全表面的严格误差上界;更多参数见 `xiaozhao/meshes/visual/README.md`。
触控场景拆分为 `model/xiaozhao/xml/` 下的三个模块:`touch_scene.xml`、
`hand_camera.xml` 和 `head_camera.xml`。
`touch_scene.xml` 定义 50 × 30 cm 屏幕和屏幕 AprilTag ID 1;
Tag 位于机器人正面看向屏幕时的右上角,含白边距上边、右边各 18.75 mm,
中心为屏幕局部坐标 `(-0.22125, 0.0151, 0.12125) m`。
机器人正前方为 Base 的 `+X`。屏幕中心为世界坐标 `(0.60, 0, 0.38) m`,
屏幕正面朝 `−X`(朝向机器人),可直接在该文件调整位置。
`hand_camera.xml` 定义右手相机 `hand_cam` 和手部 AprilTag ID 0,
由生成脚本挂到 `link7-right`,随右手运动;
触控末端 TCP 仍使用已有的直径 5 mm 红球。
手部相机光心位于右 J7 的 `(0.0325, -0.12605, 0.036) m`,在 STL 自带
相机前面板的指定窗口外 0.5 mm;镜头沿 J7 的 `−Y` 观察,图像上方为 J7 的 `+Z`。
使用现有 STL 外壳,仅附加薄镜片标记,不再叠加黑色相机盒。
`head_camera.xml` 定义头部相机,沿用 `external_touch_cam` 名称,
由生成脚本挂到 `neck_Link3`,随脖子三个关节运动。光心相对 `neck_Link3` 为
`(0.0325, 0.10347742, 0.08039297) m`,在头部指定窗口外 0.5 mm;
零位下朝 Base 的 `+X` 前方、向下约 30.9°。该相机不再固定于世界坐标系,
相机相对 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,
头部相机为 2560 × 1440;16 mm 屏幕 Tag 在头部相机的 720p 图中存在明显姿态误估,
该初姿的 1440p 图经项目实际检测器验证,屏幕 Tag 姿态误差约 0.26°,G/H 相对位置误差约 1.3 mm。
任务启动后等待 gRPC `HlcService.touch(u, v)` 请求,不会自动运动。
手部 Tag 位于相机背板左端(右 J7 的 `+X` 一侧),中心为 `(0.0345, -0.0946, 0.036) m`,
正面朝右 J7 的 `+Y`,背面距背板 0.1 mm,并向外侧避开中央支架。
屏幕和手部 Tag 的黑框外缘边长均为 16 mm,整张含白边为 20 mm;
新旧触屏仿真配置中两处 `size_m` 均为 `0.016`,不包含外围白边。
小赵配置的 `hand_tag_to_tcp` 使用 H 坐标下平移 `(-0.0275, 0.081, -0.1354) m`、
旋转 `Rx(pi/2)`,与当前模型一致。
`hand_orientation_G` 使用实际检测到的 Tag 坐标系:屏幕纹理使检测 G 相对其 MJCF body
绕 Z 旋转 180°,而检测 H 与手部 Tag body 同向。因此目标 `(rx, ry, rz)=(0, 0, pi)`
对应物理手部正立、TCP +Z 向上;不能仅按 body 坐标将 rz 改成 0。
触屏测试前,先将右臂 MoveJ 到新配置 `initialization.joint_positions` 给出的初始位,再获取
`mujoco_hand_cam` 的 RGB 图像并点击屏幕上的目标。`u/v` 使用原始图像的 1280 × 720 像素坐标;
上位机 RGB Image 页面会按原图尺寸换算点击坐标。不要使用外部相机或编码视频的像素直接调用 touch。
每次 touch 请求还会用 MoveJ 确认初始位,点击后不要手动改变机械臂姿态。
右臂初始角按 J1~J7 顺序为 `[1.8647731978, 0.9322349780, -0.3888895185, 1.7262026729,
-1.3492569035, -0.2361915889, -0.93]` rad;MoveJ 使用速度 `0.5 rad/s`、加速度 `1.0 rad/s²`。
头部三关节保持零位。该姿态下可先选手相机原始图约 `(u=750, v=635)` 的屏幕区域做小范围测试,
不要直接把右上角 Tag 中心作为第一个触碰目标。初姿、这个点击点对应的 5 cm 预对齐目标及
再前进 2 cm 的位置已做离线运动学检查;这不等同于完成整条视觉伺服流程的动态验证。
零位到初姿的 21 个关节插值样本未出现新增接触对,但当前模型仍有肩、颈及腕部内部接触,
初姿右腕碰撞几何穿透约 18.9 mm,因此该初姿不作为无碰撞路径验证结果。
小赵尚未配置 MoveP 避障规划,因此此配置关闭 MoveP 预接近及完成/失败后的自动回初始位,
直接从初始位进行 PBVS 视觉对齐。更换测试点前需手动回初始位并重新取图。
当前使用 `ZeroSimTouch`,只验证视觉对齐、前进限距和回撤,不读取 MuJoCo 接触力。
TCP 目标停在屏幕前 5 cm,沿 Tool -Y 以 0.02 m/s 前进最多 2 cm,再沿 +Y 回撤 2 cm;
未触发力阈值时最终报告 `TOUCH_FORWARD_TIMEOUT`,不代表程序崩溃,也不能视为真实接触成功。
在项目根目录编译安装并启动:
```bash
./scripts/build.sh RelWithDebInfo
./output/bin/cmvr_es
```
程序从可执行文件旁的 `config/cmvr_es.pb.txt` 读取配置。编译安装会同步配置和
模型到 `output/bin/config`、`output/bin/model`;已有可执行文件时,也可只同步
以下本次变更,无需重新编译:
```bash
cp cmvr-es/config/manager/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/camera/xiaozhao_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 -a model/xiaozhao output/bin/model/
./output/bin/cmvr_es
```
MuJoCo 窗口关闭后程序退出。修改配置后需要重启程序才能生效。
### 控制左右臂
机械臂配置为 `cmvr-es/config/devices/arm/xiaozhao_arm.pb.txt`,
电机配置为 `cmvr-es/config/devices/motor/xiaozhao_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` |
两臂均使用 QP 逆运动学,基准坐标系为 `base_link`,法兰仍为 `link7-left/right`。
TCP 与各自第七连杆的坐标轴方向一致,仅作固定平移:左侧相对 `link7-left`
为 `(0.007, 0.23, -0.045) m`,右侧相对 `link7-right` 为 `(0.007, -0.23, -0.045) m`,
两侧 `rpy` 均为 `(0, 0, 0)`。TCP 原点以直径 5 mm 的红色球标记,不参与碰撞。
位置单位为 rad,仿真关节速度上限为 1 rad/s、加速度上限为 5 rad/s²,
默认运动速度为 0.5 rad/s、加速度为 2 rad/s²。这些是仿真参数;URDF 的
速度、力矩字段仍为导出占位值,未作为硬件参数使用。
本机 gRPC 地址为 `127.0.0.1:50052`,服务为 `cmvr.api.ArmService`。
客户端先调用 `torqueOn`,再调用 `moveJ`、`moveL`、`speedJ`、`speedL` 或 `servoJ`。
请求的 `device_id` 填上表对应机械臂 ID;`moveJ` 的七个角度按上表关节顺序填写。
`torqueOn` 的 `device_id` 位于请求顶层,运动和状态查询请求则位于 `header` 内。
协议定义见 `protos/cmvr/api/arm_service.proto`、`arm_command.proto`。
MuJoCo 下 `torqueOn` 保持当前关节位置;`torqueOff` 解除直接位置/速度控制,
恢复初始化时可受外力拖动的状态。关闭后运动命令会被拒绝,需再次 `torqueOn`
才能控制;普通切换模式或迟到的停止命令不会重新锁住关节。
释放状态仍保留模型位置执行器的阻尼,不等同于全部执行器力严格为零。
现有 MuJoCo 驱动的关节轨迹接口直接写入仿真关节状态;接口到位结果用于验证
控制映射和运动学,不代表原生位置执行器的力矩或接触动力学跟踪性能。
当前未配置 `motion.joint_path`,因此 C++ `moveP` 避障规划不可用。
新模型的专用碰撞配置尚未验证,不能直接复用 xiaoyan 的碰撞模型。
修改 `joint_limits.csv` 后,除运行下方同步工具,还需同步修改两份控制配置中的
`joint_limits` / `joint_limit_policy.limits`,保持电机、IK 与模型的位置限位一致。
### moveL / speedL 测试起始姿态
预设和两臂的 gRPC 请求示例保存在
`model/xiaozhao/config/cartesian_test_pose.json`。这是手动测试预设,不会自动改变启动位置。
先对目标臂调用 `torqueOn`,再用 `moveJ` 到下列姿态;七个关节全部选择,顺序为 J1~J7。
MoveJ 参数:速度 `0.5 rad/s`、加速度 `1.0 rad/s²`,等待到位后再测试笛卡尔运动。
| 机械臂 | J1~J7,单位 ° |
| --- | --- |
| `xiaozhao_left_arm` | `90, -30, 0, -90, 0, -30, -15` |
| `xiaozhao_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`。
客户端如果仍加载 xiaoyan 的 URDF,需要修改关节名称,且不能沿用旧模型的 GetPose 坐标系。
预设中的 `expected_tcp_pose` 是按当前 URDF 计算的六个值;姿态单位为 rad,
约定为 `R = Rx(rx) * Ry(ry) * Rz(rz)`,不是旋转向量。
`base_link` 坐标轴和上述 TCP 偏移更新后,预设内的绝对 TCP 示例已按当前 URDF 重新计算;
调整前保存的绝对坐标不能继续直接使用。修改模型后应重新 `getPose`,
预设中的 `expected_tcp_pose_urdf_sha256` 标记了生成示例时的 URDF 版本。
当前 `base_link` 已直接作为根,关节轴向和限位保持不变,因此上表的关节角仍适用。
机器人正前方为 Base 的 +X;上表保留的是旧 −X 侧测试姿态(机器人后方),
不能作为当前正前方触屏场景的起始姿态。这组姿态的左右 TCP 分别约为
`(-0.482792, 0.101209, 0.374712) m` 和 `(-0.482788, -0.101205, 0.374712) m`。
- `moveL`:读取当前 `getPose`,保持 `rx/ry/rz`,单独修改 X、Y 或 Z 的绝对目标 ±`0.01 m`;速度 `0.01 m/s`,加速度 `0.05 m/s²`,blend 为 0。
- `speedL`:单轴线速度 ±`0.01 m/s`,其余速度包括角速度全部为 0;加速度 `0.05 m/s²`,duration 为 `0.5 s`。返回后调用 `stopMotion`,确认成功且关节速度归零。duration 为 0 会持续运行。
- 每项测试前用 `moveJ` 回到上述姿态,避免连续点击产生累计位移。SpeedL 有加减速过程,位移不能直接按速度乘时长计算。
以下控制接口执行记录均来自添加初版 170 mm TCP 之前,使用 `link7-left/right` 作为 TCP;
本次偏移更新已重新计算位姿示例,URDF/MuJoCo 一致性检查结果记录在 JSON 的
`tcp_frame_validation` 中;尚未重新执行 MoveL/SpeedL 接口测试。
坐标轴调整前的隔离仿真通过两臂 × 六个平移方向 × 两种接口,共 24 项 C++ 控制接口测试;
基座系调整后、添加 TCP 之前的模型通过左臂六方向 MoveL(jerk 为 gRPC 默认值 `5 m/s³`),
最大末端位置误差约 `3.32 μm`,运动中最小关节限位余量约 `0.226 rad`。
该次测试随后在首项 SpeedL 前的回预设/切换阶段阻塞,未完成 SpeedL 和右臂执行验证。
该结果只覆盖上述小幅平移。当前碰撞网格仍有 link5/link7 腕部接触,
不代表避碰验证或原生力矩控制验证。
## 从 CSV 同步关节限位
脚本为 `model/update_joint_limits.py`,使用 `--模型目录名` 选择模型。
@ -14,6 +215,7 @@ model/
└── xml/
├── xiaozhao.xml
├── actuators.xml
├── contact_exclusions.xml
├── environment.xml
└── scene.xml
```
@ -40,7 +242,7 @@ python3 model/update_joint_limits.py --xiaozhao
- `model/xiaozhao/xml/xiaozhao.xml` 的关节 `range`
- `model/xiaozhao/xml/actuators.xml` 的位置执行器 `ctrlrange`
CSV 已填入当前 14 个关节的限位。`unit` 为 `rad`(弧度)或 `deg`(角度),
CSV 已填入当前 17 个关节的限位,包括双臂 14 个和颈部 3 个。`unit` 为 `rad`(弧度)或 `deg`(角度),
可以逐行选择;省略整个 `unit` 列时按弧度处理。例如,把某个关节改为 ±90°:
```csv
@ -65,7 +267,7 @@ python3 model/update_joint_limits.py --xiaozhao \
也支持 SolidWorks 导出 CSV 的 `Joint Name`、`Limit Lower`、`Limit Upper` 列,
按弧度读取,跳过无关节名的根链接行。SolidWorks 格式 CSV 和另一份原始 URDF 不会由限位脚本自动修改。
当前 SolidWorks 格式 CSV 的关节坐标、轴向、限位及链接原点已按 `xiaozhao.urdf` 同步。
该格式每个链接仅记录一组 visual/collision,右手额外的镜像手掌几何仍以当前 URDF/XML 为准;
该格式每个链接仅记录一组 visual/collision;当前左右手各用一份完整 STL,URDF/XML 不再叠加额外的镜像手掌几何。
另一份原始 URDF 保留为历史导出。
目标 MJCF 必须是包含关节定义的机器人文件,不是仅含 `include` 的 `scene.xml`。
当前工具适用于 `revolute`/`hinge` 关节和 `gear=1` 的位置执行器;不更改速度、力矩、
@ -80,3 +282,22 @@ URDF 始终写弧度,MJCF `range` 跟随其 `compiler angle`,执行器控制
应用后在 MuJoCo 中按 **Ctrl+L** 重新加载 `model/xiaozhao/xml/scene.xml`,
新的限位和控制滑块范围才会生效;脚本不会自动操作当前仿真窗口。
## 从 URDF 重新生成 MuJoCo XML
```bash
python3 model/xiaozhao/generate_mujoco_xml.py
```
以 `xiaozhao/urdf/xiaozhao.urdf` 为准重新生成 `xiaozhao/xml/xiaozhao.xml`,
保留减面外观及原始碰撞网格。碰撞排除独立保存在 `xml/contact_exclusions.xml`,
由 `scene.xml` 加载,生成脚本不再从旧机器人 XML 复制 `<contact>`。
完整仿真应加载 `scene.xml`;单独加载机器人 XML 不包含这些碰撞排除、环境或执行器。
TCP 的 URDF visual 球转换为同名
MuJoCo site,保留位置、大小和颜色,不增加碰撞或质量。
生成时同时读取 `xiaozhao/xml/hand_camera.xml` 和 `xiaozhao/xml/head_camera.xml`,
分别把右手相机挂到 `link7-right`、头部相机挂到 `neck_Link3`。
修改任一相机安装位置后都需运行此脚本。`touch_scene.xml` 由 `scene.xml` 直接加载,
修改屏幕后重新加载场景即可。
写入前通过项目自带 MuJoCo 3.3.7 编译验证。环境、触控场景、执行器和碰撞排除由独立 XML 管理;
修改限位时使用上面的 CSV 工具同步执行器,运行目录按安装步骤同步。

Binary file not shown.

BIN
model/xiaozhao.zip Normal file

Binary file not shown.

View File

@ -13,3 +13,6 @@ joint4-right,0,2.355,rad
joint5-right,-3.14,3.14,rad
joint6-right,-0.45,0.785,rad
joint7-right,-1.05,1.05,rad
neck-joint1,-1.57,1.57,rad
neck-joint2,-1.57,0.44,rad
neck-joint3,-0.44,0.44,rad

1 joint_name lower upper unit
13 joint5-right -3.14 3.14 rad
14 joint6-right -0.45 0.785 rad
15 joint7-right -1.05 1.05 rad
16 neck-joint1 -1.57 1.57 rad
17 neck-joint2 -1.57 0.44 rad
18 neck-joint3 -0.44 0.44 rad

View File

@ -0,0 +1,188 @@
"""Regenerate xiaozhao.xml from the current URDF using bundled MuJoCo 3.3.7.
Uses simplified visual meshes when available and retains original collision
meshes. URDF TCP visual spheres become massless, non-colliding MuJoCo sites.
Environment, actuator and contact-exclusion configuration remain in separate
XML files included by scene.xml; load scene.xml for the complete simulation.
Camera attachments are loaded from xml/hand_camera.xml and xml/head_camera.xml.
"""
import argparse
import copy
import math
import os
from pathlib import Path
import stat
import subprocess
import tempfile
import xml.etree.ElementTree as ET
MODEL = Path(__file__).resolve().parent
REPO = MODEL.parents[1]
MESHES = MODEL / "meshes"
XML = MODEL / "xml/xiaozhao.xml"
CAMERA_ATTACHMENTS = (
(MODEL / "xml/hand_camera.xml", "link7-right"),
(MODEL / "xml/head_camera.xml", "neck_Link3"),
)
# Hand STLs are now lightweight too. Keep their original OBJ collision geometry;
# those OBJ files also serve as the source for repeatable hand simplification.
LARGE_MESHES = {"base_link.STL", "link7-left.STL", "link7-right.STL", "hand-right-mirrored.STL"}
def incorporate_inertial_rotation(link):
"""Express URDF inertia in link axes, preserving its physical tensor.
The native 3.3.7 importer otherwise drops inertial-origin rotation when
diagonalizing full tensors. Normalize only the temporary conversion copy.
"""
inertial = link.find("inertial")
if inertial is None:
return
origin = inertial.find("origin")
if origin is None:
return
r, p, y = map(float, origin.get("rpy", "0 0 0").split())
if (r, p, y) == (0., 0., 0.):
return
cr, sr, cp, sp, cy, sy = math.cos(r), math.sin(r), math.cos(p), math.sin(p), math.cos(y), math.sin(y)
rotation = [[cy*cp, cy*sp*sr-sy*cr, cy*sp*cr+sy*sr],
[sy*cp, sy*sp*sr+cy*cr, sy*sp*cr-cy*sr], [-sp, cp*sr, cp*cr]]
tensor = inertial.find("inertia")
a = {k: float(v) for k, v in tensor.attrib.items()}
inertia = [[a["ixx"], a["ixy"], a["ixz"]],
[a["ixy"], a["iyy"], a["iyz"]], [a["ixz"], a["iyz"], a["izz"]]]
rotated = [[sum(rotation[i][k]*inertia[k][l]*rotation[j][l]
for k in range(3) for l in range(3)) for j in range(3)] for i in range(3)]
for key, i, j in [("ixx", 0, 0), ("ixy", 0, 1), ("ixz", 0, 2),
("iyy", 1, 1), ("iyz", 1, 2), ("izz", 2, 2)]:
tensor.set(key, format(rotated[i][j], ".17g"))
origin.set("rpy", "0 0 0")
def compile_model(compiler, source, destination):
result = subprocess.run([str(compiler), str(source), str(destination)],
capture_output=True, text=True)
# The bundled utility can return zero even when model compilation fails.
if result.returncode or not destination.exists():
raise RuntimeError(result.stdout + result.stderr)
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--compiler", type=Path,
default=REPO / "dependency/x86/third_party/mujoco/v3.3.7/bin/compile")
parser.add_argument("--output", type=Path, default=XML)
args = parser.parse_args()
output = args.output.resolve()
source_path = MODEL / "urdf/xiaozhao.urdf"
original = source_path.read_bytes()
camera_sources = [(path, parent, path.read_bytes()) for path, parent in CAMERA_ATTACHMENTS]
previous = output.read_bytes() if output.exists() else None
source = ET.fromstring(original)
with tempfile.TemporaryDirectory(prefix="xiaozhao-convert-") as temporary:
work = Path(temporary)
(work / "visual").mkdir()
asset_paths = {}
for link in source.findall("link"):
incorporate_inertial_rotation(link)
for kind in ("visual", "collision"):
for element in link.findall(kind):
mesh = element.find("geometry/mesh")
if mesh is None:
continue
name = Path(mesh.get("filename")).name
simplified = MESHES / "visual" / name
if kind == "visual" and simplified.exists():
local = work / "visual" / (Path(name).stem + "_visual" + Path(name).suffix)
if not local.exists():
local.symlink_to(simplified)
relative = "visual/" + name
else:
if name in LARGE_MESHES:
name = Path(name).with_suffix(".obj").name
local, relative = MESHES / name, name
if not local.exists():
raise FileNotFoundError(local)
mesh.set("filename", str(local))
asset_paths[str(local)] = relative
extension = source.find("mujoco")
if extension is None:
extension = ET.SubElement(source, "mujoco")
compiler = extension.find("compiler")
if compiler is None:
compiler = ET.SubElement(extension, "compiler")
compiler.attrib.update(discardvisual="false", fusestatic="false", strippath="false")
ET.ElementTree(source).write(work / "source.urdf", encoding="utf-8", xml_declaration=True)
compile_model(args.compiler, work / "source.urdf", work / "generated.xml")
robot = ET.parse(work / "generated.xml").getroot()
robot.find("compiler").set("meshdir", os.path.relpath(MESHES, output.parent))
for asset in robot.findall("asset/mesh"):
asset.set("file", asset_paths[asset.get("file")])
for geom in robot.findall(".//geom"):
if geom.get("contype", "1") != "0" or geom.get("conaffinity", "1") != "0":
geom.set("group", "3")
for side in ("left", "right"):
name = "tcp-" + side
link = source.find(f'link[@name="{name}"]')
body = robot.find(f'.//body[@name="{name}"]')
if link is None or body is None or link.find("visual/geometry/sphere") is None:
continue
geoms = body.findall("geom")
if (link.find("inertial") is not None or link.find("collision") is not None
or body.find("inertial") is not None or len(geoms) != 1
or geoms[0].get("type", "sphere") != "sphere"):
raise ValueError(f"{name}: expected a massless TCP with one visual sphere")
geom = geoms[0]
site = {k: v for k, v in geom.attrib.items() if k in ("pos", "quat", "size", "rgba")}
site.update(name=name, type="sphere", group="1")
body.remove(geom)
ET.SubElement(body, "site", site)
# Mount the independent camera modules on their robot links. Their
# assets are included so the standalone robot also compiles directly.
for module_path, parent_name, module_source in camera_sources:
module = ET.fromstring(module_source)
for asset in module.findall("asset/*"):
if "file" in asset.attrib:
asset.set("file", os.path.relpath(
(module_path.parent / asset.get("file")).resolve(), output.parent))
robot.find("asset").append(copy.deepcopy(asset))
parent = robot.find(f'.//body[@name="{parent_name}"]')
if parent is None:
raise ValueError(f"{module_path.name} requires URDF {parent_name}")
for attachment in module.findall("worldbody/*"):
parent.append(copy.deepcopy(attachment))
comments = [
" Generated from ../urdf/xiaozhao.urdf with MuJoCo 3.3.7; base_link is the single fixed root. ",
" Simplified visuals are in meshes/visual; original collision meshes and inertias are retained. ",
" Collision group 3 is hidden by default. Contact exclusions, environment and actuators are included by scene.xml. ",
" Inertial-origin rotations are incorporated in link-frame tensors before conversion. ",
" TCP visual spheres from URDF are represented by non-colliding, massless sites. ",
" Cameras and hand AprilTag are mounted from hand_camera.xml and head_camera.xml by the generator. ",
]
for i, comment in enumerate(comments):
robot.insert(i, ET.Comment(comment))
ET.indent(robot, space=" ")
output.parent.mkdir(parents=True, exist_ok=True)
with tempfile.NamedTemporaryFile(dir=output.parent, prefix=".xiaozhao-", suffix=".xml", delete=False) as f:
staged = Path(f.name)
try:
ET.ElementTree(robot).write(staged, encoding="utf-8", xml_declaration=True)
with staged.open("ab") as f:
f.write(b"\n")
compile_model(args.compiler, staged, work / "verified.mjb")
if (source_path.read_bytes() != original
or any(path.read_bytes() != content for path, _, content in camera_sources)
or (output.read_bytes() if output.exists() else None) != previous):
raise RuntimeError("URDF or target XML changed during conversion; output not replaced")
staged.chmod(stat.S_IMODE(output.stat().st_mode) if output.exists() else 0o644)
os.replace(staged, output)
finally:
staged.unlink(missing_ok=True)
print(f"Generated and compiled {output}")
if __name__ == "__main__":
main()

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,56 @@
# MuJoCo 轻量外观网格
本目录保存 `xml/xiaozhao.xml` 的轻量 visual geom。手部从保留的高精度
`meshes/link7-left.obj` 减面生成,并同步写入 `meshes/link7-left.STL`、
`meshes/link7-right.STL`,因此 URDF 保持原引用即可使用轻量手部。
其他连杆的源 STL 保留。MuJoCo 手部碰撞仍使用高精度 OBJ,质量、惯性、
关节坐标、限位和执行器参数不受减面影响。
模型最初基于 urdf6 导入的 18 个 STL(含 3 个颈部网格),颈部现已同步 urdf7。
`neck_Link3` 的源网格局部坐标平移 `(0, 0.015, 0.0035) m`,相应轻量外观已从新 STL 重建;
颈部 J3 origin 更新为 `(0, 0.0035, -0.035) m`,维持头部零位外形。
头部相机同步迁移至 `neck_Link3` 的 `(0.0325, 0.10347742, 0.08039297) m`,
仍位于原相机窗口外 0.5 mm,零位朝 Base `+X`、向下约 30.9°。
其中 `link7-right.STL`
已由完整 `link7-left.STL` 关于局部 XY 平面镜像生成(Z 坐标取反)。右手 visual 同样由左手 visual 精确镜像,
左右手原始网格各 268,502 个三角面,当前 STL 和 visual 各 21,479 个,减少约 92%;
两侧使用相同减面精度,保留精确镜像关系。机器人使用的 18 个网格原始高精度源
共 1,904,402 个三角面,当前 URDF 引用的 STL 共 1,410,356 个,
MuJoCo 轻量外观共 538,499 个,相比高精度源减少约 71.72%。
目录仍保留未加载的旧 `hand-right-mirrored` 网格;包含该闲置资产的 manifest 统计
为 2,161,758 → 564,234 个三角面。
`base_link.obj` 是当前基座 STL 的无损转换;`link7-left.obj`、`link7-right.obj`
保留减面前的完整几何,用于 MuJoCo 碰撞及重复生成轻量手部,不能用减面后的 STL 覆盖。
旧 `hand-right-mirrored.STL/.obj` 保持原文件,URDF/XML 中已移除其额外几何。
碰撞 geom 设为 group 3,默认隐藏,避免与外观网格重复绘制。
需要检查碰撞外形时,可在 MuJoCo 中启用 Geom group 3。
在项目根目录重新生成(需要 Blender 4.5,使用其内置 Python/NumPy):
```bash
blender --background --factory-startup --threads 4 --python-exit-code 1 \
--python model/xiaozhao/simplify_visual_meshes.py
```
只重新生成手部时使用:
```bash
blender --background --factory-startup --threads 4 --python-exit-code 1 \
--python model/xiaozhao/simplify_visual_meshes.py -- --hands-only
```
两种命令都始终从高精度手部 OBJ 开始,左手减面后自动镜像生成右手,
同步更新两侧 STL、visual 和 `manifest.json`,不会在已经减面的手部上重复减面。
手部目标为原面数的 8%,检查原网格及输出网格的全部顶点和三角面中心,
双向距离及包围盒变化阈值为 0.9 mm;当前最大距离约 0.871 mm、RMS 约 0.072 mm。
其他连杆从 10% 面数开始,以 0.5 mm 双向采样距离及包围盒变化为阈值。
若超过对应阈值,脚本会增加保留面数。
所有网格保留原坐标和米制单位,不进行平移、旋转或缩放。
`manifest.json` 记录源文件 SHA-256、面数及每个网格的误差和采样设置;
当前最大包围盒端点变化约 0.201 mm。
顶点与面中心的检查仍是离散质量检查,不是连续全表面的严格误差上界。
减面脚本写本目录及两侧手部 STL,不自动改 URDF 或 XML。之后从 URDF 更新 XML 时,运行
`python3 model/xiaozhao/generate_mujoco_xml.py`,会自动应用独立的 visual mesh
引用和 collision group 3 设置。
环境背景、阴影、反射及仿真步长保持原配置。

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,217 @@
{
"blender_version": "4.5.11 LTS",
"target_ratio": 0.1,
"min_faces": 2000,
"max_sampled_error_m": 0.0005,
"samples_per_kind": 6000,
"source_faces": 2161758,
"output_faces": 564234,
"meshes": [
{
"source": "base_link.STL",
"source_sha256": "2fdd0b0d3fdaed9ab17eac5870b1026513d544b5c4963808abe3f9e90c3c33c7",
"output": "visual/base_link.STL",
"source_faces": 748188,
"output_faces": 149621,
"sampled_surface_max_m": 0.00042033911449834704,
"sampled_surface_rms_m": 4.1494265117752987e-05,
"bounds_max_change_m": 5.963444709777832e-05
},
{
"source": "hand-right-mirrored.STL",
"source_sha256": "e7f5c7fd193f03a85112b808f31a8accc060dfbae2f2cbf04fc965864212f3b8",
"output": "visual/hand-right-mirrored.STL",
"source_faces": 257356,
"output_faces": 25735,
"sampled_surface_max_m": 0.00037606811383739114,
"sampled_surface_rms_m": 5.473943785924547e-05,
"bounds_max_change_m": 6.569921970367432e-05
},
{
"source": "link1-left.STL",
"source_sha256": "4a171f7985e324f3dc536d1f5909efc65dc0c9326f46f98131bd8f85260b551d",
"output": "visual/link1-left.STL",
"source_faces": 57760,
"output_faces": 23104,
"sampled_surface_max_m": 0.00026875498588196933,
"sampled_surface_rms_m": 2.835141984448404e-05,
"bounds_max_change_m": 2.874806523323059e-05
},
{
"source": "link1-right.STL",
"source_sha256": "28550e0f2cd66b06175aaca3b1c7bdda62e10b947aaed015121041bd43e46deb",
"output": "visual/link1-right.STL",
"source_faces": 56898,
"output_faces": 22759,
"sampled_surface_max_m": 0.00026874730247072875,
"sampled_surface_rms_m": 2.7682213111346282e-05,
"bounds_max_change_m": 1.9766390323638916e-05
},
{
"source": "link2-left.STL",
"source_sha256": "19f89071892e642b9a67745e09f6bad7ce4297d3652c4dd63a70adc20946d088",
"output": "visual/link2-left.STL",
"source_faces": 75768,
"output_faces": 30307,
"sampled_surface_max_m": 0.00018937674758490175,
"sampled_surface_rms_m": 2.7082863328099957e-05,
"bounds_max_change_m": 5.871430039405823e-05
},
{
"source": "link2-right.STL",
"source_sha256": "0e6888b4089046cbdd8959829294829bb5792f699413f1485c7ee83b990b4f6f",
"output": "visual/link2-right.STL",
"source_faces": 76202,
"output_faces": 30479,
"sampled_surface_max_m": 0.0002346254768781364,
"sampled_surface_rms_m": 2.6829235074265677e-05,
"bounds_max_change_m": 5.8673322200775146e-05
},
{
"source": "link3-left.STL",
"source_sha256": "321d53bbcd65d8fb5e3e678c93bc2b832e29f067e4965956d752248ce0589fba",
"output": "visual/link3-left.STL",
"source_faces": 37368,
"output_faces": 14946,
"sampled_surface_max_m": 0.0003167078539263457,
"sampled_surface_rms_m": 3.798521451653437e-05,
"bounds_max_change_m": 4.1447579860687256e-05
},
{
"source": "link3-right.STL",
"source_sha256": "bfaa104792529e280f373621e4281684faa5a1b2012e7f7aead909d3bcd72e2e",
"output": "visual/link3-right.STL",
"source_faces": 37368,
"output_faces": 14947,
"sampled_surface_max_m": 0.00045000016689300537,
"sampled_surface_rms_m": 3.8364295204592935e-05,
"bounds_max_change_m": 4.1447579860687256e-05
},
{
"source": "link4-left.STL",
"source_sha256": "7321111ef3c363004278c6ab88c67e43291b7052413319afa59f4e1b9f65bc78",
"output": "visual/link4-left.STL",
"source_faces": 45090,
"output_faces": 36071,
"sampled_surface_max_m": 9.083322220249102e-05,
"sampled_surface_rms_m": 3.0952330584570504e-06,
"bounds_max_change_m": 0.0
},
{
"source": "link4-right.STL",
"source_sha256": "77a4eaf24f438fa7af172522420452c46b5c3371e894de0829b8d9f322417499",
"output": "visual/link4-right.STL",
"source_faces": 45028,
"output_faces": 36021,
"sampled_surface_max_m": 9.083344048121944e-05,
"sampled_surface_rms_m": 3.1129902787962218e-06,
"bounds_max_change_m": 0.0
},
{
"source": "link5-left.STL",
"source_sha256": "dcfa389745a9893771e2473f6437cf38c49d2e3cb85ba5a9ed6333c04059b734",
"output": "visual/link5-left.STL",
"source_faces": 53612,
"output_faces": 42889,
"sampled_surface_max_m": 0.000298623344860971,
"sampled_surface_rms_m": 5.349286240748322e-06,
"bounds_max_change_m": 3.050081431865692e-07
},
{
"source": "link5-right.STL",
"source_sha256": "75fdd5b7a69cf9bb5541ac827f7df4633fe9bfc440cf97407e3f57b06558fcf7",
"output": "visual/link5-right.STL",
"source_faces": 53616,
"output_faces": 42891,
"sampled_surface_max_m": 9.082913311431184e-05,
"sampled_surface_rms_m": 4.655186798771574e-06,
"bounds_max_change_m": 0.0
},
{
"source": "link6-left.STL",
"source_sha256": "ed4bab728dc54447f0c27a171d105ea52411a23fcafaf19366e04907330ed540",
"output": "visual/link6-left.STL",
"source_faces": 21804,
"output_faces": 17442,
"sampled_surface_max_m": 9.875782416202128e-05,
"sampled_surface_rms_m": 3.821786649679022e-06,
"bounds_max_change_m": 4.641711711883545e-06
},
{
"source": "link6-right.STL",
"source_sha256": "2cbbc72dda80d0caa105fc749e365d206a7f03b29c01c140698b51374e7faf73",
"output": "visual/link6-right.STL",
"source_faces": 21804,
"output_faces": 17442,
"sampled_surface_max_m": 9.083369513973594e-05,
"sampled_surface_rms_m": 3.723543151280335e-06,
"bounds_max_change_m": 4.641711711883545e-06
},
{
"source": "link7-left.obj",
"source_sha256": "764db2f4e79b040c8cf0f6adf645846cdb6464ba723517f89d52679388f9e50a",
"output": "visual/link7-left.STL",
"source_faces": 268502,
"output_faces": 21479,
"sampled_surface_max_m": 0.0008708483073860407,
"sampled_surface_rms_m": 7.231836397924099e-05,
"bounds_max_change_m": 0.00020128116011619568,
"target_ratio": 0.08,
"max_sampled_error_m": 0.0009,
"samples_per_kind": 300000,
"urdf_stl": "link7-left.STL"
},
{
"source": "link7-right.obj",
"source_sha256": "d759454f2aa4819e0d6094ac01aea7bfeadecb161f86d16c19caebc71f21a729",
"output": "visual/link7-right.STL",
"source_faces": 268502,
"output_faces": 21479,
"sampled_surface_max_m": 0.0008708483073860407,
"sampled_surface_rms_m": 7.231836397924099e-05,
"bounds_max_change_m": 0.00020128116011619568,
"target_ratio": 0.08,
"max_sampled_error_m": 0.0009,
"samples_per_kind": 300000,
"urdf_stl": "link7-right.STL",
"mirror_of": "visual/link7-left.STL",
"mirror_axis": "z"
},
{
"source": "neck_Link1.STL",
"source_sha256": "f6ae5e8b5ed87be05891e3eecc8f244472a5b191eaa84b4719db04c8b22be1b1",
"output": "visual/neck_Link1.STL",
"source_faces": 6050,
"output_faces": 4000,
"sampled_surface_max_m": 0.00013269121700432152,
"sampled_surface_rms_m": 3.372635119155393e-05,
"bounds_max_change_m": 1.4435732737183571e-05,
"target_ratio": 0.1,
"max_sampled_error_m": 0.0005,
"samples_per_kind": 6000
},
{
"source": "neck_Link2.STL",
"source_sha256": "d5c04d90019d4ce0e11cc55d85e0db6926a7e6f22a787399fcb0941de99c05c9",
"output": "visual/neck_Link2.STL",
"source_faces": 4278,
"output_faces": 1998,
"sampled_surface_max_m": 0.0002777037734631449,
"sampled_surface_rms_m": 6.414035904574769e-05,
"bounds_max_change_m": 6.864219903945923e-05
},
{
"source": "neck_Link3.STL",
"source_sha256": "05245467e1f49487d2b0d4fa8d2d280d60587859456278ea970267c0ce4da074",
"output": "visual/neck_Link3.STL",
"source_faces": 26564,
"output_faces": 10624,
"sampled_surface_max_m": 0.00038459166535176337,
"sampled_surface_rms_m": 6.716052793042533e-05,
"bounds_max_change_m": 7.949024438858032e-05,
"target_ratio": 0.1,
"max_sampled_error_m": 0.0005,
"samples_per_kind": 6000
}
]
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,238 @@
"""Generate lightweight visuals, including the STL files used by URDF hands.
Run with Blender 4.5 from any directory:
blender --background --factory-startup --python simplify_visual_meshes.py
blender --background --factory-startup --python simplify_visual_meshes.py -- --hands-only
The sampled surface-distance check is a quality check, not a Hausdorff bound.
Hand OBJ files retain the original geometry for MuJoCo collisions and repeated
simplification. Other source meshes and URDF definitions are not edited here.
"""
from pathlib import Path
import argparse
import hashlib
import json
import os
import stat
import struct
import sys
import tempfile
import bpy
import numpy as np
from mathutils.bvhtree import BVHTree
MESHES = Path(__file__).resolve().parent / "meshes"
OUTPUT = MESHES / "visual"
TARGET_RATIO = 0.10
MIN_FACES = 2000
MAX_SAMPLED_ERROR = 0.0005 # metres; retain more faces if necessary
SAMPLES_PER_KIND = 6000
HAND_TARGET_RATIO = 0.08
HAND_MAX_SAMPLED_ERROR = 0.0009
# Covers every vertex and triangle centre of the current 268,502-face source.
HAND_SAMPLES_PER_KIND = 300000
HAND_NAMES = {"link7-left.STL", "link7-right.STL"}
STL_DTYPE = np.dtype([
("normal", "<f4", (3,)), ("vertices", "<f4", (3, 3)), ("attribute", "<u2")
])
def read_stl(path):
with path.open("rb") as stream:
header = stream.read(84)
count = struct.unpack("<I", header[80:84])[0]
assert path.stat().st_size == 84 + 50 * count, path
triangles = np.fromfile(stream, dtype=STL_DTYPE, count=count)["vertices"]
vertices, indices = np.unique(triangles.reshape(-1, 3), axis=0, return_inverse=True)
return vertices, indices.reshape(-1, 3)
def read_obj(path):
"""Read the triangle-only, lossless collision OBJ exported from CAD STL."""
vertices, faces = [], []
with path.open() as stream:
for line in stream:
fields = line.split()
if not fields:
continue
if fields[0] == "v":
vertices.append([float(x) for x in fields[1:4]])
elif fields[0] == "f":
if len(fields) != 4:
raise ValueError(f"Expected triangles in {path}")
faces.append([int(x.split('/')[0]) - 1 for x in fields[1:]])
return np.asarray(vertices, dtype=np.float32), np.asarray(faces, dtype=np.int32)
def atomic_write(path, data):
mode = stat.S_IMODE(path.stat().st_mode) if path.exists() else 0o644
with tempfile.NamedTemporaryFile(dir=path.parent, delete=False) as stream:
temporary = Path(stream.name)
stream.write(data)
try:
temporary.chmod(mode)
os.replace(temporary, path)
finally:
temporary.unlink(missing_ok=True)
def write_stl(path, vertices, faces):
triangles = vertices[faces].astype(np.float32)
precise = triangles.astype(np.float64)
normal = np.cross(precise[:, 1] - precise[:, 0], precise[:, 2] - precise[:, 0])
length = np.linalg.norm(normal, axis=1)
assert np.all(length > 0), f"Degenerate triangles in {path.name}"
records = np.zeros(len(faces), dtype=STL_DTYPE)
records["normal"] = normal / length[:, None]
records["vertices"] = triangles
atomic_write(path, b"xiaozhao visual mesh; original coordinates in metres".ljust(80, b"\0")
+ struct.pack("<I", len(faces)) + records.tobytes())
def sample_points(vertices, faces, count=SAMPLES_PER_KIND):
rng = np.random.default_rng(17)
vi = rng.choice(len(vertices), min(count, len(vertices)), replace=False)
fi = rng.choice(len(faces), min(count, len(faces)), replace=False)
return np.concatenate((vertices[vi], vertices[faces[fi]].mean(axis=1)))
def surface_tree(vertices, faces):
return BVHTree.FromPolygons(vertices.tolist(), faces.tolist(), all_triangles=True)
def distances(points, tree):
return np.array([tree.find_nearest(point)[3] for point in points])
def simplify(path, *, output_name=None, target_ratio=TARGET_RATIO,
max_error=MAX_SAMPLED_ERROR, samples_per_kind=SAMPLES_PER_KIND):
vertices, faces = read_obj(path) if path.suffix.lower() == ".obj" else read_stl(path)
original_tree = surface_tree(vertices, faces)
original_samples = sample_points(vertices, faces, samples_per_kind)
mesh = bpy.data.meshes.new(path.stem + "_source")
mesh.from_pydata(vertices.tolist(), [], faces.tolist())
mesh.update()
obj = bpy.data.objects.new(path.stem + "_simplify", mesh)
bpy.context.scene.collection.objects.link(obj)
modifier = obj.modifiers.new("Visual simplification", "DECIMATE")
modifier.decimate_type = "COLLAPSE"
modifier.use_collapse_triangulate = True
ratio = min(1., max(target_ratio, MIN_FACES / len(faces)))
try:
while True:
modifier.ratio = ratio
bpy.context.view_layer.update()
evaluated = obj.evaluated_get(bpy.context.evaluated_depsgraph_get())
result = evaluated.to_mesh()
try:
result.calc_loop_triangles()
out_vertices = np.empty((len(result.vertices), 3), dtype=np.float32)
out_faces = np.empty((len(result.loop_triangles), 3), dtype=np.int32)
result.vertices.foreach_get("co", out_vertices.ravel())
result.loop_triangles.foreach_get("vertices", out_faces.ravel())
finally:
evaluated.to_mesh_clear()
# Discard zero-area faces produced by CAD tessellation/collapse.
precise = out_vertices[out_faces].astype(np.float64)
areas = np.linalg.norm(np.cross(
precise[:, 1] - precise[:, 0], precise[:, 2] - precise[:, 0]
), axis=1)
out_faces = out_faces[areas > 0]
used, indices = np.unique(out_faces.ravel(), return_inverse=True)
out_vertices = out_vertices[used]
out_faces = indices.reshape(-1, 3).astype(np.int32)
out_tree = surface_tree(out_vertices, out_faces)
errors = np.concatenate((
distances(original_samples, out_tree),
distances(sample_points(out_vertices, out_faces, samples_per_kind), original_tree),
))
bounds_error = float(np.max(np.abs(
np.array([vertices.min(axis=0), vertices.max(axis=0)])
- np.array([out_vertices.min(axis=0), out_vertices.max(axis=0)])
)))
if max(float(errors.max()), bounds_error) <= max_error:
break
if ratio >= 1.:
raise ValueError(f"Surface check failed for {path.name}")
ratio = min(1., ratio * 2)
print(f"Retaining more detail in {path.name}: ratio={ratio:.3f}; "
f"sampled error={errors.max() * 1000:.3f} mm", flush=True)
output = OUTPUT / (output_name or path.name)
write_stl(output, out_vertices, out_faces)
report = {
"source": path.name,
"source_sha256": hashlib.sha256(path.read_bytes()).hexdigest(),
"output": "visual/" + output.name,
"source_faces": len(faces),
"output_faces": len(out_faces),
"sampled_surface_max_m": float(errors.max()),
"sampled_surface_rms_m": float(np.sqrt(np.mean(errors ** 2))),
"bounds_max_change_m": bounds_error,
"target_ratio": target_ratio,
"max_sampled_error_m": max_error,
"samples_per_kind": samples_per_kind,
}
print(json.dumps(report), flush=True)
return report
finally:
bpy.data.objects.remove(obj, do_unlink=True)
bpy.data.meshes.remove(mesh)
def simplify_hands():
"""Always start from original OBJ, and preserve exact left/right mirroring."""
left_source, right_source = MESHES / "link7-left.obj", MESHES / "link7-right.obj"
lv, lf = read_obj(left_source)
rv, rf = read_obj(right_source)
if not np.array_equal(rv[rf], lv[lf][:, [0, 2, 1], :] * [1, 1, -1]):
raise ValueError("Hand collision OBJ files are not exact mirrors; review before simplifying")
left = simplify(left_source, output_name="link7-left.STL",
target_ratio=HAND_TARGET_RATIO, max_error=HAND_MAX_SAMPLED_ERROR,
samples_per_kind=HAND_SAMPLES_PER_KIND)
vertices, faces = read_stl(OUTPUT / "link7-left.STL")
vertices[:, 2] *= -1
write_stl(OUTPUT / "link7-right.STL", vertices, faces[:, [0, 2, 1]])
for name in sorted(HAND_NAMES):
atomic_write(MESHES / name, (OUTPUT / name).read_bytes())
left["urdf_stl"] = "link7-left.STL"
right = dict(left, source=right_source.name,
source_sha256=hashlib.sha256(right_source.read_bytes()).hexdigest(),
output="visual/link7-right.STL", urdf_stl="link7-right.STL",
mirror_of="visual/link7-left.STL", mirror_axis="z")
return [left, right]
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--hands-only", action="store_true",
help="Update hand STL/visual meshes from original collision OBJ only")
args = parser.parse_args(sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else [])
OUTPUT.mkdir(exist_ok=True)
if args.hands_only:
previous = json.loads((OUTPUT / "manifest.json").read_text())
reports = [item for item in previous["meshes"]
if Path(item["output"]).name not in HAND_NAMES]
else:
reports = [simplify(path) for path in sorted(MESHES.glob("*.STL"))
if path.name not in HAND_NAMES]
reports.extend(simplify_hands())
reports.sort(key=lambda item: item["output"])
report = {
"blender_version": bpy.app.version_string,
"target_ratio": TARGET_RATIO,
"min_faces": MIN_FACES,
"max_sampled_error_m": MAX_SAMPLED_ERROR,
"samples_per_kind": SAMPLES_PER_KIND,
"source_faces": sum(item["source_faces"] for item in reports),
"output_faces": sum(item["output_faces"] for item in reports),
"meshes": reports,
}
atomic_write(OUTPUT / "manifest.json", (json.dumps(report, indent=2) + "\n").encode())
print(f"TOTAL {report['source_faces']} -> {report['output_faces']} faces", flush=True)
if __name__ == "__main__":
main()

View File

@ -1,13 +1,14 @@
<?xml version='1.0' encoding='utf-8'?>
<robot name="xiaozhao">
<!-- Base axes: X_new = -Y_old, Y_new = X_old, Z_new = Z_old. -->
<link name="base_link">
<inertial>
<origin xyz="-1.19384910205036E-06 0.0158820586330755 0.0601572634202883" rpy="0 0 0" />
<origin xyz="-0.0158820586330755 -1.19384910205036e-06 0.0601572634202883" rpy="0 0 1.5707963267949" />
<mass value="12.0939193087609" />
<inertia ixx="0.0771992576048866" ixy="-4.71603477080102E-07" ixz="-1.48909012424014E-07" iyy="0.110011609259562" iyz="-0.00671136747575047" izz="0.130299609920884" />
</inertial>
<visual>
<origin xyz="0 0 0" rpy="0 0 0" />
<origin xyz="0 0 0" rpy="0 0 1.5707963267949" />
<geometry>
<mesh filename="package://00 0930Body-urdf4.SLDASM/meshes/base_link.STL" />
</geometry>
@ -16,7 +17,7 @@
</material>
</visual>
<collision>
<origin xyz="0 0 0" rpy="0 0 0" />
<origin xyz="0 0 0" rpy="0 0 1.5707963267949" />
<geometry>
<mesh filename="package://00 0930Body-urdf4.SLDASM/meshes/base_link.STL" />
</geometry>
@ -45,7 +46,7 @@
</collision>
</link>
<joint name="joint1-left" type="revolute">
<origin xyz="0.1478 0.0405 0.441" rpy="0 1.5708 0" />
<origin xyz="-0.0405 0.1478 0.441" rpy="0 1.5708 1.5707963267949" />
<parent link="base_link" />
<child link="link1-left" />
<axis xyz="0 0 1" />
@ -87,7 +88,7 @@
<inertia ixx="0.000106807122863566" ixy="1.3686406496755E-08" ixz="-9.39521625510296E-07" iyy="0.000211842956357412" iyz="-5.34315488439938E-06" izz="0.000188701328569606" />
</inertial>
<visual>
<origin xyz="0 0 0" rpy="0 0 0" />
<origin xyz="0 0 0" rpy="0 0 -1.5707963267949" />
<geometry>
<mesh filename="package://00 0930Body-urdf4.SLDASM/meshes/link3-left.STL" />
</geometry>
@ -96,7 +97,7 @@
</material>
</visual>
<collision>
<origin xyz="0 0 0" rpy="0 0 0" />
<origin xyz="0 0 0" rpy="0 0 -1.5707963267949" />
<geometry>
<mesh filename="package://00 0930Body-urdf4.SLDASM/meshes/link3-left.STL" />
</geometry>
@ -116,7 +117,7 @@
<inertia ixx="0.000106626468821837" ixy="-2.31152323845664E-10" ixz="6.45631718028383E-08" iyy="1.58918187475175E-05" iyz="-9.54676249280788E-07" izz="0.000120588702228947" />
</inertial>
<visual>
<origin xyz="0 0 0" rpy="0 0 0" />
<origin xyz="-0.0038192 0 -0.0416" rpy="0 -1.5707963267949 0" />
<geometry>
<mesh filename="package://00 0930Body-urdf4.SLDASM/meshes/link4-left.STL" />
</geometry>
@ -125,7 +126,7 @@
</material>
</visual>
<collision>
<origin xyz="0 0 0" rpy="0 0 0" />
<origin xyz="-0.0038192 0 -0.0416" rpy="0 -1.5707963267949 0" />
<geometry>
<mesh filename="package://00 0930Body-urdf4.SLDASM/meshes/link4-left.STL" />
</geometry>
@ -248,7 +249,7 @@
</collision>
</link>
<joint name="joint1-right" type="revolute">
<origin xyz="-0.1478 0.0405 0.441" rpy="1.5708 0 -1.5708" />
<origin xyz="-0.0405 -0.1478 0.441" rpy="1.5708 0 -3.67320510341607e-06" />
<parent link="base_link" />
<child link="link1-right" />
<axis xyz="0 0 1" />
@ -290,7 +291,7 @@
<inertia ixx="0.000208755273065386" ixy="9.19066905598572E-11" ixz="5.3068688461369E-06" iyy="0.00010579532895932" iyz="2.40971986387619E-07" izz="0.000186285169356577" />
</inertial>
<visual>
<origin xyz="0 0 0" rpy="0 0 0" />
<origin xyz="0 0 0" rpy="0 0 1.5707963267949" />
<geometry>
<mesh filename="package://00 0930Body-urdf4.SLDASM/meshes/link3-right.STL" />
</geometry>
@ -299,7 +300,7 @@
</material>
</visual>
<collision>
<origin xyz="0 0 0" rpy="0 0 0" />
<origin xyz="0 0 0" rpy="0 0 1.5707963267949" />
<geometry>
<mesh filename="package://00 0930Body-urdf4.SLDASM/meshes/link3-right.STL" />
</geometry>
@ -319,7 +320,7 @@
<inertia ixx="0.000106626439664163" ixy="-2.08649766890664E-10" ixz="-6.4569389547017E-08" iyy="1.5891801109711E-05" iyz="9.54668799732348E-07" izz="0.000120588654971646" />
</inertial>
<visual>
<origin xyz="0 0 0" rpy="0 0 0" />
<origin xyz="0.0038192 0 -0.0416" rpy="0 -1.5707963267949 0" />
<geometry>
<mesh filename="package://00 0930Body-urdf4.SLDASM/meshes/link4-right.STL" />
</geometry>
@ -328,7 +329,7 @@
</material>
</visual>
<collision>
<origin xyz="0 0 0" rpy="0 0 0" />
<origin xyz="0.0038192 0 -0.0416" rpy="0 -1.5707963267949 0" />
<geometry>
<mesh filename="package://00 0930Body-urdf4.SLDASM/meshes/link4-right.STL" />
</geometry>
@ -400,7 +401,7 @@
<limit lower="-0.45" upper="0.785" effort="0" velocity="0" />
</joint>
<link name="link7-right">
<!-- Display assembly: bracket and mirrored hand use Rx(pi), placing the collar alongside the last motor at local Z=-30 mm, with fingers along distal -Y. Kinematic joint origin/axis unchanged. -->
<!-- Complete left-hand STL mirrored in mesh Z, then mounted with Rx(pi): fingers along right J7 -Y. -->
<inertial>
<origin xyz="-7.26286393318538E-06 0.025058851607589 0.0149290377499663" rpy="0 0 0" />
<mass value="0.0419946886424074" />
@ -412,7 +413,7 @@
<mesh filename="package://00 0930Body-urdf4.SLDASM/meshes/link7-right.STL" />
</geometry>
<material name="">
<color rgba="0.898039215686275 0.917647058823529 0.929411764705882 1" />
<color rgba="1 1 1 1" />
</material>
</visual>
<collision>
@ -421,21 +422,6 @@
<mesh filename="package://00 0930Body-urdf4.SLDASM/meshes/link7-right.STL" />
</geometry>
</collision>
<visual name="mirrored_right_hand_visual">
<origin xyz="0 0 0" rpy="3.141592653589793 0 0" />
<geometry>
<mesh filename="package://00 0930Body-urdf4.SLDASM/meshes/hand-right-mirrored.STL" />
</geometry>
<material name="mirrored_hand_white">
<color rgba="1 1 1 1" />
</material>
</visual>
<collision name="mirrored_right_hand_collision">
<origin xyz="0 0 0" rpy="3.141592653589793 0 0" />
<geometry>
<mesh filename="package://00 0930Body-urdf4.SLDASM/meshes/hand-right-mirrored.STL" />
</geometry>
</collision>
</link>
<joint name="joint7-right" type="revolute">
<origin xyz="-0.037 0 -0.0369" rpy="0 -1.5708 0" />
@ -444,4 +430,125 @@
<axis xyz="0 0 1" />
<limit lower="-1.05" upper="1.05" effort="0" velocity="0" />
</joint>
<!-- Fixed TCP frames at mirrored hand-tip offsets; red markers are 5 mm in diameter. -->
<link name="tcp-left">
<visual name="tcp-left-marker">
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<sphere radius="0.0025" />
</geometry>
<material name="tcp-left-red">
<color rgba="1 0 0 1" />
</material>
</visual>
</link>
<joint name="tcp-left-fixed" type="fixed">
<origin xyz="0.007 0.23 -0.045" rpy="0 0 0" />
<parent link="link7-left" />
<child link="tcp-left" />
</joint>
<link name="tcp-right">
<visual name="tcp-right-marker">
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<sphere radius="0.0025" />
</geometry>
<material name="tcp-right-red">
<color rgba="1 0 0 1" />
</material>
</visual>
</link>
<joint name="tcp-right-fixed" type="fixed">
<origin xyz="0.007 -0.23 -0.045" rpy="0 0 0" />
<parent link="link7-right" />
<child link="tcp-right" />
</joint>
<!-- Neck branch from urdf6; mounted in the existing corrected base frame. -->
<link name="neck_Link1">
<inertial>
<origin xyz="0.0151599456281617 -6.12012555002722E-08 0.0402004715446036" rpy="0 0 0" />
<mass value="0.189845491279983" />
<inertia ixx="0.000265543601471852" ixy="-3.38808879149074E-11" ixz="-4.95566815108624E-05" iyy="0.000265166507716" iyz="-5.392904011033E-10" izz="0.000104301534284507" />
</inertial>
<visual>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<mesh filename="package://00 0930Body-urdf4.SLDASM/meshes/neck_Link1.STL" />
</geometry>
<material name="">
<color rgba="1 1 1 1" />
</material>
</visual>
<collision>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<mesh filename="package://00 0930Body-urdf4.SLDASM/meshes/neck_Link1.STL" />
</geometry>
</collision>
</link>
<joint name="neck-joint1" type="revolute">
<origin xyz="-0.0405 0 0.5195" rpy="0 0 1.5707963267949" />
<parent link="base_link" />
<child link="neck_Link1" />
<axis xyz="0 0 1" />
<limit lower="-1.57" upper="1.57" effort="0" velocity="0" />
</joint>
<link name="neck_Link2">
<inertial>
<origin xyz="-2.81713499803993E-05 -0.00170019104546993 -0.0313058952737208" rpy="0 0 0" />
<mass value="0.121849801440166" />
<inertia ixx="4.54157737539868E-05" ixy="-3.57669452070411E-08" ixz="-8.73828761656588E-08" iyy="5.73142513703822E-05" iyz="-4.8205277266393E-06" izz="3.74767660970369E-05" />
</inertial>
<visual>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<mesh filename="package://00 0930Body-urdf4.SLDASM/meshes/neck_Link2.STL" />
</geometry>
<material name="">
<color rgba="1 1 1 1" />
</material>
</visual>
<collision>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<mesh filename="package://00 0930Body-urdf4.SLDASM/meshes/neck_Link2.STL" />
</geometry>
</collision>
</link>
<joint name="neck-joint2" type="revolute">
<origin xyz="0.031 0 0.1085" rpy="0 1.5708 0" />
<parent link="neck_Link1" />
<child link="neck_Link2" />
<axis xyz="0 0 1" />
<limit lower="-1.57" upper="0.44" effort="0" velocity="0" />
</joint>
<link name="neck_Link3">
<inertial>
<origin xyz="0.000267765101194494 0.0821520757940103 0.0266245622880571" rpy="0 0 0" />
<mass value="0.521691388878172" />
<inertia ixx="0.0014052179047482" ixy="-2.38666183274677E-06" ixz="-5.69631570744507E-07" iyy="0.00123536484042354" iyz="0.000139207275153035" izz="0.00205087372298224" />
</inertial>
<visual>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<mesh filename="package://00 0930Body-urdf4.SLDASM/meshes/neck_Link3.STL" />
</geometry>
<material name="">
<color rgba="0.631372549019608 0.658823529411765 0.67843137254902 1" />
</material>
</visual>
<collision>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<mesh filename="package://00 0930Body-urdf4.SLDASM/meshes/neck_Link3.STL" />
</geometry>
</collision>
</link>
<joint name="neck-joint3" type="revolute">
<origin xyz="0 0.0035 -0.035" rpy="1.5708 -1.5708 0" />
<parent link="neck_Link2" />
<child link="neck_Link3" />
<axis xyz="0 0 1" />
<limit lower="-0.44" upper="0.44" effort="0" velocity="0" />
</joint>
</robot>

View File

@ -40,5 +40,13 @@
joint="joint6-right" kp="80" ctrlrange="-0.45 0.785"/>
<position name="joint7-right_pos" class="xiaozhao_position"
joint="joint7-right" kp="80" ctrlrange="-1.05 1.05"/>
<!-- Neck: append after the arms to preserve their actuator indices. -->
<position name="neck-joint1_pos" class="xiaozhao_position"
joint="neck-joint1" kp="80" ctrlrange="-1.57 1.57"/>
<position name="neck-joint2_pos" class="xiaozhao_position"
joint="neck-joint2" kp="80" ctrlrange="-1.57 0.44"/>
<position name="neck-joint3_pos" class="xiaozhao_position"
joint="neck-joint3" kp="80" ctrlrange="-0.44 0.44"/>
</actuator>
</mujoco>

View File

@ -0,0 +1,14 @@
<mujoco model="xiaozhao_contact_exclusions">
<!-- Scene-level collision filters. Include once from scene.xml.
Keep these simulation settings separate from the URDF-generated robot. -->
<contact>
<!-- Adjacent shoulder mounting meshes overlap. The fixed base is welded
to world, so MuJoCo's parent filter does not exclude these pairs. -->
<exclude body1="base_link" body2="link1-left"/>
<exclude body1="base_link" body2="link1-right"/>
<!-- The head and lower-neck convex hulls overlap around the internal gimbal.
Exclude this internal pair so it does not push neck J3 away from zero. -->
<exclude body1="neck_Link1" body2="neck_Link3"/>
</contact>
</mujoco>

View File

@ -1,7 +1,7 @@
<mujoco model="xiaozhao_environment">
<!-- Background, floor material and lighting match ../../xiaoyan_description/dual_arm.xml. -->
<visual>
<global offwidth="640" offheight="480"/>
<global offwidth="1280" offheight="720"/>
<map znear="0.02" zfar="5"/>
</visual>

View File

@ -0,0 +1,42 @@
<mujoco model="xiaozhao_hand_camera">
<!-- generate_mujoco_xml.py merges these assets and attaches the worldbody
children to link7-right. Positions below are expressed in right J7 axes. -->
<asset>
<!-- tag36h11 ID 0: 20 mm texture including quiet zone, 16 mm black tag. -->
<texture name="hand_apriltag_tex" type="2d"
file="../../april_tag/tag36_11.png"/>
<material name="hand_apriltag_mat" texture="hand_apriltag_tex"
texrepeat="1 1" rgba="1 1 1 1" emission="1"
specular="0" shininess="0" reflectance="0"/>
</asset>
<worldbody>
<!-- Use the existing CAD housing. Selected front window is at J7
(0.0325, -0.12555, 0.036); optical center sits 0.5 mm outside it. -->
<body name="hand_camera_mount" pos="0.0325 -0.12605 0.036">
<!-- Camera -Z points along the fingers (J7 -Y); camera +Y is J7 +Z. -->
<camera name="hand_cam" pos="0 0 0"
quat="0 0 0.7071067811865476 0.7071067811865476"
fovy="60"/>
<!-- Thin lens marker behind the optical center; no additional case. -->
<geom name="hand_camera_lens" type="cylinder" pos="0 0.00025 0"
quat="0.7071067811865476 0.7071067811865476 0 0"
size="0.0025 0.0002" rgba="0.05 0.12 0.18 1" mass="0"
contype="0" conaffinity="0" group="1"/>
</body>
<!-- Tag H sits on the +X end of the camera backplate (left in the rear view),
facing J7 +Y. Backplate y=-0.095; tag back face is 0.1 mm outside it.
The 20 mm texture keeps the established mounting center and orientation.
In H coordinates: TCP position=(-0.0275,0.081,-0.1354), rotation=Rx(pi/2).
The existing 5 mm red tcp-right sphere remains the touch endpoint. -->
<body name="R_HAND_APRILTAG" pos="0.0345 -0.0946 0.036"
quat="0.7071067811865476 -0.7071067811865476 0 0">
<geom name="R_HAND_APRILTAG_GEOM" type="box"
size="0.01 0.01 0.0003" material="hand_apriltag_mat"
rgba="1 1 1 1" mass="0" contype="0" conaffinity="0" group="2"/>
<site name="R_HAND_APRILTAG_SITE" pos="0 0 0"
size="0.002" rgba="1 0 1 0"/>
</body>
</worldbody>
</mujoco>

View File

@ -0,0 +1,24 @@
<mujoco model="xiaozhao_head_camera">
<!-- generate_mujoco_xml.py attaches this module to neck_Link3.
Coordinates below are in the urdf7 head link, not the world frame.
Selected CAD window center: (0.0325, 0.10372742, 0.07995996) m.
Outward normal: (0, -0.5, 0.8660254038); optical center is 0.5 mm outside.
At neck zero, the camera looks toward base +X and down about 30.9 degrees. -->
<worldbody>
<body name="external_camera_mount" pos="0.0325 0.10347742 0.08039297">
<!-- Retain the existing device-facing name; this now follows the neck. -->
<camera name="external_touch_cam" pos="0 0 0"
quat="0 0 0.963863295733281 0.26639734821911742"
fovy="50"/>
<site name="external_touch_cam_site" size="0.001" rgba="0.1 0.8 0.3 0"
quat="0 0 0.963863295733281 0.26639734821911742"/>
<!-- Reuse the STL housing; only a thin lens marker is added, behind
the optical center. It contributes no mass or contact geometry. -->
<geom name="external_camera_lens" type="cylinder"
pos="0 0.000125 -0.000216506351"
quat="0.9659258262890683 0.25881904510252074 0 0"
size="0.0025 0.0002" rgba="0.05 0.12 0.18 1"
mass="0" contype="0" conaffinity="0" group="1"/>
</body>
</worldbody>
</mujoco>

View File

@ -1,7 +1,9 @@
<mujoco model="xiaozhao_scene">
<!-- Open this file in MuJoCo to load the robot with its environment. -->
<include file="xiaozhao.xml"/>
<include file="contact_exclusions.xml"/>
<include file="environment.xml"/>
<include file="touch_scene.xml"/>
<include file="actuators.xml"/>
<option timestep="0.001" integrator="implicitfast"/>
</mujoco>

View File

@ -0,0 +1,45 @@
<mujoco model="xiaozhao_touch_scene">
<!-- Fixed touch-test equipment, adapted from right_arm_eye_to_hand.xml.
Units: metres/radians; base_link = world. Robot front is world +X.
Screen: 500 x 300 mm, front normal -X, glass front at x = +0.585 m.
Move touch_screen here; the external camera is attached to the head
through head_camera.xml and generate_mujoco_xml.py. -->
<asset>
<texture name="screen_apriltag_tex" type="2d"
file="../../april_tag/tag36_11_00001.png"/>
<material name="screen_apriltag_mat" texture="screen_apriltag_tex"
texrepeat="-1 -1" rgba="1 1 1 1" emission="1"
specular="0" shininess="0" reflectance="0"/>
<material name="screen_material" rgba="0.04 0.05 0.06 1"
specular="0.25" shininess="0.4"/>
<material name="screen_frame_material" rgba="0.15 0.15 0.15 1"
specular="0.2" shininess="0.3"/>
</asset>
<worldbody>
<body name="touch_screen" pos="0.60 0 0.38" quat="0.7071067811865476 0 0 0.7071067811865476">
<geom name="screen_frame" type="box" size="0.265 0.012 0.165"
material="screen_frame_material" contype="1" conaffinity="1"/>
<geom name="screen_surface" type="box" pos="0 0.013 0"
size="0.25 0.002 0.15" material="screen_material"
contype="1" conaffinity="1" friction="0.5 0.005 0.0001"/>
<site name="screen_center" pos="0 0.015 0" size="0.0025" rgba="1 0 0 1"/>
<site name="screen_top_left" pos="-0.25 0.015 0.15" size="0.002" rgba="1 1 0 1"/>
<site name="screen_top_right" pos="0.25 0.015 0.15" size="0.002" rgba="1 1 0 1"/>
<site name="screen_bottom_left" pos="-0.25 0.015 -0.15" size="0.002" rgba="1 1 0 1"/>
<site name="screen_bottom_right" pos="0.25 0.015 -0.15" size="0.002" rgba="1 1 0 1"/>
<!-- ID 1: 20 mm texture including quiet zone, 16 mm black tag region.
Top-right as viewed by the robot: local -X, +Z; 18.75 mm edge margins.
Entire tag stays inside the glass, offset 0.2 mm from its face. -->
<body name="SCREEN_APRILTAG" pos="-0.22125 0.0151 0.12125" quat="0.7071067811865476 -0.7071067811865476 0 0">
<geom name="SCREEN_APRILTAG_GEOM" type="box" size="0.01 0.01 0.0001"
material="screen_apriltag_mat" contype="0" conaffinity="0" mass="0" group="2"/>
<site name="SCREEN_APRILTAG_SITE" size="0.002" rgba="0 1 0 0"/>
</body>
<!-- A fixed visual stand reaches the floor at z = -0.183 m. -->
<geom name="screen_stand" type="box" pos="0 -0.02 -0.36" size="0.025 0.025 0.19"
material="screen_frame_material" contype="0" conaffinity="0"/>
<geom name="screen_stand_foot" type="box" pos="0 -0.02 -0.553" size="0.18 0.12 0.01"
material="screen_frame_material" contype="0" conaffinity="0"/>
</body>
</worldbody>
</mujoco>

View File

@ -1,68 +1,95 @@
<?xml version='1.0' encoding='utf-8'?>
<mujoco model="xiaozhao">
<!-- Converted from ../urdf/xiaozhao.urdf with MuJoCo 3.3.7. Fixed base_link; 14 joints; no mounting pedestal. -->
<!-- Large STL meshes are losslessly re-encoded as OBJ. Original inertial, visual and collision definitions are retained. -->
<!-- Position servos are defined in actuators.xml and included by scene.xml. -->
<!-- Inertial principal axes include the URDF inertial-origin rotations. -->
<!-- Generated from ../urdf/xiaozhao.urdf with MuJoCo 3.3.7; base_link is the single fixed root. -->
<!-- Simplified visuals are in meshes/visual; original collision meshes and inertias are retained. -->
<!-- Collision group 3 is hidden by default. Contact exclusions, environment and actuators are included by scene.xml. -->
<!-- Inertial-origin rotations are incorporated in link-frame tensors before conversion. -->
<!-- TCP visual spheres from URDF are represented by non-colliding, massless sites. -->
<!-- Cameras and hand AprilTag are mounted from hand_camera.xml and head_camera.xml by the generator. -->
<compiler angle="radian" meshdir="../meshes" />
<asset>
<mesh name="base_link_visual" file="visual/base_link.STL" />
<mesh name="base_link" file="base_link.obj" />
<mesh name="link1-left_visual" file="visual/link1-left.STL" />
<mesh name="link1-left" file="link1-left.STL" />
<mesh name="link2-left_visual" file="visual/link2-left.STL" />
<mesh name="link2-left" file="link2-left.STL" />
<mesh name="link3-left_visual" file="visual/link3-left.STL" />
<mesh name="link3-left" file="link3-left.STL" />
<mesh name="link4-left_visual" file="visual/link4-left.STL" />
<mesh name="link4-left" file="link4-left.STL" />
<mesh name="link5-left_visual" file="visual/link5-left.STL" />
<mesh name="link5-left" file="link5-left.STL" />
<mesh name="link6-left_visual" file="visual/link6-left.STL" />
<mesh name="link6-left" file="link6-left.STL" />
<mesh name="link7-left" file="link7-left.obj" />
<mesh name="link1-right" file="link1-right.STL" />
<mesh name="link2-right" file="link2-right.STL" />
<mesh name="link3-right" file="link3-right.STL" />
<mesh name="link4-right" file="link4-right.STL" />
<mesh name="link5-right" file="link5-right.STL" />
<mesh name="link7-left_visual" content_type="model/stl" file="visual/link7-left.STL" />
<mesh name="link7-left" content_type="model/obj" file="link7-left.obj" />
<mesh name="link1-right_visual" content_type="model/stl" file="visual/link1-right.STL" />
<mesh name="link1-right" content_type="model/stl" file="link1-right.STL" />
<mesh name="link2-right_visual" content_type="model/stl" file="visual/link2-right.STL" />
<mesh name="link2-right" content_type="model/stl" file="link2-right.STL" />
<mesh name="link3-right_visual" content_type="model/stl" file="visual/link3-right.STL" />
<mesh name="link3-right" content_type="model/stl" file="link3-right.STL" />
<mesh name="link4-right_visual" content_type="model/stl" file="visual/link4-right.STL" />
<mesh name="link4-right" content_type="model/stl" file="link4-right.STL" />
<mesh name="link5-right_visual" content_type="model/stl" file="visual/link5-right.STL" />
<mesh name="link5-right" content_type="model/stl" file="link5-right.STL" />
<mesh name="link6-right_visual" content_type="model/stl" file="visual/link6-right.STL" />
<mesh name="link6-right" content_type="model/stl" file="link6-right.STL" />
<mesh name="link7-right" content_type="model/stl" file="link7-right.STL" />
<mesh name="hand-right-mirrored" content_type="model/obj" file="hand-right-mirrored.obj" />
<mesh name="link7-right_visual" content_type="model/stl" file="visual/link7-right.STL" />
<mesh name="link7-right" content_type="model/obj" file="link7-right.obj" />
<mesh name="neck_Link1_visual" file="visual/neck_Link1.STL" />
<mesh name="neck_Link1" file="neck_Link1.STL" />
<mesh name="neck_Link2_visual" file="visual/neck_Link2.STL" />
<mesh name="neck_Link2" content_type="model/stl" file="neck_Link2.STL" />
<mesh name="neck_Link3_visual" content_type="model/stl" file="visual/neck_Link3.STL" />
<mesh name="neck_Link3" content_type="model/stl" file="neck_Link3.STL" />
<texture name="hand_apriltag_tex" type="2d" file="../../april_tag/tag36_11.png" />
<material name="hand_apriltag_mat" texture="hand_apriltag_tex" texrepeat="1 1" rgba="1 1 1 1" emission="1" specular="0" shininess="0" reflectance="0" />
</asset>
<worldbody>
<body name="base_link">
<inertial pos="-1.19385e-06 0.0158821 0.0601573" quat="-0.102963 0.69957 -0.102952 0.699572" mass="12.0939" diaginertia="0.132319 0.107992 0.0771993" />
<geom type="mesh" contype="0" conaffinity="0" group="1" density="0" rgba="0.752941 0.752941 0.752941 1" mesh="base_link" />
<geom type="mesh" rgba="0.752941 0.752941 0.752941 1" mesh="base_link" />
<body name="link1-left" pos="0.1478 0.0405 0.441" quat="0.707105 0 0.707108 0">
<inertial pos="-0.0158821 -1.19385e-06 0.0601573" quat="0.567469 0.567478 -0.421866 0.421873" mass="12.0939" diaginertia="0.132319 0.107992 0.0771993" />
<geom pos="0 0 0" quat="0.707107 0 0 0.707107" type="mesh" contype="0" conaffinity="0" group="1" density="0" rgba="0.752941 0.752941 0.752941 1" mesh="base_link_visual" />
<geom pos="0 0 0" quat="0.707107 0 0 0.707107" type="mesh" rgba="0.752941 0.752941 0.752941 1" mesh="base_link" group="3" />
<body name="link1-left" pos="-0.0405 0.1478 0.441" quat="0.499999 -0.500001 0.500001 0.499999">
<inertial pos="6.75324e-05 -0.00414125 0.0357014" quat="0.509548 0.489669 0.510529 0.489842" mass="0.304091" diaginertia="0.000428415 0.000350261 0.000245055" />
<joint name="joint1-left" pos="0 0 0" axis="0 0 1" range="-3.14 3.14" />
<geom type="mesh" contype="0" conaffinity="0" group="1" density="0" rgba="0.898039 0.917647 0.929412 1" mesh="link1-left" />
<geom type="mesh" rgba="0.898039 0.917647 0.929412 1" mesh="link1-left" />
<geom type="mesh" contype="0" conaffinity="0" group="1" density="0" rgba="0.898039 0.917647 0.929412 1" mesh="link1-left_visual" />
<geom type="mesh" rgba="0.898039 0.917647 0.929412 1" mesh="link1-left" group="3" />
<body name="link2-left" pos="0 -0.04975 0.053" quat="0.707108 0.707105 0 0">
<inertial pos="7.2506e-05 0.080783 -0.0422541" quat="0.437069 -0.554493 0.55751 0.436682" mass="0.238736" diaginertia="0.000254541 0.000233071 0.000168039" />
<inertial pos="7.2506e-05 0.080783 -0.0422541" quat="0.55751 0.436682 -0.437069 0.554493" mass="0.238736" diaginertia="0.000254541 0.000233071 0.000168039" />
<joint name="joint2-left" pos="0 0 0" axis="0 0 1" range="-1.57 1.57" />
<geom pos="0 0 0" quat="0 -1 0 0" type="mesh" contype="0" conaffinity="0" group="1" density="0" rgba="0.898039 0.917647 0.929412 1" mesh="link2-left" />
<geom pos="0 0 0" quat="0 -1 0 0" type="mesh" rgba="0.898039 0.917647 0.929412 1" mesh="link2-left" />
<geom quat="0 -1 0 0" type="mesh" contype="0" conaffinity="0" group="1" density="0" rgba="0.898039 0.917647 0.929412 1" mesh="link2-left_visual" />
<geom quat="0 -1 0 0" type="mesh" rgba="0.898039 0.917647 0.929412 1" mesh="link2-left" group="3" />
<body name="link3-left" pos="0 0.1575 -0.04975" quat="0.707108 -0.707105 0 0">
<inertial pos="0.000612208 0.00229659 0.0517903" quat="0.554126 0.440405 0.547991 0.445751" mass="0.206576" diaginertia="0.000213017 0.000187538 0.000106796" />
<joint name="joint3-left" pos="0 0 0" axis="0 0 1" range="-3.14 3.14" />
<geom type="mesh" contype="0" conaffinity="0" group="1" density="0" rgba="0.898039 0.917647 0.929412 1" mesh="link3-left" />
<geom type="mesh" rgba="0.898039 0.917647 0.929412 1" mesh="link3-left" />
<geom quat="0.707107 0 0 -0.707107" type="mesh" contype="0" conaffinity="0" group="1" density="0" rgba="0.898039 0.917647 0.929412 1" mesh="link3-left_visual" />
<geom quat="0.707107 0 0 -0.707107" type="mesh" rgba="0.898039 0.917647 0.929412 1" mesh="link3-left" group="3" />
<body name="link4-left" pos="0 -0.04125 0.0945" quat="0.707105 0.707108 0 0">
<inertial pos="0.00026874 0.0373909 -0.035949" quat="0.498863 0.503434 -0.501111 0.496565" mass="0.0803293" diaginertia="0.000120598 0.000106626 1.58831e-05" />
<joint name="joint4-left" pos="0 0 0" axis="0 0 1" range="-2.355 0" />
<geom type="mesh" contype="0" conaffinity="0" group="1" density="0" rgba="0.898039 0.917647 0.929412 1" mesh="link4-left" />
<geom type="mesh" rgba="0.898039 0.917647 0.929412 1" mesh="link4-left" />
<geom pos="-0.0038192 0 -0.0416" quat="0.707107 0 -0.707107 0" type="mesh" contype="0" conaffinity="0" group="1" density="0" rgba="0.898039 0.917647 0.929412 1" mesh="link4-left_visual" />
<geom pos="-0.0038192 0 -0.0416" quat="0.707107 0 -0.707107 0" type="mesh" rgba="0.898039 0.917647 0.929412 1" mesh="link4-left" group="3" />
<body name="link5-left" pos="0 0.1315 -0.04125" quat="0.707105 -0.707108 0 0">
<inertial pos="-0.000647708 0.00811978 0.041878" quat="0.703234 -0.0446477 -0.0360034 0.708642" mass="0.171116" diaginertia="0.000175707 0.000110948 8.42989e-05" />
<joint name="joint5-left" pos="0 0 0" axis="0 0 1" range="-3.14 3.14" />
<geom type="mesh" contype="0" conaffinity="0" group="1" density="0" rgba="0.898039 0.917647 0.929412 1" mesh="link5-left" />
<geom type="mesh" rgba="0.898039 0.917647 0.929412 1" mesh="link5-left" />
<geom type="mesh" contype="0" conaffinity="0" group="1" density="0" rgba="0.898039 0.917647 0.929412 1" mesh="link5-left_visual" />
<geom type="mesh" rgba="0.898039 0.917647 0.929412 1" mesh="link5-left" group="3" />
<body name="link6-left" pos="0 -0.0369 0.1145" quat="0.707108 0.707105 0 0">
<inertial pos="0.0160148 0.000660039 -0.0380435" quat="-0.00781159 -0.707189 0.706915 0.00969709" mass="0.0326968" diaginertia="3.0484e-05 2.67251e-05 6.25024e-06" />
<inertial pos="0.0160148 0.000660039 -0.0380435" quat="0.706915 0.00969709 0.00781159 0.707189" mass="0.0326968" diaginertia="3.0484e-05 2.67251e-05 6.25024e-06" />
<joint name="joint6-left" pos="0 0 0" axis="0 0 1" range="-0.785 0.45" />
<geom quat="0 -1 0 0" type="mesh" contype="0" conaffinity="0" group="1" density="0" rgba="0.898039 0.917647 0.929412 1" mesh="link6-left" />
<geom quat="0 -1 0 0" type="mesh" rgba="0.898039 0.917647 0.929412 1" mesh="link6-left" />
<geom quat="0 -1 0 0" type="mesh" contype="0" conaffinity="0" group="1" density="0" rgba="0.898039 0.917647 0.929412 1" mesh="link6-left_visual" />
<geom quat="0 -1 0 0" type="mesh" rgba="0.898039 0.917647 0.929412 1" mesh="link6-left" group="3" />
<body name="link7-left" pos="-0.037 0 -0.0369" quat="0.707105 2.59734e-06 -0.707108 2.59735e-06">
<inertial pos="0.00178605 0.0813605 -0.0221116" quat="0.591603 0.379349 -0.390017 0.594969" mass="0.0935117" diaginertia="5.86461e-05 5.06687e-05 2.54633e-05" />
<joint name="joint7-left" pos="0 0 0" axis="0 0 1" range="-1.05 1.05" />
<geom type="mesh" contype="0" conaffinity="0" group="1" density="0" rgba="1 1 1 1" mesh="link7-left" />
<geom type="mesh" rgba="1 1 1 1" mesh="link7-left" />
<geom type="mesh" contype="0" conaffinity="0" group="1" density="0" rgba="1 1 1 1" mesh="link7-left_visual" />
<geom type="mesh" rgba="1 1 1 1" mesh="link7-left" group="3" />
<body name="tcp-left" pos="0.007 0.23 -0.045">
<site size="0.0025" rgba="1 0 0 1" name="tcp-left" type="sphere" group="1" />
</body>
</body>
</body>
</body>
@ -70,43 +97,52 @@
</body>
</body>
</body>
<body name="link1-right" pos="-0.1478 0.0405 0.441" quat="0.499998 0.5 -0.500002 -0.5">
<body name="link1-right" pos="-0.0405 -0.1478 0.441" quat="0.707105 0.707108 -1.29868e-06 -1.29867e-06">
<inertial pos="0.00186095 -6.57028e-05 0.0370126" quat="0.707342 0.706656 -0.0127919 0.0118593" mass="0.286348" diaginertia="0.000422643 0.00034441 0.000244327" />
<joint name="joint1-right" pos="0 0 0" axis="0 0 1" range="-3.14 3.14" />
<geom type="mesh" contype="0" conaffinity="0" group="1" density="0" rgba="0.898039 0.917647 0.929412 1" mesh="link1-right" />
<geom type="mesh" rgba="0.898039 0.917647 0.929412 1" mesh="link1-right" />
<geom type="mesh" contype="0" conaffinity="0" group="1" density="0" rgba="0.898039 0.917647 0.929412 1" mesh="link1-right_visual" />
<geom type="mesh" rgba="0.898039 0.917647 0.929412 1" mesh="link1-right" group="3" />
<body name="link2-right" pos="0.04975 0 0.053" quat="0.499998 -0.5 0.500002 -0.5">
<inertial pos="7.27313e-05 -0.080783 -0.0425927" quat="0.434354 0.554857 -0.55773 0.438642" mass="0.238736" diaginertia="0.000254603 0.00023307 0.000167979" />
<joint name="joint2-right" pos="0 0 0" axis="0 0 1" range="-1.57 1.57" />
<geom type="mesh" contype="0" conaffinity="0" group="1" density="0" rgba="0.898039 0.917647 0.929412 1" mesh="link2-right" />
<geom type="mesh" rgba="0.898039 0.917647 0.929412 1" mesh="link2-right" />
<geom type="mesh" contype="0" conaffinity="0" group="1" density="0" rgba="0.898039 0.917647 0.929412 1" mesh="link2-right_visual" />
<geom type="mesh" rgba="0.898039 0.917647 0.929412 1" mesh="link2-right" group="3" />
<body name="link3-right" pos="0 -0.164 -0.04975" quat="0.499998 0.5 -0.5 0.500002">
<inertial pos="-0.00460139 0.00042661 0.0434471" quat="0.703869 0.701746 -0.0777895 0.0779152" mass="0.19403" diaginertia="0.000209946 0.000185096 0.000105795" />
<joint name="joint3-right" pos="0 0 0" axis="0 0 1" range="-3.14 3.14" />
<geom type="mesh" contype="0" conaffinity="0" group="1" density="0" rgba="0.898039 0.917647 0.929412 1" mesh="link3-right" />
<geom type="mesh" rgba="0.898039 0.917647 0.929412 1" mesh="link3-right" />
<geom quat="0.707107 0 0 0.707107" type="mesh" contype="0" conaffinity="0" group="1" density="0" rgba="0.898039 0.917647 0.929412 1" mesh="link3-right_visual" />
<geom quat="0.707107 0 0 0.707107" type="mesh" rgba="0.898039 0.917647 0.929412 1" mesh="link3-right" group="3" />
<body name="link4-right" pos="0.04125 0 0.088" quat="0.499998 -0.5 0.500002 -0.5">
<inertial pos="0.000268623 -0.0373908 -0.0354483" quat="0.501111 0.496565 -0.498863 0.503434" mass="0.0803292" diaginertia="0.000120598 0.000106626 1.58831e-05" />
<joint name="joint4-right" pos="0 0 0" axis="0 0 1" range="0 2.355" />
<geom type="mesh" contype="0" conaffinity="0" group="1" density="0" rgba="0.898039 0.917647 0.929412 1" mesh="link4-right" />
<geom type="mesh" rgba="0.898039 0.917647 0.929412 1" mesh="link4-right" />
<geom pos="0.0038192 0 -0.0416" quat="0.707107 0 -0.707107 0" type="mesh" contype="0" conaffinity="0" group="1" density="0" rgba="0.898039 0.917647 0.929412 1" mesh="link4-right_visual" />
<geom pos="0.0038192 0 -0.0416" quat="0.707107 0 -0.707107 0" type="mesh" rgba="0.898039 0.917647 0.929412 1" mesh="link4-right" group="3" />
<body name="link5-right" pos="0 -0.1315 -0.04125" quat="0.499998 0.5 -0.5 0.500002">
<inertial pos="-0.0081198 0.000647653 0.0416257" quat="0.998699 -0.0504829 -0.00612479 -0.00374546" mass="0.171116" diaginertia="0.000175707 0.000110871 8.43751e-05" />
<joint name="joint5-right" pos="0 0 0" axis="0 0 1" range="-3.14 3.14" />
<geom type="mesh" contype="0" conaffinity="0" group="1" density="0" rgba="0.898039 0.917647 0.929412 1" mesh="link5-right" />
<geom type="mesh" rgba="0.898039 0.917647 0.929412 1" mesh="link5-right" />
<geom type="mesh" contype="0" conaffinity="0" group="1" density="0" rgba="0.898039 0.917647 0.929412 1" mesh="link5-right_visual" />
<geom type="mesh" rgba="0.898039 0.917647 0.929412 1" mesh="link5-right" group="3" />
<body name="link6-right" pos="0.0369 0 0.1145" quat="0.499998 -0.5 0.500002 -0.5">
<inertial pos="0.0160148 -0.000660099 -0.0368135" quat="0.706915 0.00969709 0.00781159 0.707189" mass="0.0326968" diaginertia="3.0484e-05 2.67251e-05 6.25024e-06" />
<joint name="joint6-right" pos="0 0 0" axis="0 0 1" range="-0.45 0.785" />
<geom type="mesh" contype="0" conaffinity="0" group="1" density="0" rgba="0.898039 0.917647 0.929412 1" mesh="link6-right" />
<geom type="mesh" rgba="0.898039 0.917647 0.929412 1" mesh="link6-right" />
<geom type="mesh" contype="0" conaffinity="0" group="1" density="0" rgba="0.898039 0.917647 0.929412 1" mesh="link6-right_visual" />
<geom type="mesh" rgba="0.898039 0.917647 0.929412 1" mesh="link6-right" group="3" />
<body name="link7-right" pos="-0.037 0 -0.0369" quat="0.707105 0 -0.707108 0">
<inertial pos="-7.26286e-06 0.0250589 0.014929" quat="0.34053 0.620312 -0.619198 0.34036" mass="0.0419947" diaginertia="3.51757e-05 3.12202e-05 1.41845e-05" />
<joint name="joint7-right" pos="0 0 0" axis="0 0 1" range="-1.05 1.05" />
<geom quat="0 1 0 0" type="mesh" contype="0" conaffinity="0" group="1" density="0" rgba="0.898039 0.917647 0.929412 1" mesh="link7-right" />
<geom quat="0 1 0 0" type="mesh" rgba="0.898039 0.917647 0.929412 1" mesh="link7-right" />
<geom name="mirrored_right_hand_visual" pos="0 0 0" quat="0 1 0 0" type="mesh" contype="0" conaffinity="0" group="1" density="0" rgba="1 1 1 1" mesh="hand-right-mirrored" />
<geom name="mirrored_right_hand_collision" pos="0 0 0" quat="0 1 0 0" type="mesh" rgba="1 1 1 1" mesh="hand-right-mirrored" />
<geom pos="0 0 0" quat="0 1 0 0" type="mesh" contype="0" conaffinity="0" group="1" density="0" rgba="1 1 1 1" mesh="link7-right_visual" />
<geom pos="0 0 0" quat="0 1 0 0" type="mesh" rgba="1 1 1 1" mesh="link7-right" group="3" />
<body name="tcp-right" pos="0.007 -0.23 -0.045">
<site size="0.0025" rgba="1 0 0 1" name="tcp-right" type="sphere" group="1" />
</body>
<body name="hand_camera_mount" pos="0.0325 -0.12605 0.036">
<camera name="hand_cam" pos="0 0 0" quat="0 0 0.7071067811865476 0.7071067811865476" fovy="60" />
<geom name="hand_camera_lens" type="cylinder" pos="0 0.00025 0" quat="0.7071067811865476 0.7071067811865476 0 0" size="0.0025 0.0002" rgba="0.05 0.12 0.18 1" mass="0" contype="0" conaffinity="0" group="1" />
</body>
<body name="R_HAND_APRILTAG" pos="0.0345 -0.0946 0.036" quat="0.7071067811865476 -0.7071067811865476 0 0">
<geom name="R_HAND_APRILTAG_GEOM" type="box" size="0.01 0.01 0.0003" material="hand_apriltag_mat" rgba="1 1 1 1" mass="0" contype="0" conaffinity="0" group="2" />
<site name="R_HAND_APRILTAG_SITE" pos="0 0 0" size="0.002" rgba="1 0 1 0" />
</body>
</body>
</body>
</body>
@ -114,12 +150,29 @@
</body>
</body>
</body>
<body name="neck_Link1" pos="-0.0405 0 0.5195" quat="0.707107 0 0 0.707107">
<inertial pos="0.0151599 -6.12013e-08 0.0402005" quat="0.990522 -9.51036e-07 0.137352 4.13566e-06" mass="0.189845" diaginertia="0.000279557 0.000265167 9.02885e-05" />
<joint name="neck-joint1" pos="0 0 0" axis="0 0 1" range="-1.57 1.57" />
<geom type="mesh" contype="0" conaffinity="0" group="1" density="0" rgba="1 1 1 1" mesh="neck_Link1_visual" />
<geom type="mesh" rgba="1 1 1 1" mesh="neck_Link1" group="3" />
<body name="neck_Link2" pos="0.031 0 0.1085" quat="0.707105 0 0.707108 0">
<inertial pos="-2.81713e-05 -0.00170019 -0.0313059" quat="0.702579 -0.0761365 0.0834642 0.702581" mass="0.12185" diaginertia="5.84236e-05 4.54167e-05 3.63665e-05" />
<joint name="neck-joint2" pos="0 0 0" axis="0 0 1" range="-1.57 0.44" />
<geom type="mesh" contype="0" conaffinity="0" group="1" density="0" rgba="1 1 1 1" mesh="neck_Link2_visual" />
<geom type="mesh" rgba="1 1 1 1" mesh="neck_Link2" group="3" />
<body name="neck_Link3" pos="0 0.0035 -0.035" quat="0.499998 0.5 -0.5 0.500002">
<inertial pos="0.000267765 0.0821521 0.0266246" quat="0.541671 0.45374 -0.460711 0.537083" mass="0.521691" diaginertia="0.00207398 0.00140524 0.00121223" />
<joint name="neck-joint3" pos="0 0 0" axis="0 0 1" range="-0.44 0.44" />
<geom type="mesh" contype="0" conaffinity="0" group="1" density="0" rgba="0.631373 0.658824 0.678431 1" mesh="neck_Link3_visual" />
<geom type="mesh" rgba="0.631373 0.658824 0.678431 1" mesh="neck_Link3" group="3" />
<body name="external_camera_mount" pos="0.0325 0.10347742 0.08039297">
<camera name="external_touch_cam" pos="0 0 0" quat="0 0 0.963863295733281 0.26639734821911742" fovy="50" />
<site name="external_touch_cam_site" size="0.001" rgba="0.1 0.8 0.3 0" quat="0 0 0.963863295733281 0.26639734821911742" />
<geom name="external_camera_lens" type="cylinder" pos="0 0.000125 -0.000216506351" quat="0.9659258262890683 0.25881904510252074 0 0" size="0.0025 0.0002" rgba="0.05 0.12 0.18 1" mass="0" contype="0" conaffinity="0" group="1" />
</body>
</body>
</body>
</body>
</body>
</worldbody>
<contact>
<!-- These adjacent mounting meshes overlap at the shoulder joints.
The fixed base is welded to world, so MuJoCo's parent filter does not exclude them. -->
<exclude body1="base_link" body2="link1-left" />
<exclude body1="base_link" body2="link1-right" />
</contact>
</mujoco>