| """Convert selected RobotWin (MIT) GLB objects to USD so they can be spawned in the YAM Isaac Lab env.""" |
| import argparse, sys, os, json |
| from isaaclab.app import AppLauncher |
| p=argparse.ArgumentParser() |
| p.add_argument("--jobs", default="021_cup:base0,002_bowl:base0,001_bottle:base0,008_tray:base0") |
| |
| |
| |
| p.add_argument("--collision", default="convexDecomposition", |
| choices=["convexDecomposition","convexHull","meshSimplification","boundingCube","none"]) |
| p.add_argument("--suffix", default="", help="append to the usd filename, e.g. _mesh for a mesh-collision variant") |
| AppLauncher.add_app_launcher_args(p); a=p.parse_args(); a.headless=True |
| app=AppLauncher(a).app |
| from isaaclab.sim.converters import MeshConverter, MeshConverterCfg |
| import isaaclab.sim as sim_utils |
| SRC=os.environ.get("ROBOTWIN_SRC", "/home/horde/xiaotong/robotwin_assets/objects") |
| OUT=os.environ.get("ROBOTWIN_USD", "/home/horde/xiaotong/robotwin_assets/usd") |
| os.makedirs(OUT, exist_ok=True) |
| for job in a.jobs.split(","): |
| cat,inst=job.split(":") |
| glb=f"{SRC}/{cat}/visual/{inst}.glb" |
| if not os.path.exists(glb): print("[conv] MISSING", glb, flush=True); continue |
| |
| scale=None |
| mdi=f"{SRC}/{cat}/model_data{inst.replace('base','')}.json" |
| if os.path.exists(mdi): |
| try: scale=json.load(open(mdi)).get("scale") |
| except Exception: pass |
| cfg=MeshConverterCfg( |
| asset_path=glb, usd_dir=f"{OUT}/{cat}", usd_file_name=f"{inst}{a.suffix}.usd", |
| force_usd_conversion=True, make_instanceable=False, |
| rigid_props=sim_utils.RigidBodyPropertiesCfg(), |
| mass_props=sim_utils.MassPropertiesCfg(mass=0.10), |
| collision_props=sim_utils.CollisionPropertiesCfg(), |
| collision_approximation=a.collision, |
| ) |
| try: |
| conv=MeshConverter(cfg) |
| print(f"[conv] OK {cat}:{inst} scale={scale} -> {conv.usd_path}", flush=True) |
| except Exception as e: |
| print(f"[conv] FAIL {cat}:{inst}: {e}", flush=True) |
| app.close(); print("CONVERT_DONE", flush=True) |
|
|