Mujoco机械臂场景修改实操:为SO-Arm100添加桌子
2026-03-27 来源:EEWorld 论坛
Mujoco机械臂场景修改实操:为SO-Arm100添加桌子
在机器人仿真中,Mujoco是一个常用的工具,但默认的机械臂模型往往直接放置在地面上,这与实际应用场景如安装在桌子上或底盘上不符。因此,修改场景模型文件成为必要步骤。本文以SO-Arm100机械臂为例,详细介绍如何为其添加一个桌子,提升仿真真实性。
原有场景分析
SO-Arm100原有的场景文件仅包含基本环境元素,如地面和天空。其XML代码主要包括视觉设置、资产定义和世界体,其中世界体中只有地板几何体。这种配置无法满足机械臂安装在桌面上的需求。
<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场景
为了简化操作,可以参考ALOHA场景中的桌子模型,避免自行寻找Mesh文件。ALOHA场景提供了现成的桌子组件,包括桌腿和桌面,可直接复用。
修改步骤详解
修改SO-Arm100场景文件以添加桌子,主要分为以下步骤:
- 放置模型文件:将桌子的Mesh文件(如tablelegs.obj和tabletop.obj)放入assets文件夹中。
- 添加路径说明:在XML中通过<compiler>标签指定mesh和texture目录。
- 添加Mesh和Texture描述:在<asset>部分定义Mesh和材质,确保桌子有正确的纹理。
- 添加位置关系描述:在<worldbody>中放置桌子几何体,调整位置和旋转,使其与机械臂匹配。
修改后的场景文件
以下是将上述步骤整合后的完整XML代码,可另存为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>结果与总结
通过上述修改,SO-Arm100机械臂现在被放置在桌子上,场景更贴近真实应用。运行仿真命令如simulate trs_so_arm100/scene_with_table.xml即可查看效果。此方法可推广到其他机械臂模型,灵活调整场景元素。
想了解更多细节、观看视频讲解或查看原始图片,请阅读原帖子:机械臂如何稳稳上桌?Mujoco场景修改实操。
原帖子内容来源:https://bbs.eeworld.com.cn/thread-1310579-1-1.html
相关文章




