Skip to content

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 checkpoint
player = simulo.RLPlayer(
env=env,
checkpoint="checkpoints/humanoid_final.pt",
)
# Or using JIT exported model
player = simulo.RLPlayer(
env=env,
checkpoint="exported/policy.pt", # JIT file
)
# Run 10 episodes with real-time visualization
player.play(num_episodes=10, real_time=True)
# Record a video
player.play(num_steps=500, video_path="humanoid_demo.mp4")
# Export to ONNX for deployment
player.export_onnx("humanoid_policy.onnx")

Attributes:

  • checkpoint — Path to the loaded checkpoint
  • agent — 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',
)
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 run
  • num_steps — Number of steps to run (alternative to num_episodes)
  • real_time — Match simulation dt to wall-clock time
  • video_path — Path to save video (requires cameras enabled). Orthogonal to record= — kept for backward compatibility with the existing video-stub behavior.
  • video_length — Steps per video segment
  • deterministic — 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 → default RecordConfig(output_path=...). A RecordConfig is used directly. See simulo.RecordConfig for 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.

RLPlayer.load(path: str) -> None

Load a checkpoint.

Args:

  • path — Path to checkpoint file (.pt)
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.

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.

RLPlayer.export_onnx(path: str) -> None

Export policy to ONNX format for deployment.

Args:

  • path — Output path for ONNX file
RLPlayer.export_jit(path: str) -> None

Export policy to TorchScript JIT format.

Args:

  • path — Output path for JIT file (.pt)
RLPlayer.close() -> None

Close the player and cleanup resources.