In-Process Policies#

An in-process policy computes its actions inside the simulation process. It needs no server and no network connection, so it is the fastest way to check that an environment loads, to replay recorded data, or to run a small trained network.

Arena includes three in-process policies. zero_action returns an all-zero action and needs no model weights. What a zero action does depends on the embodiment’s action space. With relative actions, such as droid_rel_joint_pos, it commands no motion, so the robot stays still while the environment loads and renders. With absolute joint positions, such as droid_abs_joint_pos, it is a target of 0 rad for every arm joint, so the arm moves from its start pose toward the joint-zero pose and can knock objects over. replay plays back one episode from an HDF5 recording. It reports the episode length, so the rollout ends when the recording does. rsl_rl runs a trained RSL-RL checkpoint and loads the params/agent.yaml saved with it.

All three live in isaaclab_arena/policy/. ZeroActionPolicy is the smallest complete example of the policy contract:

zero_action_policy.py
import gymnasium as gym
import torch
from dataclasses import dataclass
from gymnasium.spaces.dict import Dict as GymSpacesDict

from isaaclab_arena.assets.register import register_policy
from isaaclab_arena.policy.policy_base import PolicyBase, PolicyCfg


@dataclass
class ZeroActionPolicyCfg(PolicyCfg):
    """Configure a policy that always returns zero actions."""


@register_policy
class ZeroActionPolicy(PolicyBase[ZeroActionPolicyCfg]):

    name = "zero_action"

    def __init__(self, config: ZeroActionPolicyCfg):
        """
        Initialize ZeroActionPolicy.

        Args:
            config: Typed policy configuration.
        """
        super().__init__(config)

    def get_action(self, env: gym.Env, observation: GymSpacesDict) -> torch.Tensor:
        """
        Always returns a zero action.
        """
        return torch.zeros(env.action_space.shape, device=torch.device(env.unwrapped.device))

Run an in-process policy#

Select the policy with policy.type in a Run of an Experiment Definition. The other keys set fields of its configuration:

policy:
  type: replay
  replay_file_path: demo.hdf5

The replay policy reports the length of its episode, so a Run that uses it can leave out rollout_limit. zero_action has no length, so a Run that uses it must set rollout_limit. The Experiment in Exploring Environment Variations selects zero_action and sets rollout_limit.num_steps.

Add your own#

Write an in-process policy when inference is cheap and its dependencies fit in the Arena image. Examples are a scripted controller, an imitation-learning checkpoint, or a policy from another RL library. Follow Write your own policy. If the policy keeps state across steps, such as a recurrent hidden state or a queued action chunk, clear it for the affected environments in reset(env_ids). If it plays back data of a fixed length, implement has_length() and length().

When a model brings its own dependencies or needs its own GPU or machine, keep it out of the simulation process and run it as a server instead.

Next steps#

Continue to Server–Client Policies to evaluate a foundation model running in a separate process.