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>

效果

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

相关推荐
whaosoft-14339 分钟前
51c自动驾驶~合集7
人工智能
刘晓倩4 小时前
Coze智能体开发实战-多Agent综合实战
人工智能·coze
石迹耿千秋5 小时前
迁移学习--基于torchvision中VGG16模型的实战
人工智能·pytorch·机器学习·迁移学习
Wendy14417 小时前
【线性回归(最小二乘法MSE)】——机器学习
算法·机器学习·线性回归
路人蛃8 小时前
通过国内扣子(Coze)搭建智能体并接入discord机器人
人工智能·python·ubuntu·ai·aigc·个人开发
CV-杨帆8 小时前
论文阅读:arxiv 2025 A Survey of Large Language Model Agents for Question Answering
论文阅读·人工智能·语言模型
绝顶大聪明8 小时前
【深度学习】神经网络-part2
人工智能·深度学习·神经网络
加百力9 小时前
AI助手竞争白热化,微软Copilot面临ChatGPT的9亿下载挑战
人工智能·microsoft·copilot
Danceful_YJ9 小时前
16.使用ResNet网络进行Fashion-Mnist分类
人工智能·深度学习·神经网络·resnet
iFulling9 小时前
【计算机网络】第四章:网络层(上)
学习·计算机网络