JoeyYuzy's picture
Add source-context coverage repairs with exact provenance and native validation (part 2)
baa938b verified
Raw History Blame Contribute Delete
2.34 kB
"""Open a coverage-repaired scene and install its physical door latches.
Example: /home/joey/isaacsim/python.sh open_scene.py penthouse1
"""
import argparse,sys,json
from pathlib import Path
HERE=Path(__file__).resolve().parent;sys.path.insert(0,str(HERE));p=argparse.ArgumentParser();p.add_argument('asset',help='asset name or path to .usd/.usdz');p.add_argument('--headless',action='store_true');p.add_argument('--frames',type=int,default=0);p.add_argument('--no-ui',action='store_true');p.add_argument('--view',type=int,default=0);a=p.parse_args()
candidates=[Path(a.asset),HERE/a.asset/(a.asset+'.usd')];path=next((x.resolve() for x in candidates if x.is_file()),None)
if path is None:raise SystemExit('Scene not found: '+a.asset)
from isaacsim import SimulationApp
app=SimulationApp({'headless':a.headless,'width':1280,'height':900,'renderer':'RayTracedLighting','extra_args':['--/exts/isaacsim.core.simulation_manager/default_engine=physx','--/exts/isaacsim.physics.newton/auto_switch_on_startup=false']})
import omni.usd
import carb
from pxr import Sdf
from isaacsim.core.utils.stage import open_stage
from isaacsim.core.api import World
from cvpr_door_runtime import install
open_stage(str(path));stage=omni.usd.get_context().get_stage();settings=carb.settings.get_settings();settings.set('/rtx/rtpt/gaussian/skipTonemapping/enabled',True);settings.set('/rtx/post/tonemap/op',0);settings.set('/rtx/post/aa/op',3);settings.set('/rtx/hydra/faceCulling/enabled',True)
for _ in range(24):app.update()
world=World(physics_dt=1/240,rendering_dt=1/60,stage_units_in_meters=1);runtime=install(stage,show_ui=not a.headless and not a.no_ui);world.reset()
if not a.headless:
from omni.kit.viewport.utility import get_active_viewport
viewport=get_active_viewport()
if viewport:viewport.camera_path=Sdf.Path(f'/World/Cameras/Review_{a.view:02d}')
limit=a.frames or (600 if a.headless else 0);count=0;print(json.dumps({'asset':str(path),'doors':list(runtime.doors),'physical_latch_runtime_installed':True,'physics_backend':'PhysX','buttons':'Turn handle -> Open drive / manual robot push; Release handle; Close drive. All commands act through physics.'}),flush=True)
try:
while app.is_running() and (not limit or count<limit):world.step(render=True);count+=1
except KeyboardInterrupt:pass
finally:world.stop();runtime.close();app.close()