"""RSL-RL PPO trainer stub (Isaac Lab ``OnPolicyRunner``). Hyperparameters come from the Gym task's ``rsl_rl_cfg_entry_point``. Swap this class when we lock the algorithm (plain PPO vs joint residual, etc.). """ from __future__ import annotations from typing import Any from .base import Algorithm class RslRlPpoTrainer(Algorithm): def __init__(self, agent_cfg: Any): self.agent_cfg = agent_cfg self._runner = None def train(self, env: Any, log_dir: str) -> None: from isaaclab.utils import class_to_dict from rsl_rl.runners import OnPolicyRunner self._runner = OnPolicyRunner( env, class_to_dict(self.agent_cfg), log_dir=log_dir, device=str(env.unwrapped.device) ) self._runner.learn( num_learning_iterations=self.agent_cfg.max_iterations, init_at_random_ep_len=True, ) def load(self, checkpoint: str) -> None: if self._runner is None: raise RuntimeError("call train() or construct a runner before load()") self._runner.load(checkpoint) def act(self, obs: Any) -> Any: if self._runner is None: raise RuntimeError("no runner") return self._runner.alg.act(obs)