simulo.RLPlayer
RL policy player supporting skrl checkpoints and JIT/ONNX models.
Loads trained PPO/other policies and runs inference. Automatically detects whether the checkpoint is a skrl checkpoint or a JIT/ONNX exported model.
Example:
task = HumanoidLocomotionTask()env = simulo.LearningEnv(task, num_envs=64)
# Using skrl checkpointplayer = simulo.RLPlayer( env=env, checkpoint="checkpoints/humanoid_final.pt",)
# Or using JIT exported modelplayer = simulo.RLPlayer( env=env, checkpoint="exported/policy.pt", # JIT file)
# Run 10 episodes with real-time visualizationplayer.play(num_episodes=10, real_time=True)
# Record a videoplayer.play(num_steps=500, video_path="humanoid_demo.mp4")
# Export to ONNX for deploymentplayer.export_onnx("humanoid_policy.onnx")Attributes:
checkpoint— Path to the loaded checkpointagent— The skrl agent instance (after setup, if using skrl)policy— The Policy instance (if using JIT/ONNX)
Real usage, from the shipped cartpole_eval app’s rollout job — a TorchScript checkpoint runs the policy directly, no trainer:
env = simulo.LearningEnv(task=CartpoleEvalTask(with_camera=True), num_envs=1, device="cuda")player = simulo.RLPlayer(env=env, checkpoint=policy_path, device="cuda")stats = player.play( num_steps=200, record=simulo.RecordConfig(output_path=mcap_path, policy_checkpoint=policy_path, robot_model="cartpole"),)
player.close()env.close()simulo.RLPlayer( env: LearningEnv, checkpoint: str, device: str = 'cuda', ml_framework: str = 'torch',)play()
Section titled “play()”RLPlayer.play( num_episodes: Optional[int] = None, num_steps: Optional[int] = None, real_time: bool = False, video_path: Optional[str] = None, video_length: int = 200, deterministic: bool = True, record: Union[None, str, 'Path', 'RecordConfig'] = None,) -> Dict[str, Any]Run policy inference.
Args:
num_episodes— Number of episodes to runnum_steps— Number of steps to run (alternative to num_episodes)real_time— Match simulation dt to wall-clock timevideo_path— Path to save video (requires cameras enabled). Orthogonal torecord=— kept for backward compatibility with the existing video-stub behavior.video_length— Steps per video segmentdeterministic— Use mean actions instead of sampling (only for skrl)record— Optional MCAP recording.None(default) skips all recording with a single None-check overhead per step .str/Path→ defaultRecordConfig(output_path=...). ARecordConfigis used directly. Seesimulo.RecordConfigfor full options.
Returns:
Dictionary with playback statistics. When recording is enabled the recorder’s stats (record_path, recording_complete, partial, interrupted, error, messages_written, etc.) are merged into the returned dict.
load()
Section titled “load()”RLPlayer.load(path: str) -> NoneLoad a checkpoint.
Args:
path— Path to checkpoint file (.pt)
policy
Section titled “policy”RLPlayer.policy: Optional[Any]property
Get the underlying policy.
Returns the JIT/ONNX Policy if using direct inference, or the skrl agent’s policy network otherwise.
RLPlayer.agent: Optional[Any]property
Get the skrl agent (if using skrl).
Returns None if using JIT/ONNX policy directly.
recorder
Section titled “recorder”RLPlayer.recorder: Optional[Any]property
Get the live simulo.McapRecorder during play() (Wave Policy-Eval-Completeness).
Returns the active recorder while play(record=...) is in flight,
or None otherwise. Use this to call
player.recorder.record_annotation(text, kind=..., env_index=...)
from inside a step callback or a mid-run hook.
export_onnx()
Section titled “export_onnx()”RLPlayer.export_onnx(path: str) -> NoneExport policy to ONNX format for deployment.
Args:
path— Output path for ONNX file
export_jit()
Section titled “export_jit()”RLPlayer.export_jit(path: str) -> NoneExport policy to TorchScript JIT format.
Args:
path— Output path for JIT file (.pt)
close()
Section titled “close()”RLPlayer.close() -> NoneClose the player and cleanup resources.