xml创建模型组合体

XML创建模型组合体


创建步骤

模型准备

CAD 提供的原始模型如下:

该模型存在的问题:

  1. 单位问题:CAD出图的是 mm 为单位,但是 mujoco 建模这边用的是以 m 为单位的;
  2. 原点问题:CAD作图时,没有坐标原点的概念,为了能更好的控制模型的位置,需要确定模型的原点,将物体的某一个特征点移动到 (0, 0, 0)
  3. 姿态问题:暂无

模型处理

姿态:关于模型姿态问题,暂时不处理,需要在作图时保障与坐标轴平行

位置纠偏

  1. CC 里把模型打开
  2. 统一度量衡,对模型整体进行缩放,操作:CC->Edit->scale
  3. 查看模型属性,主要是 Global box center 这个参数
  4. 然后根据 Box dimension 计算需要平移的值
  5. 平移模型, 操作: CC->Edit-> Apply transformation

模型文件XML编写

复制代码
<mujoco model="air_condition_outdoor">
  <asset>
    <mesh file="./meshes/air_condition_outdoor.stl" name="base" scale="0.5 0.5 0.5"/>
  </asset>
  <worldbody>
    <body>
      <body name="object">
        <inertial pos="0 0 0" mass="0.05" diaginertia="0.002 0.002 0.002" />
        <geom pos="0. 0. 0.0" quat="1  0 0 0  " mesh="base" type="mesh" solimp="0.998 0.998 0.001" solref="0.001 1" density="100" friction="1 1 1" group="0" condim="4" rgba="0.839 0.839 0.839 1"/>
        <geom pos="-0.1001 -0.0564 0.264" size="0.002 0.005" quat="0 0 0.707 0.707" type="cylinder" rgba="1. 0. 0. 1.0" solimp="0.998 0.998 0.001" solref="0.02 1" density="100" friction="0.95 0.3 0.1" group="0" condim="4" />
        <geom pos=" 0.1001 -0.0564 0.264" size="0.002 0.005" quat="0 0 0.707 0.707" type="cylinder" rgba="1. 0. 0. 1.0" solimp="0.998 0.998 0.001" solref="0.02 1" density="100" friction="0.95 0.3 0.1" group="0" condim="4" />
        <geom pos="-0.1001 -0.0564 0.27" size="0.002 0.005" quat="0 0 0 1.0" type="cylinder" rgba="1. 0. 0. 1.0" solimp="0.998 0.998 0.001" solref="0.02 1" density="100" friction="0.95 0.3 0.1" group="0" condim="4" />
        <geom pos=" 0.1001 -0.0564 0.27" size="0.002 0.005" quat="0 0 0 1.0" type="cylinder" rgba="1. 0. 0. 1.0" solimp="0.998 0.998 0.001" solref="0.02 1" density="100" friction="0.95 0.3 0.1" group="0" condim="4" />
      </body>
      <body name="visual">
        <inertial pos="0 0 0" mass="0.05" diaginertia="0.002 0.002 0.002" />
        <geom pos="0 0 0" mesh="base" type="mesh" conaffinity="0" contype="0"  group="0" mass="0.0001" rgba="0.8 0.8 0.8 0.1"/>
      </body>
      <site rgba="0 0 0 0" size="0.005" pos="0 0 -0.004" name="bottom_site"/>
      <site rgba="0 0 0 0" size="0.005" pos="0 0 0.004" name="top_site"/>
      <site rgba="0 0 0 0" size="0.005" pos="0. 0. 0" name="horizontal_radius_site"/>
      <site rgba="0 0 0 0" size="0.005" pos="-0.1001 -0.0564 0.1295" name="hole_0_site"/>
    </body>
  </worldbody>
</mujoco>

效果

红色小柱子为模拟的该位置的螺丝孔

相关推荐
yaoyouzhong1 分钟前
2026 年 GPT 与 Gemini 怎么选?AI 工具适配哪些场景?
人工智能·gpt
码农阿强3 分钟前
GPT-Image-2 技术原理与实战:开启推理驱动图像生成新时代
人工智能·gpt·ai·aigc·个人开发
Ajie'Blog8 分钟前
Claude Opus 4.8 发布:Claude Code 能不能接住复杂项目
服务器·前端·javascript·人工智能·ai编程
码农小旋风9 分钟前
Agent框架开发实践
人工智能·chatgpt·claude
小橙讲编程10 分钟前
PaddleOCR 3.6 深度解析:0.9B 参数如何跑出 96.3% 准确率,登顶文档解析 SOTA?
人工智能·开源·github
sunneo13 分钟前
S5.2 兴趣培养——让用户从“看看“变成“想了解更多“
人工智能·产品运营·产品经理·用户运营·用户体验
xiezhr15 分钟前
折腾了一下午,终于让Codex用上了DeepSeek
人工智能·openai·deepseek
lauo16 分钟前
ibbot角色智能体 v2.0 升级公告:全新上下文限制功能上线————灵活适配速度与深度,让每位数字伙伴更懂你
人工智能·智能手机·电脑·娱乐