debug: list compiled MuJoCo meshes with file paths
Browse files- debug/mesh_list.py +19 -0
debug/mesh_list.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Wraps mujoco.mj_step; on the first step of the replay, lists every mesh of the compiled model:
|
| 2 |
+
# index, name, file path, vertex/face counts and a hash of its vertices. Compare the output across machines.
|
| 3 |
+
import hashlib, runpy, sys, numpy as np, mujoco
|
| 4 |
+
_step, done = mujoco.mj_step, [False]
|
| 5 |
+
def report(m):
|
| 6 |
+
paths = m.paths.decode() if hasattr(m, "paths") else ""
|
| 7 |
+
for i in range(m.nmesh):
|
| 8 |
+
name = mujoco.mj_id2name(m, mujoco.mjtObj.mjOBJ_MESH, i)
|
| 9 |
+
a = m.mesh_pathadr[i]; path = paths[a:paths.index("\0", a)] if a >= 0 else "-"
|
| 10 |
+
v = m.mesh_vert[m.mesh_vertadr[i]:m.mesh_vertadr[i] + m.mesh_vertnum[i]]
|
| 11 |
+
print(f"[mesh] {i:3d} {name:40s} vert={m.mesh_vertnum[i]:6d} face={m.mesh_facenum[i]:6d} "
|
| 12 |
+
f"hash={hashlib.md5(v.tobytes()).hexdigest()[:8]} path={path}", flush=True)
|
| 13 |
+
def step(m, d, nstep=1):
|
| 14 |
+
if not done[0]:
|
| 15 |
+
done[0] = True; report(m); raise SystemExit(0)
|
| 16 |
+
_step(m, d, nstep=nstep)
|
| 17 |
+
mujoco.mj_step = step
|
| 18 |
+
sys.argv = ["replay_decoupled_wbc"] + sys.argv[1:]
|
| 19 |
+
runpy.run_module("simple.cli.replay_decoupled_wbc", run_name="__main__")
|