MCPcopy Create free account
hub / github.com/URLab-Sim/UnrealRoboticsLab / flatten_includes

Function flatten_includes

Scripts/clean_meshes.py:203–217  ·  view source on GitHub ↗

Resolve every into a single self-contained tree. gym-aloha (and many MJCF models) split a robot across fragments rooted in , including files referenced from inside . Unreal's importer must see one flat document so all /<compi

(root, root_dir: Path)

Source from the content-addressed store, hash-verified

201
202
203def flatten_includes(root, root_dir: Path):
204 """Resolve every <include> into a single self-contained <mujoco> tree.
205
206 gym-aloha (and many MJCF models) split a robot across <include> fragments
207 rooted in <mujocoinclude>, including files referenced from inside <worldbody>.
208 Unreal&#x27;s importer must see one flat document so all <asset>/<compiler>/body
209 content is visible and there is exactly one worldbody. Returns the new root
210 element (a <mujoco>). No-op-equivalent for files without includes.
211 """
212 md, txd, ad = _compiler_dirs(root)
213 visited = set()
214 new_root = ET.Element("mujoco", dict(root.attrib))
215 for child in list(root):
216 _append_expanded(new_root, child, root_dir, root_dir, md, txd, ad, visited)
217 return new_root
218
219
220def materialize_inline_meshes(root, mesh_base: Path) -> int:

Callers 1

process_xmlFunction · 0.85

Calls 2

_compiler_dirsFunction · 0.85
_append_expandedFunction · 0.85

Tested by

no test coverage detected