1- import time
21import os
2+ import time
33from dataclasses import dataclass , field
44from pathlib import Path
5+
56import carb .input
67import numpy as np
78import omni .kit .commands
89from isaacsim import SimulationApp
910from isaacsim .core .api import World
11+ from isaacsim .core .prims import SingleXFormPrim
1012from isaacsim .core .utils import stage as stage_utils
1113from omni .isaac .core .utils .prims import get_prim_at_path
12- from isaacsim .core .prims import SingleXFormPrim
1314from pxr import Gf , Sdf , UsdGeom
15+ from usd_rerun_logger .usd_logger import UsdRerunLogger
1416
1517from simulation .camera_manager import CameraManager
16-
1718from simulation .environments .pyramid import create_stepped_pyramid
1819from simulation .environments .rails import create_rails
1920from simulation .follow_camera import FollowCamera
@@ -175,6 +176,8 @@ def __init__(
175176 window_size = 200 , update_interval = 100
176177 ) # 1-second window for 200Hz, update every 100 steps
177178 self .log_rtf = False
179+ self ._simulation_time = 0.0
180+ self .logger = None
178181
179182 def initialize (self ):
180183 self .world = World (
@@ -215,6 +218,7 @@ def initialize_scene(self):
215218 self .world .reset ()
216219 self .go2 .reset ()
217220 self .go2 .initialize ()
221+ self ._simulation_time = 0.0
218222
219223 if demo_config .robot_position is not None :
220224 # Set the initial robot position in every possible way. I'm confuesed how the reset prcedure works in Isaac,
@@ -253,11 +257,16 @@ def initialize_scene(self):
253257 self .camera_manager .link_waypoint_mission (self .waypoint_mission )
254258
255259 # TODO: find a better way to separate artefacts outputs per test run
256- self .camera_manager .start_writers (
257- output_dir = OUTPUT_DIR
258- / f"{ self .current_scene .name } _{ int (self .difficulty * 100 )} " ,
260+ run_dir = OUTPUT_DIR / f"{ self .current_scene .name } _{ int (self .difficulty * 100 )} "
261+
262+ self .logger = UsdRerunLogger (
263+ self .world .stage ,
264+ save_path = str (run_dir / "simulation.rrd" ),
265+ application_id = "go2-demo" ,
259266 )
260267
268+ self .camera_manager .start_writers (output_dir = run_dir )
269+
261270 def load_next_scene (self ):
262271 print ("Loading next scene..." )
263272 current_index = (
@@ -283,6 +292,7 @@ def reload_scene(self):
283292 self .load_scene (self .current_scene )
284293
285294 def on_physics_step (self , step_size ) -> None :
295+ self ._simulation_time += step_size
286296 rtf = self ._rtf_calculator .step (step_size )
287297 if rtf is not None and self .log_rtf :
288298 print (f"Real-Time Factor (RTF): { rtf :.2f} " )
@@ -335,6 +345,8 @@ def step(self):
335345
336346 # Prevent the RTF from going above 1.0 (faster than real-time)
337347 self .steady_rate .sleep ()
348+ if self .logger :
349+ self .logger .log_stage ()
338350
339351 def get_rtf (self ) -> float :
340352 return self ._rtf_calculator .rtf
0 commit comments