Download tools/robolab/probe_objects.py from vietnhat/robodojo-dev-suite: direct link, hf CLI and curl.
- Browser
- Download file 3.48 kB
-
https://huggingface.co/datasets/vietnhat/robodojo-dev-suite/resolve/main/tools/robolab/probe_objects.py
- Command line
-
hf download hf://datasets/vietnhat/robodojo-dev-suite/tools/robolab/probe_objects.py
-
curl -L -o probe_objects.py https://huggingface.co/datasets/vietnhat/robodojo-dev-suite/resolve/main/tools/robolab/probe_objects.py
3.48 kB
| """Drop every converted RoboLab object on a flat floor in Isaac Sim and check that it rests stably (PROD-116). | |
| CUDA_VISIBLE_DEVICES=1 /data1/viet/venv/robodojo_client/bin/python dev_suite/robolab/probe_objects.py [--only rl_banana ...] | |
| Loads each Rigid wrapper the way RoboDojo does (a USD reference + SingleRigidPrim, mass from metadata.json), | |
| puts it on the floor at its resting pose ("place up"), runs 3 s at RoboDojo's dt and records how far it moved and tilted. | |
| Stable: moved < 2 cm, tilted < 5 deg, did not sink. Writes dev_suite/robolab/object_probe.json. | |
| """ | |
| from __future__ import annotations | |
| import argparse | |
| import json | |
| import math | |
| import os | |
| from pathlib import Path | |
| from isaacsim import SimulationApp | |
| HERE = Path(__file__).resolve().parent | |
| OBJECTS = Path(os.environ.get("ROBOLAB_OBJECTS", "/data1/viet/robolab_objects")) | |
| SPACING = 0.8 # m between objects | |
| SECONDS, DT = 3.0, 0.004 | |
| def main() -> None: | |
| p = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) | |
| p.add_argument("--only", nargs="*") | |
| args = p.parse_args() | |
| app = SimulationApp({"headless": True}) | |
| import numpy as np | |
| from isaacsim.core.api import World | |
| from isaacsim.core.prims import SingleRigidPrim | |
| from isaacsim.core.utils.stage import add_reference_to_stage | |
| world = World(physics_dt=DT, rendering_dt=DT * 10, stage_units_in_meters=1.0) | |
| world.scene.add_default_ground_plane(static_friction=1.0, dynamic_friction=1.0) | |
| names = sorted(args.only or (d.name for d in (OBJECTS / "Rigid").iterdir())) | |
| cols = math.ceil(math.sqrt(len(names))) | |
| bodies = {} | |
| for i, name in enumerate(names): | |
| folder = OBJECTS / "Rigid" / name / "00000" | |
| meta = json.loads((folder / "metadata.json").read_text()) | |
| z = -meta["active"]["place"]["up"]["projection_circle"]["center"][2] + 0.002 | |
| pos = np.array([(i % cols) * SPACING, (i // cols) * SPACING, z]) | |
| prim_path = f"/World/{name}" | |
| add_reference_to_stage(str(folder / "object.usd"), prim_path) | |
| body = SingleRigidPrim(prim_path, name=name, translation=pos, orientation=np.array([1.0, 0, 0, 0])) | |
| body.set_mass(meta["physics"]["mass"]) # friction: RoboLab's physics material, bound on the collision meshes | |
| bodies[name] = (body, pos) | |
| world.reset() | |
| for _ in range(int(SECONDS / DT)): | |
| world.step(render=False) | |
| report = {} | |
| for name, (body, start) in bodies.items(): | |
| pos, quat = body.get_world_pose() | |
| pos, quat = np.asarray(pos, dtype=float), np.asarray(quat, dtype=float) | |
| up = 1 - 2 * (quat[1] ** 2 + quat[2] ** 2) # world z of the body's z axis | |
| tilt = math.degrees(math.acos(max(-1.0, min(1.0, up)))) | |
| moved = float(np.linalg.norm(pos[:2] - start[:2])) | |
| sink = float(start[2] - pos[2]) | |
| stable = bool(moved < 0.02 and tilt < 5 and -0.01 < sink < 0.01) | |
| report[name] = {"stable": stable, "moved": round(moved, 4), "tilt_deg": round(tilt, 1), "sink": round(sink, 4)} | |
| print(f"{name:34} {'ok ' if stable else 'BAD'} moved {moved:.3f} tilt {tilt:5.1f} sink {sink:+.3f}", flush=True) | |
| out = HERE / "object_probe.json" | |
| old = json.loads(out.read_text()) if out.exists() and args.only else {} | |
| out.write_text(json.dumps(old | report, indent=1, sort_keys=True) + "\n") | |
| print(f"stable {sum(r['stable'] for r in report.values())}/{len(report)} -> {out}") | |
| app.close() | |
| if __name__ == "__main__": | |
| main() | |