视频讲解:
机械臂如何稳稳上桌?Mujoco场景修改实操
前面《常见机械臂模型不用找!Mujoco这儿都有!》中介绍的mujoco-menagerie中机械臂大多都是base_link放在地上的,这些场景往往和真实的场景对应不上,比如机械臂可能是安装在桌子上,或者安装在底盘上,所以就涉及到修改场景模型文件,今天我们就以so-arm100这个机械臂为例,为其添加一个桌子。
首先我们看下so-arm100原有的场景文件
<mujoco model="so_arm100 scene"><include file="so_arm100.xml"/><statistic center="0 -0.2 0.1" extent="0.4"/><visual><headlight diffuse="0.6 0.6 0.6" ambient="0.3 0.3 0.3" specular="0 0 0"/><rgba haze="0.15 0.25 0.35 1"/><global azimuth="140" elevation="-30"/></visual><asset><texture type="skybox" builtin="gradient" rgb1="0.3 0.5 0.7" rgb2="0 0 0" width="512" height="3072"/><texture type="2d" name="groundplane" builtin="checker" mark="edge" rgb1="0.2 0.3 0.4" rgb2="0.1 0.2 0.3"markrgb="0.8 0.8 0.8" width="300" height="300"/><material name="groundplane" texture="groundplane" texuniform="true" texrepeat="5 5" reflectance="0.2"/></asset><worldbody><light pos="0 0 1.5" dir="0 0 -1" directional="true"/><geom name="floor" size="0 0 0.05" type="plane" material="groundplane"/></worldbody>
</mujoco>
原有模型只描述了地面、天空等环境
我们可以参考aloha的场景,他是有桌子的,最起码桌子的mesh文件不用自己找了
然后在so-arm100的scene.xml上做修改,大概如下的步骤:
a. 首先需要把桌子的模型放进assets文件夹中
b. 然后添加路径说明
c. 添加mesh文件以及texture描述
d. 添加位置关系描述
修改后的文件如下,可以重新命名为scene_with_table.xml
<mujoco model="so_arm100 scene"><compiler meshdir="assets" texturedir="assets"/><include file="so_arm100.xml"/><statistic center="0 -0.2 0.1" extent="0.4"/><visual><headlight diffuse="0.6 0.6 0.6" ambient="0.3 0.3 0.3" specular="0 0 0"/><rgba haze="0.15 0.25 0.35 1"/><global azimuth="140" elevation="-30"/></visual><asset><mesh file="tablelegs.obj"/><mesh file="tabletop.obj"/><texture type="skybox" builtin="gradient" rgb1="0.3 0.5 0.7" rgb2="0 0 0" width="512" height="3072"/><texture type="2d" name="groundplane" builtin="checker" mark="edge" rgb1="0.2 0.3 0.4" rgb2="0.1 0.2 0.3"markrgb="0.8 0.8 0.8" width="300" height="300"/><texture type="2d" file="small_meta_table_diffuse.png"/><material name="groundplane" texture="groundplane" texuniform="true" texrepeat="5 5" reflectance="0.2"/><material name="table" texture="small_meta_table_diffuse"/></asset><worldbody><light pos="0 0 1.5" dir="0 0 -1" directional="true"/><geom name="floor" size="0 0 0.05" type="plane" material="groundplane" pos="0 0 -.75"/><site name="worldref" pos="0 0 -0.75"/><geom mesh="tabletop" material="table" class="visual" pos="0 0 -0.75" quat="1 0 0 1"/><geom mesh="tablelegs" material="table" class="visual" pos="0 0 -0.75" quat="1 0 0 1"/><geom name="table" pos="0 0 -0.1009" size="0.61 0.37 0.1" type="box" class="collision"/><camera name="overhead_cam" focal="1.93e-3 1.93e-3" resolution="1280 720" sensorsize="3896e-6 2140e-6"pos="0 -0.303794 1.02524" mode="fixed" quat="0.976332 0.216277 0 0"/><camera name="worms_eye_cam" focal="1.93e-3 1.93e-3" resolution="1280 720" sensorsize="3896e-6 2140e-6"pos="0 -0.377167 0.0316055" mode="fixed" quat="0.672659 0.739953 0 0"/></worldbody>
</mujoco>
simulate trs_so_arm100/scene_with_table.xml