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>

效果

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

相关推荐
哥布林学者1 小时前
高光谱成像(一)高光谱图像
机器学习·高光谱成像
罗西的思考2 小时前
AI Agent框架探秘:拆解 OpenHands(10)--- Runtime
人工智能·算法·机器学习
冬奇Lab3 小时前
OpenClaw 源码精读(2):Channel & Routing——一条消息如何找到它的 Agent?
人工智能·开源·源码阅读
冬奇Lab3 小时前
一天一个开源项目(第38篇):Claude Code Telegram - 用 Telegram 远程用 Claude Code,随时随地聊项目
人工智能·开源·资讯
格砸4 小时前
从入门到辞职|从ChatGPT到OpenClaw,跟上智能时代的进化
前端·人工智能·后端
可观测性用观测云5 小时前
可观测性 4.0:教系统如何思考
人工智能
sunny8655 小时前
Claude Code 跨会话上下文恢复:从 8 次纠正到 0 次的工程实践
人工智能·开源·github
小笼包包仔5 小时前
OpenClaw 多Agent软件开发最佳实践指南
人工智能
smallyoung5 小时前
AgenticRAG:智能体驱动的检索增强生成
人工智能
_skyming_5 小时前
OpenCode 如何做到结果不做自动质量评估,为什么结果还不错?
人工智能