| """Interactive layout editor for the toy-sorting scene. |
| |
| Spawns the full scene with physics frozen so you can reposition objects |
| freely using the Isaac Sim viewport transform gizmos (press W to activate). |
| When you close the window the current stage is exported to a USDA file. |
| |
| Usage: |
| uv run python scripts/layout_editor.py |
| uv run python scripts/layout_editor.py --export assets/my_layout.usda |
| |
| Physics is intentionally NOT stepped β only the GUI update loop runs. |
| Objects stay wherever you drag them. Close the window to export and exit. |
| """ |
|
|
| from __future__ import annotations |
|
|
| import argparse |
| import sys |
| from pathlib import Path |
|
|
| _REPO_ROOT = Path(__file__).resolve().parents[1] |
| _SRC = _REPO_ROOT / "src" |
| if str(_SRC) not in sys.path: |
| sys.path.insert(0, str(_SRC)) |
|
|
| |
| |
| |
| parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) |
| parser.add_argument( |
| "--export", |
| default="assets/scene_layout.usda", |
| help="Path to write the exported USDA layout (default: assets/scene_layout.usda)", |
| ) |
| args_cli = parser.parse_args() |
|
|
| from isaaclab.app import AppLauncher |
| app_launcher = AppLauncher(headless=False) |
| simulation_app = app_launcher.app |
|
|
| |
| |
| |
| import isaaclab.sim as sim_utils |
| from isaaclab.sim import SimulationContext |
| from manipulator_learning.envhub import make_env |
|
|
|
|
| def main() -> None: |
| export_path = (_REPO_ROOT / args_cli.export).resolve() |
|
|
| sim_cfg = sim_utils.SimulationCfg(dt=1.0 / 60.0) |
| sim = SimulationContext(sim_cfg) |
| sim.set_camera_view(eye=[0.8, -0.8, 1.2], target=[0.0, 0.0, 0.2]) |
|
|
| print("[layout_editor] Building scene β¦") |
| envs_dict = make_env(n_envs=1) |
| env = envs_dict["toy_sorting"][0] |
|
|
| print("[layout_editor] Resetting (physics will NOT be stepped) β¦") |
| sim.reset() |
| env.reset() |
|
|
| print() |
| print("=" * 60) |
| print(" Physics is FROZEN. Drag objects freely in the viewport.") |
| print(" Press W β translate gizmo") |
| print(" Press E β rotate gizmo") |
| print(" Press R β scale gizmo") |
| print(f" Close window to export layout β {export_path}") |
| print("=" * 60) |
| print() |
|
|
| |
| while simulation_app.is_running(): |
| simulation_app.update() |
|
|
| |
| import omni.usd |
| stage = omni.usd.get_context().get_stage() |
| export_path.parent.mkdir(parents=True, exist_ok=True) |
| stage.Export(str(export_path)) |
| print(f"[layout_editor] Layout exported β {export_path}") |
|
|
| env.close() |
|
|
|
|
| if __name__ == "__main__": |
| main() |
| simulation_app.close() |
|
|