RecorderManager#

The RecorderManager coordinates multiple recorders, handling their lifecycle and data distribution.

Overview#

The RecorderManager:

  • Manages a collection of recorders

  • Dispatches data to appropriate recorders

  • Handles start/stop of recording sessions

  • Coordinates build and cleanup phases

Usage#

The RecorderManager is typically accessed through the Scene:

import genesis as gs

gs.init()
scene = gs.Scene()
robot = scene.add_entity(gs.morphs.URDF(file="robot.urdf"))
scene.build()

# Add multiple recorders
scene.add_recorder(
    gs.recorders.NPZFile(filename="data.npz"),
    data_func=lambda: robot.get_qpos(),
)

scene.add_recorder(
    gs.recorders.MPLLinePlot(title="Positions"),
    data_func=lambda: robot.get_qpos(),
)

# Start all recorders
scene.start_recording()

for i in range(1000):
    scene.step()

# Stop all recorders
scene.stop_recording()

Recording Controls#

# Start recording all registered recorders
scene.start_recording()

# Check recording status
if scene.is_recording:
    print("Currently recording")

# Stop recording and trigger cleanup
scene.stop_recording()

# Stop recording and save video (if viewer is active)
scene.stop_recording(save_to="output.mp4")

API Reference#

class genesis.recorders.recorder_manager.RecorderManager(step_dt: float)[source]#

Bases: object

Manage the creation, processing, and cleanup of all data recorders.

Parameters:

step_dt (float) – The simulation time step.

RECORDER_TYPES_MAP = {<class 'genesis.options.recorders.PyQtLinePlot'>: <class 'genesis.recorders.plotters.PyQtLinePlotter'>, <class 'genesis.options.recorders.MPLLinePlot'>: <class 'genesis.recorders.plotters.MPLLinePlotter'>, <class 'genesis.options.recorders.MPLImagePlot'>: <class 'genesis.recorders.plotters.MPLImagePlotter'>, <class 'genesis.options.recorders.MPLVectorFieldPlot'>: <class 'genesis.recorders.plotters.MPLVectorFieldPlotter'>, <class 'genesis.options.recorders.VideoFile'>: <class 'genesis.recorders.file_writers.VideoFileWriter'>, <class 'genesis.options.recorders.CSVFile'>: <class 'genesis.recorders.file_writers.CSVFileWriter'>, <class 'genesis.options.recorders.NPZFile'>: <class 'genesis.recorders.file_writers.NPZFileWriter'>}#
add_recorder(data_func: Callable[[], Any], rec_options: RecorderOptions) Recorder[source]#

Automatically read and process data. See RecorderOptions for more details.

Parameters:
  • data_func (Callable[[], Any]) – A function with no arguments that returns the data to be recorded.

  • rec_options (RecorderOptions) – The options for the recorder which determines how the data is recorded and processed.

Returns:

recorder – The created recorder object.

Return type:

Recorder

build()[source]#

Start data recording.

stop()[source]#

Stop and complete data recording.

reset(envs_idx=None)[source]#
step(global_step: int)[source]#

Increment the step count and process data from each recording configuration.

In threaded mode, data is put in queues. In non-threaded mode, data is processed synchronously.

property is_recording: bool#
property is_built: bool#

See Also#