feat(model): regenerate xiaozhao visual meshes from urdf9 sources
This commit is contained in:
parent
f2d8910bea
commit
e48ba8ab35
@ -10,10 +10,9 @@
|
||||
xiaozhao 的双臂关节名为 `joint1-left`…`joint7-left` 和
|
||||
`joint1-right`…`joint7-right`,不能直接复用原模型的机械臂配置。
|
||||
|
||||
模型最初基于 urdf6 导入的 18 个 STL,颈部现已同步 `model/00 0930Body-urdf7.SLDASM`;其中
|
||||
`link7-right.STL` 已替换为完整 `link7-left.STL` 关于局部 XY 平面的镜像(Z 坐标取反),左右手各使用一份完整 STL。
|
||||
两侧手部 STL 已从各 268,502 面减至 21,479 面,减少约 92%;URDF 保持原路径即可读取轻量手部。
|
||||
`neck_Link1`~`neck_Link3`、`neck-joint1`~`neck-joint3` 已按 urdf7 更新。
|
||||
URDF 的 18 个外观 STL 采用 urdf9 网格,安装在 `xiaozhao/meshes/`。
|
||||
左右 `link4` 已按现用 URDF 的安装坐标对齐。左右手各用一份完整 STL,右手是左手关于局部 XY 平面的镜像。
|
||||
MuJoCo 从 `xiaozhao/meshes/visual/` 加载这些 STL 的减面外观。颈部三个关节的安装参数沿用 urdf7 更新。
|
||||
双臂 J3/J5 的机械零位已于 2026-11-18 各沿原关节局部 Z 轴旋转 +180°;
|
||||
新的 `q=0` 对应旧模型的 `q=pi`,URDF 安装旋转为 `R_new = R_old * Rz(pi)`。
|
||||
左右臂同步调整,关节轴向、位置限位数值、TCP 局部偏移和惯量保持原配置;
|
||||
@ -40,8 +39,8 @@ J2 `[-1.57, 0.44]`、J3 `[-0.44, 0.44]` rad;首关节已补偿现有基座绕
|
||||
从 URDF 重新生成机器人 XML 不会覆盖碰撞配置。修改排除规则后重新加载 `scene.xml` 即可。
|
||||
原生 MuJoCo 3.3.7 验证:零目标运行 10 秒后 J3 约 −0.001°、J2 约 +0.087°;
|
||||
三组非零目标及回零的最大稳态误差约 0.168°,未产生仿真警告。
|
||||
`base_link.obj` 是当前基座 STL 的无损转换;`link7-left.obj`、`link7-right.obj`
|
||||
保留减面前的高精度几何,继续用于 MuJoCo 手部碰撞及轻量网格的重建源。
|
||||
MuJoCo 物理接触独立引用 `base_link.obj`、`link7-left.obj` 和 `link7-right.obj`,
|
||||
其余连杆直接使用 `meshes/` 中的 STL。
|
||||
右手 visual/collision 保留既有 `Rx(pi)` 安装旋转;旧 `hand-right-mirrored` 资产文件保留,但不再加载或叠加。
|
||||
|
||||
只重新生成轻量手部(需要 Blender 4.5):
|
||||
@ -51,11 +50,10 @@ blender --background --factory-startup --threads 4 --python-exit-code 1 \
|
||||
--python model/xiaozhao/simplify_visual_meshes.py -- --hands-only
|
||||
```
|
||||
|
||||
省略 `-- --hands-only` 可重新生成全部轻量外观。两种模式均从高精度 OBJ 生成左手,
|
||||
再精确镜像生成右手,同步两侧 STL 与 visual;不会对轻量手部重复减面。
|
||||
当前 18 个网格的高精度源共 1,904,402 面,URDF 引用的 STL 共 1,410,356 面,
|
||||
MuJoCo 外观共 538,499 面。手部全部顶点和面中心的双向检查最大距离约 0.871 mm,
|
||||
不代表连续全表面的严格误差上界;更多参数见 `xiaozhao/meshes/visual/README.md`。
|
||||
省略 `-- --hands-only` 可从当前 URDF 引用的全部 STL 重新生成外观。脚本校验两侧手部 STL 的镜像关系,
|
||||
将左手减面后镜像生成右手。输出仅写入 `xiaozhao/meshes/visual/`,各连杆的源哈希、面数和采样误差见该目录的 `manifest.json`。
|
||||
使用源码模型时,重新加载 `xiaozhao/xml/scene.xml` 即可查看更新。使用安装版 CMVR 时,先同步该目录到
|
||||
`output/bin/model/xiaozhao/meshes/visual/`,再重启仿真。
|
||||
|
||||
触控场景拆分为 `model/xiaozhao/xml/` 下的三个模块:`touch_scene.xml`、
|
||||
`hand_camera.xml` 和 `head_camera.xml`。
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,29 +1,18 @@
|
||||
# MuJoCo 轻量外观网格
|
||||
|
||||
本目录保存 `xml/xiaozhao.xml` 的轻量 visual geom。手部从保留的高精度
|
||||
`meshes/link7-left.obj` 减面生成,并同步写入 `meshes/link7-left.STL`、
|
||||
`meshes/link7-right.STL`,因此 URDF 保持原引用即可使用轻量手部。
|
||||
其他连杆的源 STL 保留。MuJoCo 手部碰撞仍使用高精度 OBJ,质量、惯性、
|
||||
关节坐标、限位和执行器参数不受减面影响。
|
||||
MuJoCo 通过 `xml/xiaozhao.xml` 的 Geom group 1 显示本目录的 18 个减面 STL。
|
||||
源文件是当前 `urdf/xiaozhao.urdf` 引用的 urdf9 网格,来自上一级 `meshes/` 目录,
|
||||
包括基座、左右臂各 7 个连杆和 3 个颈部连杆。左右 `link4` 的源网格已对齐现用 URDF 的安装坐标。
|
||||
本次 urdf9 外观由 1,899,320 个三角面减至 525,299 个,减少约 72.34%。每侧手部由 266,586 面减至 21,326 面。
|
||||
|
||||
模型最初基于 urdf6 导入的 18 个 STL(含 3 个颈部网格),颈部现已同步 urdf7。
|
||||
`neck_Link3` 的源网格局部坐标平移 `(0, 0.015, 0.0035) m`,相应轻量外观已从新 STL 重建;
|
||||
颈部 J3 origin 更新为 `(0, 0.0035, -0.035) m`,维持头部零位外形。
|
||||
头部相机同步迁移至 `neck_Link3` 的 `(0.0325, 0.10347742, 0.08039297) m`,
|
||||
仍位于原相机窗口外 0.5 mm,零位朝 Base `+X`、向下约 30.9°。
|
||||
其中 `link7-right.STL`
|
||||
已由完整 `link7-left.STL` 关于局部 XY 平面镜像生成(Z 坐标取反)。右手 visual 同样由左手 visual 精确镜像,
|
||||
左右手原始网格各 268,502 个三角面,当前 STL 和 visual 各 21,479 个,减少约 92%;
|
||||
两侧使用相同减面精度,保留精确镜像关系。机器人使用的 18 个网格原始高精度源
|
||||
共 1,904,402 个三角面,当前 URDF 引用的 STL 共 1,410,356 个,
|
||||
MuJoCo 轻量外观共 538,499 个,相比高精度源减少约 71.72%。
|
||||
目录仍保留未加载的旧 `hand-right-mirrored` 网格;包含该闲置资产的 manifest 统计
|
||||
为 2,161,758 → 564,234 个三角面。
|
||||
`base_link.obj` 是当前基座 STL 的无损转换;`link7-left.obj`、`link7-right.obj`
|
||||
保留减面前的完整几何,用于 MuJoCo 碰撞及重复生成轻量手部,不能用减面后的 STL 覆盖。
|
||||
旧 `hand-right-mirrored.STL/.obj` 保持原文件,URDF/XML 中已移除其额外几何。
|
||||
碰撞 geom 设为 group 3,默认隐藏,避免与外观网格重复绘制。
|
||||
需要检查碰撞外形时,可在 MuJoCo 中启用 Geom group 3。
|
||||
颈部 J3 origin 为 `(0, 0.0035, -0.035) m`,头部相机挂在 `neck_Link3` 的
|
||||
`(0.0325, 0.10347742, 0.08039297) m`,零位朝 Base `+X`、向下约 30.9°。
|
||||
右手源 STL 是左手关于局部 XY 平面的镜像。脚本检查两侧源 STL 的三角面,然后对左手减面,
|
||||
沿 Z 轴反号并反转三角面绕序,得到精确镜像的右手外观。
|
||||
|
||||
MuJoCo 的 Geom group 3 用于查看物理接触几何。基座和左右手分别引用
|
||||
`meshes/base_link.obj`、`meshes/link7-left.obj` 和 `meshes/link7-right.obj`,其余连杆引用 `meshes/*.STL`。
|
||||
旧的 `hand-right-mirrored` 文件是闲置资产,生成清单只统计 URDF 引用的网格。
|
||||
|
||||
在项目根目录重新生成(需要 Blender 4.5,使用其内置 Python/NumPy):
|
||||
|
||||
@ -39,18 +28,12 @@ blender --background --factory-startup --threads 4 --python-exit-code 1 \
|
||||
--python model/xiaozhao/simplify_visual_meshes.py -- --hands-only
|
||||
```
|
||||
|
||||
两种命令都始终从高精度手部 OBJ 开始,左手减面后自动镜像生成右手,
|
||||
同步更新两侧 STL、visual 和 `manifest.json`,不会在已经减面的手部上重复减面。
|
||||
手部目标为原面数的 8%,检查原网格及输出网格的全部顶点和三角面中心,
|
||||
双向距离及包围盒变化阈值为 0.9 mm;当前最大距离约 0.871 mm、RMS 约 0.072 mm。
|
||||
其他连杆从 10% 面数开始,以 0.5 mm 双向采样距离及包围盒变化为阈值。
|
||||
若超过对应阈值,脚本会增加保留面数。
|
||||
所有网格保留原坐标和米制单位,不进行平移、旋转或缩放。
|
||||
`manifest.json` 记录源文件 SHA-256、面数及每个网格的误差和采样设置;
|
||||
当前最大包围盒端点变化约 0.201 mm。
|
||||
顶点与面中心的检查仍是离散质量检查,不是连续全表面的严格误差上界。
|
||||
两种命令只写本目录的外观 STL 和 `manifest.json`。手部从原面数的 8% 开始尝试减面,
|
||||
对当前源与输出网格的全部顶点和三角面中心检查双向表面距离,并检查包围盒端点,阈值为 0.9 mm。
|
||||
其他连杆从 10% 开始(小网格至少以 2,000 面为目标),对应阈值为 0.5 mm。
|
||||
若误差过大,脚本会增加保留面数。外观沿用各连杆的局部坐标和米制单位。
|
||||
`manifest.json` 记录源 STL 的 SHA-256、减面前后的面数、采样最大距离、均方根距离和包围盒端点变化。
|
||||
这些距离描述所检查的离散样本。
|
||||
|
||||
减面脚本写本目录及两侧手部 STL,不自动改 URDF 或 XML。之后从 URDF 更新 XML 时,运行
|
||||
`python3 model/xiaozhao/generate_mujoco_xml.py`,会自动应用独立的 visual mesh
|
||||
引用和 collision group 3 设置。
|
||||
环境背景、阴影、反射及仿真步长保持原配置。
|
||||
使用源码模型时,重新加载 `model/xiaozhao/xml/scene.xml` 即可查看新的外观。
|
||||
使用安装版 CMVR 时,先将更新的外观同步到 `output/bin/model/xiaozhao/meshes/visual/`,再重启仿真。
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -4,187 +4,214 @@
|
||||
"min_faces": 2000,
|
||||
"max_sampled_error_m": 0.0005,
|
||||
"samples_per_kind": 6000,
|
||||
"source_faces": 2161758,
|
||||
"output_faces": 564234,
|
||||
"source_faces": 1899320,
|
||||
"output_faces": 525299,
|
||||
"meshes": [
|
||||
{
|
||||
"source": "base_link.STL",
|
||||
"source_sha256": "2fdd0b0d3fdaed9ab17eac5870b1026513d544b5c4963808abe3f9e90c3c33c7",
|
||||
"source_sha256": "5b4bf28a5df15cc10818020f39c0b97fa9ba484aef2829b77bac92ae9f18b671",
|
||||
"output": "visual/base_link.STL",
|
||||
"source_faces": 748188,
|
||||
"output_faces": 149621,
|
||||
"sampled_surface_max_m": 0.00042033911449834704,
|
||||
"sampled_surface_rms_m": 4.1494265117752987e-05,
|
||||
"bounds_max_change_m": 5.963444709777832e-05
|
||||
},
|
||||
{
|
||||
"source": "hand-right-mirrored.STL",
|
||||
"source_sha256": "e7f5c7fd193f03a85112b808f31a8accc060dfbae2f2cbf04fc965864212f3b8",
|
||||
"output": "visual/hand-right-mirrored.STL",
|
||||
"source_faces": 257356,
|
||||
"output_faces": 25735,
|
||||
"sampled_surface_max_m": 0.00037606811383739114,
|
||||
"sampled_surface_rms_m": 5.473943785924547e-05,
|
||||
"bounds_max_change_m": 6.569921970367432e-05
|
||||
"source_faces": 748942,
|
||||
"output_faces": 149772,
|
||||
"sampled_surface_max_m": 0.0003111637488473207,
|
||||
"sampled_surface_rms_m": 4.152841895599864e-05,
|
||||
"bounds_max_change_m": 5.963444709777832e-05,
|
||||
"target_ratio": 0.1,
|
||||
"max_sampled_error_m": 0.0005,
|
||||
"samples_per_kind": 6000
|
||||
},
|
||||
{
|
||||
"source": "link1-left.STL",
|
||||
"source_sha256": "4a171f7985e324f3dc536d1f5909efc65dc0c9326f46f98131bd8f85260b551d",
|
||||
"source_sha256": "f5310b4abc783e1af954be8d08c33c230c6096c533cfa5afe1fe7d93acf159d4",
|
||||
"output": "visual/link1-left.STL",
|
||||
"source_faces": 57760,
|
||||
"output_faces": 23104,
|
||||
"sampled_surface_max_m": 0.00026875498588196933,
|
||||
"sampled_surface_rms_m": 2.835141984448404e-05,
|
||||
"bounds_max_change_m": 2.874806523323059e-05
|
||||
"source_faces": 58060,
|
||||
"output_faces": 23224,
|
||||
"sampled_surface_max_m": 0.0002687492815311998,
|
||||
"sampled_surface_rms_m": 2.7950388519050904e-05,
|
||||
"bounds_max_change_m": 2.874806523323059e-05,
|
||||
"target_ratio": 0.1,
|
||||
"max_sampled_error_m": 0.0005,
|
||||
"samples_per_kind": 6000
|
||||
},
|
||||
{
|
||||
"source": "link1-right.STL",
|
||||
"source_sha256": "28550e0f2cd66b06175aaca3b1c7bdda62e10b947aaed015121041bd43e46deb",
|
||||
"source_sha256": "267c8cc35fce1ac2178ecd7f95ffdadb048dcbd6f2cd7db8b1fe920ea1e5c929",
|
||||
"output": "visual/link1-right.STL",
|
||||
"source_faces": 56898,
|
||||
"output_faces": 22759,
|
||||
"sampled_surface_max_m": 0.00026874730247072875,
|
||||
"sampled_surface_rms_m": 2.7682213111346282e-05,
|
||||
"bounds_max_change_m": 1.9766390323638916e-05
|
||||
"source_faces": 57198,
|
||||
"output_faces": 11439,
|
||||
"sampled_surface_max_m": 0.0004739641153719276,
|
||||
"sampled_surface_rms_m": 9.812387082722046e-05,
|
||||
"bounds_max_change_m": 7.112696766853333e-05,
|
||||
"target_ratio": 0.1,
|
||||
"max_sampled_error_m": 0.0005,
|
||||
"samples_per_kind": 6000
|
||||
},
|
||||
{
|
||||
"source": "link2-left.STL",
|
||||
"source_sha256": "19f89071892e642b9a67745e09f6bad7ce4297d3652c4dd63a70adc20946d088",
|
||||
"source_sha256": "44b464da23919257d5054bebf218197b26152dc20455d825f0febea1ec1bb2f1",
|
||||
"output": "visual/link2-left.STL",
|
||||
"source_faces": 75768,
|
||||
"output_faces": 30307,
|
||||
"sampled_surface_max_m": 0.00018937674758490175,
|
||||
"sampled_surface_rms_m": 2.7082863328099957e-05,
|
||||
"bounds_max_change_m": 5.871430039405823e-05
|
||||
"source_faces": 75788,
|
||||
"output_faces": 30314,
|
||||
"sampled_surface_max_m": 0.00022682604321744293,
|
||||
"sampled_surface_rms_m": 2.681821308919837e-05,
|
||||
"bounds_max_change_m": 5.871430039405823e-05,
|
||||
"target_ratio": 0.1,
|
||||
"max_sampled_error_m": 0.0005,
|
||||
"samples_per_kind": 6000
|
||||
},
|
||||
{
|
||||
"source": "link2-right.STL",
|
||||
"source_sha256": "0e6888b4089046cbdd8959829294829bb5792f699413f1485c7ee83b990b4f6f",
|
||||
"source_sha256": "70c591fd630a7172ce299cc0cec3f0a06512024001df8cbb3e84eb719a7a558d",
|
||||
"output": "visual/link2-right.STL",
|
||||
"source_faces": 76202,
|
||||
"output_faces": 30479,
|
||||
"sampled_surface_max_m": 0.0002346254768781364,
|
||||
"sampled_surface_rms_m": 2.6829235074265677e-05,
|
||||
"bounds_max_change_m": 5.8673322200775146e-05
|
||||
"source_faces": 76222,
|
||||
"output_faces": 30488,
|
||||
"sampled_surface_max_m": 0.00024794129421934485,
|
||||
"sampled_surface_rms_m": 2.6942850020958247e-05,
|
||||
"bounds_max_change_m": 5.8673322200775146e-05,
|
||||
"target_ratio": 0.1,
|
||||
"max_sampled_error_m": 0.0005,
|
||||
"samples_per_kind": 6000
|
||||
},
|
||||
{
|
||||
"source": "link3-left.STL",
|
||||
"source_sha256": "321d53bbcd65d8fb5e3e678c93bc2b832e29f067e4965956d752248ce0589fba",
|
||||
"source_sha256": "85635ae21453f8b231b3caf6bc07d47422c959ad7c1c501e2faf50a7d8dcbaa7",
|
||||
"output": "visual/link3-left.STL",
|
||||
"source_faces": 37368,
|
||||
"output_faces": 14946,
|
||||
"sampled_surface_max_m": 0.0003167078539263457,
|
||||
"sampled_surface_rms_m": 3.798521451653437e-05,
|
||||
"bounds_max_change_m": 4.1447579860687256e-05
|
||||
"source_faces": 37024,
|
||||
"output_faces": 14808,
|
||||
"sampled_surface_max_m": 0.00045000016689300537,
|
||||
"sampled_surface_rms_m": 3.733395665099885e-05,
|
||||
"bounds_max_change_m": 4.1447579860687256e-05,
|
||||
"target_ratio": 0.1,
|
||||
"max_sampled_error_m": 0.0005,
|
||||
"samples_per_kind": 6000
|
||||
},
|
||||
{
|
||||
"source": "link3-right.STL",
|
||||
"source_sha256": "bfaa104792529e280f373621e4281684faa5a1b2012e7f7aead909d3bcd72e2e",
|
||||
"source_sha256": "48f79272d502dbac15da0d26ce6df5102b988b6f63619e6cbf44c8207a4e1047",
|
||||
"output": "visual/link3-right.STL",
|
||||
"source_faces": 37368,
|
||||
"output_faces": 14947,
|
||||
"sampled_surface_max_m": 0.00045000016689300537,
|
||||
"sampled_surface_rms_m": 3.8364295204592935e-05,
|
||||
"bounds_max_change_m": 4.1447579860687256e-05
|
||||
"source_faces": 37024,
|
||||
"output_faces": 14808,
|
||||
"sampled_surface_max_m": 0.0003153694560751319,
|
||||
"sampled_surface_rms_m": 3.738622786213791e-05,
|
||||
"bounds_max_change_m": 4.1447579860687256e-05,
|
||||
"target_ratio": 0.1,
|
||||
"max_sampled_error_m": 0.0005,
|
||||
"samples_per_kind": 6000
|
||||
},
|
||||
{
|
||||
"source": "link4-left.STL",
|
||||
"source_sha256": "7321111ef3c363004278c6ab88c67e43291b7052413319afa59f4e1b9f65bc78",
|
||||
"source_sha256": "416e252a3e4fecbc239cd15c8ba06e9c01a9ef39e70acb3fa120582851911ddb",
|
||||
"output": "visual/link4-left.STL",
|
||||
"source_faces": 45090,
|
||||
"output_faces": 36071,
|
||||
"sampled_surface_max_m": 9.083322220249102e-05,
|
||||
"sampled_surface_rms_m": 3.0952330584570504e-06,
|
||||
"bounds_max_change_m": 0.0
|
||||
"source_faces": 44752,
|
||||
"output_faces": 35800,
|
||||
"sampled_surface_max_m": 9.083346230909228e-05,
|
||||
"sampled_surface_rms_m": 3.069948544792859e-06,
|
||||
"bounds_max_change_m": 0.0,
|
||||
"target_ratio": 0.1,
|
||||
"max_sampled_error_m": 0.0005,
|
||||
"samples_per_kind": 6000
|
||||
},
|
||||
{
|
||||
"source": "link4-right.STL",
|
||||
"source_sha256": "77a4eaf24f438fa7af172522420452c46b5c3371e894de0829b8d9f322417499",
|
||||
"source_sha256": "44959e773823b67ac8856515e67b405178c0959198bc160069db0296c959b608",
|
||||
"output": "visual/link4-right.STL",
|
||||
"source_faces": 45028,
|
||||
"output_faces": 36021,
|
||||
"sampled_surface_max_m": 9.083344048121944e-05,
|
||||
"sampled_surface_rms_m": 3.1129902787962218e-06,
|
||||
"bounds_max_change_m": 0.0
|
||||
"source_faces": 44712,
|
||||
"output_faces": 35768,
|
||||
"sampled_surface_max_m": 9.083175245905295e-05,
|
||||
"sampled_surface_rms_m": 2.954903548131498e-06,
|
||||
"bounds_max_change_m": 0.0,
|
||||
"target_ratio": 0.1,
|
||||
"max_sampled_error_m": 0.0005,
|
||||
"samples_per_kind": 6000
|
||||
},
|
||||
{
|
||||
"source": "link5-left.STL",
|
||||
"source_sha256": "dcfa389745a9893771e2473f6437cf38c49d2e3cb85ba5a9ed6333c04059b734",
|
||||
"source_sha256": "a626df38eaed4b2537ab27d25014cbf2216a6d231d241c2c8efeda4c4bc88d3a",
|
||||
"output": "visual/link5-left.STL",
|
||||
"source_faces": 53612,
|
||||
"output_faces": 42889,
|
||||
"sampled_surface_max_m": 0.000298623344860971,
|
||||
"sampled_surface_rms_m": 5.349286240748322e-06,
|
||||
"bounds_max_change_m": 3.050081431865692e-07
|
||||
"source_faces": 53274,
|
||||
"output_faces": 42619,
|
||||
"sampled_surface_max_m": 0.00029859167989343405,
|
||||
"sampled_surface_rms_m": 4.802355145454622e-06,
|
||||
"bounds_max_change_m": 8.102506399154663e-08,
|
||||
"target_ratio": 0.1,
|
||||
"max_sampled_error_m": 0.0005,
|
||||
"samples_per_kind": 6000
|
||||
},
|
||||
{
|
||||
"source": "link5-right.STL",
|
||||
"source_sha256": "75fdd5b7a69cf9bb5541ac827f7df4633fe9bfc440cf97407e3f57b06558fcf7",
|
||||
"source_sha256": "4a1c11b5d361c5a189f4cfcd63d4b8a07333665c57a3dac7d239e33042ad7147",
|
||||
"output": "visual/link5-right.STL",
|
||||
"source_faces": 53616,
|
||||
"output_faces": 42891,
|
||||
"sampled_surface_max_m": 9.082913311431184e-05,
|
||||
"sampled_surface_rms_m": 4.655186798771574e-06,
|
||||
"bounds_max_change_m": 0.0
|
||||
"source_faces": 53278,
|
||||
"output_faces": 42621,
|
||||
"sampled_surface_max_m": 0.00029859167989343405,
|
||||
"sampled_surface_rms_m": 4.969851798305747e-06,
|
||||
"bounds_max_change_m": 3.050081431865692e-07,
|
||||
"target_ratio": 0.1,
|
||||
"max_sampled_error_m": 0.0005,
|
||||
"samples_per_kind": 6000
|
||||
},
|
||||
{
|
||||
"source": "link6-left.STL",
|
||||
"source_sha256": "ed4bab728dc54447f0c27a171d105ea52411a23fcafaf19366e04907330ed540",
|
||||
"source_sha256": "5751e5b18aded2fd1f4d25c3bfc46e338c24545df28dddf21b4303d9efc3c10b",
|
||||
"output": "visual/link6-left.STL",
|
||||
"source_faces": 21804,
|
||||
"output_faces": 17442,
|
||||
"sampled_surface_max_m": 9.875782416202128e-05,
|
||||
"sampled_surface_rms_m": 3.821786649679022e-06,
|
||||
"bounds_max_change_m": 4.641711711883545e-06
|
||||
"source_faces": 21466,
|
||||
"output_faces": 17172,
|
||||
"sampled_surface_max_m": 9.083602344617248e-05,
|
||||
"sampled_surface_rms_m": 3.8544717831602e-06,
|
||||
"bounds_max_change_m": 4.641711711883545e-06,
|
||||
"target_ratio": 0.1,
|
||||
"max_sampled_error_m": 0.0005,
|
||||
"samples_per_kind": 6000
|
||||
},
|
||||
{
|
||||
"source": "link6-right.STL",
|
||||
"source_sha256": "2cbbc72dda80d0caa105fc749e365d206a7f03b29c01c140698b51374e7faf73",
|
||||
"source_sha256": "ace2f885bd95bd42370a6039dbf60f100d051aff9455f49535074196e7d5e0ef",
|
||||
"output": "visual/link6-right.STL",
|
||||
"source_faces": 21804,
|
||||
"output_faces": 17442,
|
||||
"sampled_surface_max_m": 9.083369513973594e-05,
|
||||
"sampled_surface_rms_m": 3.723543151280335e-06,
|
||||
"bounds_max_change_m": 4.641711711883545e-06
|
||||
"source_faces": 21466,
|
||||
"output_faces": 17172,
|
||||
"sampled_surface_max_m": 9.875768591882661e-05,
|
||||
"sampled_surface_rms_m": 4.036426034251301e-06,
|
||||
"bounds_max_change_m": 4.641711711883545e-06,
|
||||
"target_ratio": 0.1,
|
||||
"max_sampled_error_m": 0.0005,
|
||||
"samples_per_kind": 6000
|
||||
},
|
||||
{
|
||||
"source": "link7-left.obj",
|
||||
"source_sha256": "764db2f4e79b040c8cf0f6adf645846cdb6464ba723517f89d52679388f9e50a",
|
||||
"source": "link7-left.STL",
|
||||
"source_sha256": "ae314bc48bb608ede8970f03cf59c3386a760a5d40a69cae2db72b05f5729543",
|
||||
"output": "visual/link7-left.STL",
|
||||
"source_faces": 268502,
|
||||
"output_faces": 21479,
|
||||
"source_faces": 266586,
|
||||
"output_faces": 21326,
|
||||
"sampled_surface_max_m": 0.0008708483073860407,
|
||||
"sampled_surface_rms_m": 7.231836397924099e-05,
|
||||
"sampled_surface_rms_m": 7.19075150640207e-05,
|
||||
"bounds_max_change_m": 0.00020128116011619568,
|
||||
"target_ratio": 0.08,
|
||||
"max_sampled_error_m": 0.0009,
|
||||
"samples_per_kind": 300000,
|
||||
"urdf_stl": "link7-left.STL"
|
||||
"samples_per_kind": 300000
|
||||
},
|
||||
{
|
||||
"source": "link7-right.obj",
|
||||
"source_sha256": "d759454f2aa4819e0d6094ac01aea7bfeadecb161f86d16c19caebc71f21a729",
|
||||
"source": "link7-right.STL",
|
||||
"source_sha256": "641b850200d98dcaa5d2cbe05399b75746fddc15ab34d409f34d3a1c62a200a5",
|
||||
"output": "visual/link7-right.STL",
|
||||
"source_faces": 268502,
|
||||
"output_faces": 21479,
|
||||
"source_faces": 266586,
|
||||
"output_faces": 21326,
|
||||
"sampled_surface_max_m": 0.0008708483073860407,
|
||||
"sampled_surface_rms_m": 7.231836397924099e-05,
|
||||
"sampled_surface_rms_m": 7.19075150640207e-05,
|
||||
"bounds_max_change_m": 0.00020128116011619568,
|
||||
"target_ratio": 0.08,
|
||||
"max_sampled_error_m": 0.0009,
|
||||
"samples_per_kind": 300000,
|
||||
"urdf_stl": "link7-right.STL",
|
||||
"mirror_of": "visual/link7-left.STL",
|
||||
"mirror_axis": "z"
|
||||
},
|
||||
{
|
||||
"source": "neck_Link1.STL",
|
||||
"source_sha256": "f6ae5e8b5ed87be05891e3eecc8f244472a5b191eaa84b4719db04c8b22be1b1",
|
||||
"source_sha256": "d5dfe5b8683524c6f0a4342dd6b3a241cf7e9b522441c243ebb0657b74a6c398",
|
||||
"output": "visual/neck_Link1.STL",
|
||||
"source_faces": 6050,
|
||||
"output_faces": 4000,
|
||||
"sampled_surface_max_m": 0.00013269121700432152,
|
||||
"sampled_surface_rms_m": 3.372635119155393e-05,
|
||||
"sampled_surface_rms_m": 3.370800948667785e-05,
|
||||
"bounds_max_change_m": 1.4435732737183571e-05,
|
||||
"target_ratio": 0.1,
|
||||
"max_sampled_error_m": 0.0005,
|
||||
@ -192,22 +219,25 @@
|
||||
},
|
||||
{
|
||||
"source": "neck_Link2.STL",
|
||||
"source_sha256": "d5c04d90019d4ce0e11cc55d85e0db6926a7e6f22a787399fcb0941de99c05c9",
|
||||
"source_sha256": "03852c9e37cf0e3aab7930a8101380194d9783cdeb7cb3154ed38a4503abd79b",
|
||||
"output": "visual/neck_Link2.STL",
|
||||
"source_faces": 4278,
|
||||
"output_faces": 1998,
|
||||
"sampled_surface_max_m": 0.0002777037734631449,
|
||||
"sampled_surface_rms_m": 6.414035904574769e-05,
|
||||
"bounds_max_change_m": 6.864219903945923e-05
|
||||
"sampled_surface_rms_m": 6.431449667360781e-05,
|
||||
"bounds_max_change_m": 6.864219903945923e-05,
|
||||
"target_ratio": 0.1,
|
||||
"max_sampled_error_m": 0.0005,
|
||||
"samples_per_kind": 6000
|
||||
},
|
||||
{
|
||||
"source": "neck_Link3.STL",
|
||||
"source_sha256": "05245467e1f49487d2b0d4fa8d2d280d60587859456278ea970267c0ce4da074",
|
||||
"source_sha256": "3b6b58748c45144d462a801a35a217d359f50061b9ee05be2b4f1b680490a3ed",
|
||||
"output": "visual/neck_Link3.STL",
|
||||
"source_faces": 26564,
|
||||
"output_faces": 10624,
|
||||
"sampled_surface_max_m": 0.00038459166535176337,
|
||||
"sampled_surface_rms_m": 6.716052793042533e-05,
|
||||
"source_faces": 26614,
|
||||
"output_faces": 10644,
|
||||
"sampled_surface_max_m": 0.00037754757795482874,
|
||||
"sampled_surface_rms_m": 6.68902570850785e-05,
|
||||
"bounds_max_change_m": 7.949024438858032e-05,
|
||||
"target_ratio": 0.1,
|
||||
"max_sampled_error_m": 0.0005,
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,12 +1,11 @@
|
||||
"""Generate lightweight visuals, including the STL files used by URDF hands.
|
||||
"""Generate MuJoCo visual meshes from the STL files referenced by the URDF.
|
||||
|
||||
Run with Blender 4.5 from any directory:
|
||||
blender --background --factory-startup --python simplify_visual_meshes.py
|
||||
blender --background --factory-startup --python simplify_visual_meshes.py -- --hands-only
|
||||
|
||||
The sampled surface-distance check is a quality check, not a Hausdorff bound.
|
||||
Hand OBJ files retain the original geometry for MuJoCo collisions and repeated
|
||||
simplification. Other source meshes and URDF definitions are not edited here.
|
||||
All generated meshes and the manifest are written to meshes/visual.
|
||||
"""
|
||||
|
||||
from pathlib import Path
|
||||
@ -18,6 +17,7 @@ import stat
|
||||
import struct
|
||||
import sys
|
||||
import tempfile
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
import bpy
|
||||
import numpy as np
|
||||
@ -25,6 +25,7 @@ from mathutils.bvhtree import BVHTree
|
||||
|
||||
|
||||
MESHES = Path(__file__).resolve().parent / "meshes"
|
||||
URDF = MESHES.parent / "urdf" / "xiaozhao.urdf"
|
||||
OUTPUT = MESHES / "visual"
|
||||
TARGET_RATIO = 0.10
|
||||
MIN_FACES = 2000
|
||||
@ -32,7 +33,7 @@ MAX_SAMPLED_ERROR = 0.0005 # metres; retain more faces if necessary
|
||||
SAMPLES_PER_KIND = 6000
|
||||
HAND_TARGET_RATIO = 0.08
|
||||
HAND_MAX_SAMPLED_ERROR = 0.0009
|
||||
# Covers every vertex and triangle centre of the current 268,502-face source.
|
||||
# Covers every vertex and triangle centre of the current hand meshes.
|
||||
HAND_SAMPLES_PER_KIND = 300000
|
||||
HAND_NAMES = {"link7-left.STL", "link7-right.STL"}
|
||||
STL_DTYPE = np.dtype([
|
||||
@ -50,23 +51,6 @@ def read_stl(path):
|
||||
return vertices, indices.reshape(-1, 3)
|
||||
|
||||
|
||||
def read_obj(path):
|
||||
"""Read the triangle-only, lossless collision OBJ exported from CAD STL."""
|
||||
vertices, faces = [], []
|
||||
with path.open() as stream:
|
||||
for line in stream:
|
||||
fields = line.split()
|
||||
if not fields:
|
||||
continue
|
||||
if fields[0] == "v":
|
||||
vertices.append([float(x) for x in fields[1:4]])
|
||||
elif fields[0] == "f":
|
||||
if len(fields) != 4:
|
||||
raise ValueError(f"Expected triangles in {path}")
|
||||
faces.append([int(x.split('/')[0]) - 1 for x in fields[1:]])
|
||||
return np.asarray(vertices, dtype=np.float32), np.asarray(faces, dtype=np.int32)
|
||||
|
||||
|
||||
def atomic_write(path, data):
|
||||
mode = stat.S_IMODE(path.stat().st_mode) if path.exists() else 0o644
|
||||
with tempfile.NamedTemporaryFile(dir=path.parent, delete=False) as stream:
|
||||
@ -107,9 +91,9 @@ def distances(points, tree):
|
||||
return np.array([tree.find_nearest(point)[3] for point in points])
|
||||
|
||||
|
||||
def simplify(path, *, output_name=None, target_ratio=TARGET_RATIO,
|
||||
def simplify(path, *, target_ratio=TARGET_RATIO,
|
||||
max_error=MAX_SAMPLED_ERROR, samples_per_kind=SAMPLES_PER_KIND):
|
||||
vertices, faces = read_obj(path) if path.suffix.lower() == ".obj" else read_stl(path)
|
||||
vertices, faces = read_stl(path)
|
||||
original_tree = surface_tree(vertices, faces)
|
||||
original_samples = sample_points(vertices, faces, samples_per_kind)
|
||||
mesh = bpy.data.meshes.new(path.stem + "_source")
|
||||
@ -160,7 +144,7 @@ def simplify(path, *, output_name=None, target_ratio=TARGET_RATIO,
|
||||
ratio = min(1., ratio * 2)
|
||||
print(f"Retaining more detail in {path.name}: ratio={ratio:.3f}; "
|
||||
f"sampled error={errors.max() * 1000:.3f} mm", flush=True)
|
||||
output = OUTPUT / (output_name or path.name)
|
||||
output = OUTPUT / path.name
|
||||
write_stl(output, out_vertices, out_faces)
|
||||
report = {
|
||||
"source": path.name,
|
||||
@ -183,24 +167,21 @@ def simplify(path, *, output_name=None, target_ratio=TARGET_RATIO,
|
||||
|
||||
|
||||
def simplify_hands():
|
||||
"""Always start from original OBJ, and preserve exact left/right mirroring."""
|
||||
left_source, right_source = MESHES / "link7-left.obj", MESHES / "link7-right.obj"
|
||||
lv, lf = read_obj(left_source)
|
||||
rv, rf = read_obj(right_source)
|
||||
"""Preserve the exact mirror relationship of the two URDF hand meshes."""
|
||||
left_source, right_source = MESHES / "link7-left.STL", MESHES / "link7-right.STL"
|
||||
lv, lf = read_stl(left_source)
|
||||
rv, rf = read_stl(right_source)
|
||||
if not np.array_equal(rv[rf], lv[lf][:, [0, 2, 1], :] * [1, 1, -1]):
|
||||
raise ValueError("Hand collision OBJ files are not exact mirrors; review before simplifying")
|
||||
left = simplify(left_source, output_name="link7-left.STL",
|
||||
raise ValueError("URDF hand STL files are not exact mirrors; review before simplifying")
|
||||
left = simplify(left_source,
|
||||
target_ratio=HAND_TARGET_RATIO, max_error=HAND_MAX_SAMPLED_ERROR,
|
||||
samples_per_kind=HAND_SAMPLES_PER_KIND)
|
||||
vertices, faces = read_stl(OUTPUT / "link7-left.STL")
|
||||
vertices[:, 2] *= -1
|
||||
write_stl(OUTPUT / "link7-right.STL", vertices, faces[:, [0, 2, 1]])
|
||||
for name in sorted(HAND_NAMES):
|
||||
atomic_write(MESHES / name, (OUTPUT / name).read_bytes())
|
||||
left["urdf_stl"] = "link7-left.STL"
|
||||
right = dict(left, source=right_source.name,
|
||||
source_sha256=hashlib.sha256(right_source.read_bytes()).hexdigest(),
|
||||
output="visual/link7-right.STL", urdf_stl="link7-right.STL",
|
||||
output="visual/link7-right.STL",
|
||||
mirror_of="visual/link7-left.STL", mirror_axis="z")
|
||||
return [left, right]
|
||||
|
||||
@ -208,16 +189,17 @@ def simplify_hands():
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--hands-only", action="store_true",
|
||||
help="Update hand STL/visual meshes from original collision OBJ only")
|
||||
help="Update only the hand visuals from the URDF hand STL files")
|
||||
args = parser.parse_args(sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else [])
|
||||
OUTPUT.mkdir(exist_ok=True)
|
||||
sources = {Path(mesh.attrib["filename"]).name
|
||||
for mesh in ET.parse(URDF).iterfind("link/visual/geometry/mesh")}
|
||||
if args.hands_only:
|
||||
previous = json.loads((OUTPUT / "manifest.json").read_text())
|
||||
reports = [item for item in previous["meshes"]
|
||||
if Path(item["output"]).name not in HAND_NAMES]
|
||||
if Path(item["output"]).name in sources - HAND_NAMES]
|
||||
else:
|
||||
reports = [simplify(path) for path in sorted(MESHES.glob("*.STL"))
|
||||
if path.name not in HAND_NAMES]
|
||||
reports = [simplify(MESHES / name) for name in sorted(sources - HAND_NAMES)]
|
||||
reports.extend(simplify_hands())
|
||||
reports.sort(key=lambda item: item["output"])
|
||||
report = {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user