1+ from datetime import datetime , timedelta
12import os
23from pathlib import Path
34
@@ -29,7 +30,7 @@ def initialize(
2930
3031 # Add random postfix to logger ID to avoid conflicts
3132 self ._logger_id = f"{ logger_id } _{ np .random .randint (10000 )} "
32- rr .init (self ._logger_id , spawn = True )
33+ rr .init (self ._logger_id , spawn = spawn )
3334 if save_path is not None :
3435 # Ensure directory exists
3536 save_path .parent .mkdir (parents = True , exist_ok = True )
@@ -48,19 +49,55 @@ def stop(self):
4849 self ._logged_meshes .clear ()
4950 self ._last_transforms .clear ()
5051
51- def log_stage (self , frame_idx : int = None ):
52+ def set_time (
53+ self ,
54+ sequence : int | None = None ,
55+ duration : int | float | timedelta | np .timedelta64 | None = None ,
56+ timestamp : int | float | datetime | np .datetime64 | None = None ,
57+ ) -> None :
5258 """
53- Log the entire USD stage to Rerun.
59+ Set the current time of the Rerun logger.
60+
61+ Used for all subsequent logging on the same thread, until the next call to
62+ [`rerun.set_time`][], [`rerun.reset_time`][] or [`rerun.disable_timeline`][].
63+
64+ For example: `set_time("frame_nr", sequence=frame_nr)`.
65+
66+ There is no requirement of monotonicity. You can move the time backwards if you like.
67+
68+ You are expected to set exactly ONE of the arguments `sequence`, `duration`, or `timestamp`.
69+ You may NOT change the type of a timeline, so if you use `duration` for a specific timeline,
70+ you must only use `duration` for that timeline going forward.
5471
55- Args:
56- frame_idx: Optional frame index for this log. If None, uses static data.
72+ Parameters
73+ ----------
74+ sequence:
75+ Used for sequential indices, like `frame_nr`.
76+ Must be an integer.
77+ duration:
78+ Used for relative times, like `time_since_start`.
79+ Must either be in seconds, a [`datetime.timedelta`][], or [`numpy.timedelta64`][].
80+ For nanosecond precision, use `numpy.timedelta64(nanoseconds, 'ns')`.
81+ timestamp:
82+ Used for absolute time indices, like `capture_time`.
83+ Must either be in seconds since Unix epoch, a [`datetime.datetime`][], or [`numpy.datetime64`][].
84+ For nanosecond precision, use `numpy.datetime64(nanoseconds, 'ns')`.
85+
86+ """
87+ rr .set_time (
88+ "clock" ,
89+ sequence = sequence ,
90+ duration = duration ,
91+ timestamp = timestamp ,
92+ )
93+
94+ def log_stage (self ):
95+ """
96+ Log the entire USD stage to Rerun.
5797 """
5898 if self .stage is None :
5999 print ("Warning: USD stage is not initialized." )
60100 return
61- # Set frame index if provided
62- if frame_idx is not None :
63- rr .set_time ("frame_idx" , sequence = frame_idx )
64101
65102 # Traverse all prims in the stage
66103 current_paths = set ()
0 commit comments