robot_embodiments / arms /armbot /example_mujoco.xml
alfonsusrr's picture
Add files using upload-large-folder tool
f149cc6 verified
Raw History Blame Contribute Delete
13.1 kB
<mujoco model="world_box_reference">
<!-- 本文件统一使用米、千克、秒和弧度作为单位。 -->
<compiler angle="radian" autolimits="true"/>
<option timestep="0.002" integrator="implicitfast" gravity="0 0 -9.81"/>
<visual>
<headlight ambient="0.35 0.35 0.35"
diffuse="0.75 0.75 0.75"
specular="0.2 0.2 0.2"/>
<global azimuth="135" elevation="-25"/>
</visual>
<asset>
<texture name="floor_grid"
type="2d"
builtin="checker"
width="512"
height="512"
rgb1="0.82 0.84 0.87"
rgb2="0.94 0.95 0.97"/>
<material name="floor_material"
texture="floor_grid"
texrepeat="8 8"
texuniform="true"
reflectance="0.05"/>
</asset>
<!--
CyberGear 参数元数据,仅供控制程序读取或作为模型说明,不会自动改变 MuJoCo 动力学。
机械输出端参数来自《CyberGear微电机使用说明书》:
额定转矩 4 N·m,峰值转矩 12 N·m;
额定转速 240 rpm = 25.133 rad/s;
空载转速 296 rpm = 30.997 rad/s;
运控协议速度范围 ±30 rad/s,位置编码范围 ±4π rad;
减速比 7.75:1,电机总质量 0.317 kg。
手册没有给出转子惯量、粘性阻尼、库仑摩擦和回差,不能在此凭空填写。
-->
<custom>
<numeric name="cybergear_rated_voltage_v" data="24"/>
<numeric name="cybergear_min_voltage_v" data="16"/>
<numeric name="cybergear_max_voltage_v" data="28"/>
<numeric name="cybergear_rated_torque_nm" data="4"/>
<numeric name="cybergear_peak_torque_nm" data="12"/>
<numeric name="cybergear_rated_speed_rad_s" data="25.132741"/>
<numeric name="cybergear_no_load_speed_rad_s" data="30.997048"/>
<numeric name="cybergear_command_speed_limit_rad_s" data="30"/>
<numeric name="cybergear_protocol_position_limit_rad" data="12.566371"/>
<numeric name="cybergear_rated_current_a" data="6.5"/>
<numeric name="cybergear_peak_current_a" data="23"/>
<numeric name="cybergear_torque_constant_nm_a" data="0.87"/>
<numeric name="cybergear_reduction_ratio" data="7.75"/>
<numeric name="cybergear_total_mass_kg" data="0.317"/>
<numeric name="cybergear_encoder_counts_per_rev" data="16384"/>
<!-- 以下两项为仿真初始估计值,不是说明书标称参数。 -->
<numeric name="cybergear_estimated_frictionloss_nm" data="0.12"/>
<numeric name="cybergear_estimated_damping_nm_s_rad" data="0.010"/>
</custom>
<worldbody>
<light name="main_light" pos="1 -1 2" dir="-1 1 -2"/>
<camera name="overview"
pos="1.4 -1.4 1.0"
xyaxes="0.707 0.707 0 -0.333 0.333 0.882"/>
<!--
plane 的前两个 size 数值表示可视区域在 X、Y 方向上的半尺寸。
此处显示为约 6 m × 6 m 的地面,但物理碰撞平面是无限大的。
plane 的默认法向为 +Z,因此 pos 的 Z=0 表示地面位于世界坐标 Z=0。
-->
<geom name="floor"
type="plane"
pos="0 0 0"
size="3 3 0.1"
material="floor_material"
friction="1.0 0.01 0.001"/>
<!--
固定底座的实际尺寸:
0.30 m × 0.25 m × 0.08 m
box 的 size 使用各方向的半尺寸:
0.15 m × 0.125 m × 0.04 m
将几何中心放在 Z=0.04,可使底座底面正好落在 Z=0 的地面上。
-->
<geom name="fixed_base"
type="box"
pos="0 0 0.02"
size="0.3 0.3 0.022"
rgba="0.25 0.30 0.38 1"
friction="0.9 0.01 0.001"/>
<!--
这是一个边长为 0.10 m、带自由关节的立方体。
仿真开始后,它会从 Z=0.60 m 的位置下落并与地面碰撞。
-->
<body name="falling_cube" pos="0.45 0 0.60">
<freejoint/>
<geom name="falling_cube_geom"
type="box"
size="0.084 0.084 0.084"
mass="1.0"
rgba="0.90 0.25 0.15 1"/>
</body>
<!--
link1 是固定立柱,不设置 joint,因此与世界坐标系刚性连接。
底座顶面高度:0.02 + 0.022 = 0.042 m。
link1 的完整高度:0.084 × 2 = 0.168 m。
link1 的 body 原点放在底座顶面,几何中心向上偏移 0.084 m,
因此 link1 的底面与底座顶面正好贴合。
-->
<body name="link1" pos="0 0 0.042">
<geom name="link1_box"
type="box"
pos="0 0 0.084"
size="0.084 0.084 0.084"
mass="0.440"
rgba="0.42 0.45 0.50 1"/>
<site name="link1_tip"
type="sphere"
pos="0 0 0.168"
size="0.012"
rgba="1 0.1 0.1 1"/>
<!--
MuJoCo 的 joint 必须定义在相对父 body 运动的子 body 中。
link2 位于 link1 顶面,joint1 的转轴取 Z 轴方向。
link1 顶面是 XY 平面,因此 axis="0 0 1" 垂直于顶面;
link2 将绕穿过顶面中心的 Z 轴做一维旋转。
-->
<body name="link2" pos="0 0 0.168">
<!--
摩擦初始估计:
frictionloss="0.12" 表示约 0.12 N·m 的库仑摩擦力矩;
damping="0.010" 表示 0.010 N·m·s/rad 的线性粘性阻尼。
在空载转速 30.997 rad/s 时,总阻力矩约为:
0.12 + 0.010 × 30.997 ≈ 0.43 N·m。
这与手册空载电流 0.5 Arms × 转矩常数 0.87 N·m/Arms
得到的约 0.435 N·m 接近,适合作为首次仿真的保守起点。
该拆分值并非厂家标定结果,后续应通过实机自由减速或阶跃实验辨识。
电机可连续多圈旋转,没有机械刚性限位,因此 limited="false",
不设置 range;qpos 中的关节角可以超过 ±2π 并持续累积。
-->
<joint name="joint1"
type="hinge"
pos="0 0 0"
axis="0 0 1"
limited="false"
damping="0.010"
frictionloss="0.12"/>
<!--
用薄圆柱表示居中的电机输出转轴。
转轴直径 33 mm,所以半径为 0.0165 m。
cylinder 的 size 为“半径、半高”,因此半高 0.0005 m
对应完整厚度 0.001 m,即 1 mm。
转轴质量尚未提供,mass="0" 表示暂不计入 link2 的质量和惯量。
-->
<geom name="joint1_shaft"
type="cylinder"
pos="0 0 0.0005"
size="0.0165 0.0005"
mass="0"
rgba="0.28 0.32 0.40 1"/>
<!--
link2_box 与 link1_box 尺寸完全相同:
完整尺寸为 0.168 m × 0.168 m × 0.168 m。
转轴顶面位于 Z=0.001 m,因此方块中心放在
0.001 + 0.084 = 0.085 m,使其底面正好落在转轴顶面。
-->
<geom name="link2_box"
type="box"
pos="0 0 0.085"
size="0.084 0.084 0.084"
mass="0.130"
rgba="0.90 0.91 0.93 1"/>
<site name="link2_tip"
type="sphere"
pos="0 0 0.169"
size="0.010"
rgba="0.10 0.90 0.20 1"/>
<!--
第二组连杆安装在 link2 的局部 +X 侧面。
link3 是 link1 的复制体,直接粘连在 link2 侧面,不设置 joint。
link3 的 body 原点位于 link2 的 +X 侧面中心:
link2_box 的 +X 侧面为 X=0.084 m;
link2_box 的中心高度为 Z=0.085 m。
euler 绕 Y 轴旋转 +90°,使复制体原来的局部 +Z 方向指向
link2 的局部 +X 方向。这样 link3 会从 link2 侧面向外延伸。
-->
<body name="link3"
pos="0.084 0 0.085"
euler="0 1.57079632679 0">
<geom name="link3_box"
type="box"
pos="0 0 0.084"
size="0.084 0.084 0.084"
mass="0.440"
rgba="0.42 0.45 0.50 1"/>
<site name="link3_tip"
type="sphere"
pos="0 0 0.168"
size="0.012"
rgba="1 0.45 0.10 1"/>
<!--
link4 是 link2 的复制体,并通过 joint2 与 link3 相连。
joint2 在 link3 外侧面的中心,轴线沿复制体的局部 Z 轴。
由于 link3 已绕 Y 轴转过 90°,joint2 的轴线在 link2
局部坐标中就是 +X,旋转平面为 YZ。
joint1 的轴线为 Z、旋转平面为 XY,因此 joint2 的旋转平面
与 joint1 的旋转平面互相垂直。
-->
<body name="link4" pos="0 0 0.168">
<joint name="joint2"
type="hinge"
pos="0 0 0"
axis="0 0 1"
limited="false"
damping="0.010"
frictionloss="0.12"/>
<!-- 第二个 CyberGear 转轴:直径 33 mm,完整厚度 1 mm。 -->
<geom name="joint2_shaft"
type="cylinder"
pos="0 0 0.0005"
size="0.0165 0.0005"
mass="0"
rgba="0.28 0.32 0.40 1"/>
<geom name="link4_box"
type="box"
pos="0 0 0.085"
size="0.084 0.084 0.084"
mass="0.130"
rgba="0.90 0.91 0.93 1"/>
<site name="link4_tip"
type="sphere"
pos="0 0 0.169"
size="0.010"
rgba="0.15 0.80 1.00 1"/>
<!--
在 link4_box 的局部 +Y 侧面连接三个 link4 复制体:
link5、link6、link7 均为 0.168 m 立方体;
每块质量 0.130 kg,颜色与从动块相同;
三者不设置 joint,因此与 link4 刚性连接并随 joint2 一起运动。
link4_box 的 +Y 侧面位于 Y=0.084 m,侧面中心高度为 Z=0.085 m。
link5 的 body 原点放在该侧面中心,并绕局部 X 轴旋转 -90°,
使 link5 原来的局部 +Z 延伸方向转为 link4 的局部 +Y。
link6、link7 再沿 link5 的局部 +Z 方向依次粘连。
-->
<body name="link5"
pos="0 0.084 0.085"
euler="-1.57079632679 0 0">
<geom name="link5_box"
type="box"
pos="0 0 0.084"
size="0.084 0.084 0.084"
mass="0.130"
rgba="0.90 0.91 0.93 1"/>
<body name="link6" pos="0 0 0.168">
<geom name="link6_box"
type="box"
pos="0 0 0.084"
size="0.084 0.084 0.084"
mass="0.130"
rgba="0.90 0.91 0.93 1"/>
<body name="link7" pos="0 0 0.168">
<geom name="link7_box"
type="box"
pos="0 0 0.084"
size="0.084 0.084 0.084"
mass="0.130"
rgba="0.90 0.91 0.93 1"/>
<site name="arm_tip"
type="sphere"
pos="0 0 0.168"
size="0.010"
rgba="0.95 0.25 0.20 1"/>
</body>
</body>
</body>
</body>
</body>
</body>
</body>
</worldbody>
<actuator>
<!--
CyberGear 手册给出的 4 N·m 额定转矩和 12 N·m 峰值转矩是负载输出端参数。
因此本模型直接在输出关节上施加力矩,gear="1",不能再乘 7.75,
否则会把内置减速比重复计算一次。
ctrl 的单位为 N·m,允许范围 ±12 N·m;forcerange 再做一次硬限幅。
12 N·m 只能短时使用,持续运行应由控制程序按照 4 N·m 额定值和
手册过载时间曲线进行热保护。
手册没有直接给出转子惯量、粘性阻尼和摩擦参数,因此暂不填写
armature;joint1、joint2 中的 damping 和 frictionloss 是依据空载数据配置的
初始估计值,后续仍应通过实物辨识修正。
-->
<motor name="joint1_motor"
joint="joint1"
gear="1"
ctrlrange="-12 12"
forcerange="-12 12"/>
<motor name="joint2_motor"
joint="joint2"
gear="1"
ctrlrange="-12 12"
forcerange="-12 12"/>
</actuator>
<keyframe>
<!--
qpos 顺序:自由关节的位置 xyz、四元数 wxyz、joint1 角度、joint2 角度。
ctrl 顺序:joint1_motor、joint2_motor。
-->
<key name="home" qpos="0.45 0 0.60 1 0 0 0 0 0" ctrl="0 0"/>
</keyframe>
</mujoco>