Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions docs/source/concepts/reinforcement_learning.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,6 @@ To evaluate the latest compatible checkpoint in the interactive visualizer:

The ``train`` and ``play`` commands work across the supported RL libraries.

For a bounded evaluation of an RSL-RL policy on a manager-based task, add ``--evaluate``:

.. code-block:: bash

uv run isaaclab play --rl_library rsl_rl --task Isaac-Cartpole --checkpoint latest --evaluate

This reports each environment's first completed episode: mean reward, mean duration and termination
fractions. It exits after at most one task episode limit and skips policy export. Physics presets,
agent overrides, checkpoint selection and environment cleanup follow normal playback.


Try pretrained controllers directly below: perturb Cartpole or command G1,
ANYmal-D, and MicroDuck with travel and yaw controls. These compact browser
scenes illustrate policy control; use native playback for full task evaluation.
Expand Down
20 changes: 0 additions & 20 deletions docs/source/how-to/neural_robot_dynamics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -112,23 +112,3 @@ that require those values. Contact-force observables are penetration-based indic
force measurements. External body forces do not affect the standalone model. Use free-motion coupling
when numerical contact with other moving bodies is required. Neural solvers currently reject coupled-solver
entries.

Evaluate an explicit policy
---------------------------

Policy evaluation uses the shared RSL-RL playback workflow. ``physics=`` selects evaluation
physics; ``--checkpoint`` selects the policy using the ordinary playback checkpoint resolver.

.. code-block:: bash

uv run --extra newton-neural isaaclab play --rl_library rsl_rl --evaluate \
--task Isaac-Reach-Franka --checkpoint logs/rsl_rl/reach_franka_nerd/RUN/model_100.pt \
physics=newton_mjwarp

Evaluate additional checkpoints by invoking the same command again. Supply matching ``agent.*``
overrides when the policy was trained with settings that differ from the selected task defaults,
including network dimensions and action clipping. For example, ANYmal C policies trained with neural
physics use ``agent.clip_actions=1.5``. Saved agent YAML is not restored automatically.

The report counts each world's first episode once and reports reward, duration and termination
fractions. Command metrics are not part of the report.
Empty file.
6 changes: 3 additions & 3 deletions source/isaaclab_neural/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ checkpoint during normal Newton solver construction and checks it against the li
The backend owns state, contacts, graph capture and queued model changes.

The scripts in `scripts/neural` compose a task with these pieces to record and fit a model; the
package itself imports no task registry. Dataset and checkpoint paths are explicit. Policy training, playback and evaluation use
the existing RL entrypoints: `isaaclab play --rl_library rsl_rl --evaluate` scores one checkpoint on
the physics that `physics=` selects.
package itself imports no task registry. Dataset and checkpoint paths are explicit. Policy training
and playback use the existing RL entrypoints, `isaaclab train` and `isaaclab play`, with `physics=`
selecting the physics preset.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Removed the unreleased RSL-RL ``--evaluate`` policy-scoring mode and its helper. Use
``isaaclab play --rl_library rsl_rl`` for ordinary policy playback.
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,17 @@
import contextlib
import logging
import os
from collections.abc import Callable

import torch
from torch import Tensor

from isaaclab.app import add_launcher_args, launch_simulation
from isaaclab.envs import DirectMARLEnvCfg, ManagerBasedRLEnvCfg
from isaaclab.envs import DirectMARLEnvCfg
from isaaclab.utils.assets import retrieve_file_path
from isaaclab.utils.seed import configure_seed
from isaaclab.utils.string import list_intersection

import isaaclab_tasks # noqa: F401
from isaaclab_tasks.utils import get_checkpoint_path, resolve_task_config, setup_preset_cli

from ...rsl_rl import RslRlBaseRunnerCfg, RslRlSacRunnerCfg, RslRlSuperMimicRunnerCfg, RslRlVecEnvWrapper
from ...rsl_rl import RslRlBaseRunnerCfg, RslRlSacRunnerCfg, RslRlSuperMimicRunnerCfg
from ...utils.wandb import is_wandb_checkpoint, resolve_wandb_checkpoint
from ..common import (
CHECKPOINT_SELECTORS,
Expand Down Expand Up @@ -65,9 +61,6 @@ def _parse_args(argv: list[str]) -> argparse.Namespace:
parser.add_argument(
"--external_callback", default=None, help="Fully qualified path to an externally defined callback."
)
parser.add_argument(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Warning · Compatibility — Deprecate scoring before removal

Documented --evaluate commands now fail parsing, and score_policy callers lose the function. Keep both functional through deprecation with targeted warnings, migration and removal guidance, and old/new path tests.

"--evaluate", action="store_true", help="Score the first episode of each manager-based environment and exit."
)
cli_args.add_rsl_rl_args(parser)
add_launcher_args(parser)
remaining_args_env_registration = cli_args.register_external_tasks(argv)
Expand Down Expand Up @@ -107,44 +100,6 @@ def _resolve_checkpoint(
return get_checkpoint_path(log_root_path, agent_cfg.load_run, agent_cfg.load_checkpoint)


@torch.inference_mode()
def score_policy(env: RslRlVecEnvWrapper, policy: Callable[..., Tensor]) -> tuple[int, float, float, dict[str, float]]:
"""Report rewards, durations and termination fractions for each world's first episode.
Aggregated command metrics cannot distinguish first endings from later autoresets, so they are not
reconstructed from extras['log']. All worlds count once, regardless of their episode lengths.
"""
task = env.unwrapped
obs, _ = env.reset()
reward, seconds = (torch.zeros(task.num_envs, device=task.device) for _ in range(2))
running = torch.ones(task.num_envs, dtype=torch.bool, device=task.device) # Environments in their first episode
endings = dict.fromkeys(task.termination_manager.active_terms, 0)
for _ in range(task.max_episode_length):
obs, step_reward, dones, extras = env.step(policy(obs))
policy.reset(dones) # The shared RSL-RL policy interface clears recurrent state at episode endings.
reward += step_reward * running
seconds += task.step_dt * running
ended = running & dones.bool()
running &= ~ended
count = int(ended.sum())
if count == 0:
continue
for name in endings:
endings[name] += int((ended & task.termination_manager.get_term(name)).sum())
if not running.any():
break
episode_count = int((~running).sum())
if episode_count == 0:
raise RuntimeError("No evaluation episode completed within the task episode limit")
divisor = episode_count
return (
episode_count,
reward[~running].sum().item() / divisor,
seconds[~running].sum().item() / divisor,
{name: count / divisor for name, count in endings.items()},
)


def run(argv: list[str]) -> None:
"""Play a checkpoint of an RSL-RL agent."""
args_cli = _parse_args(argv)
Expand All @@ -155,8 +110,6 @@ def run(argv: list[str]) -> None:
return
with startup_screen(args_cli, num_stages=3) as screen:
env_cfg, agent_cfg = resolve_task_config(args_cli.task, args_cli.agent, play_mode=not args_cli.train_env_cfg)
if args_cli.evaluate and not isinstance(env_cfg, ManagerBasedRLEnvCfg):
raise ValueError("--evaluate requires a manager-based RL environment for termination reporting")
pre_launch_video_config(env_cfg, args_cli)
screen.stage("Launching simulation")
with launch_simulation(env_cfg, args_cli), contextlib.ExitStack() as cleanup:
Expand Down Expand Up @@ -195,14 +148,6 @@ def run(argv: list[str]) -> None:
runner.load(resume_path, map_location=agent_cfg.device)
policy = runner.get_inference_policy(device=env.unwrapped.device)

if args_cli.evaluate:
screen.close()
episodes, reward, seconds, endings = score_policy(env, policy)
logger.info("%d episodes, mean reward %.3f, mean duration %.3f s", episodes, reward, seconds)
for name, fraction in endings.items():
logger.info(" %s: %.2f%%", name, 100 * fraction)
return

export_model_dir = os.path.join(log_dir, "exported")
runner.export_policy_to_jit(path=export_model_dir, filename="policy.pt")
runner.export_policy_to_onnx(path=export_model_dir, filename="policy.onnx")
Expand Down
53 changes: 0 additions & 53 deletions source/isaaclab_rl/test/test_policy_evaluation.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* Restored the ANYmal C flat RSL-RL agent's concrete experiment name and default action clipping by removing
its neural-physics-specific overrides. Set ``agent.experiment_name`` and ``agent.clip_actions`` explicitly
when a run needs different values.
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
from isaaclab_rl.rsl_rl import RslRlMLPModelCfg, RslRlOnPolicyRunnerCfg, RslRlPpoAlgorithmCfg, RslRlSymmetryCfg

from isaaclab_tasks.core.velocity.mdp.symmetry import anymal
from isaaclab_tasks.utils import preset

from ..flat_env_cfg import ANYMAL_C_NERD_TARGET_REACH


@configclass
Expand Down Expand Up @@ -53,10 +50,7 @@ def __post_init__(self):
super().__post_init__()

self.max_iterations = 300
self.experiment_name = preset(default="anymal_c_flat", newton_nerd="anymal_c_flat_nerd")
# Under physics=newton_nerd the task clips its joint targets to the range the model was recorded on. Clipping
# the actions to the same range lets the policy observe the action that was applied.
self.clip_actions = preset(default=self.clip_actions, newton_nerd=ANYMAL_C_NERD_TARGET_REACH / 0.5)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Warning · Compatibility — Transition neural action clipping

Removing the newton_nerd override changes the agent's action bound while deployment still clips joint targets. Preserve the prior default through deprecation with a targeted warning, explicit override guidance, and transition tests.

self.experiment_name = "anymal_c_flat"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Warning · Compatibility — Transition the neural experiment default

physics=newton_nerd now selects anymal_c_flat instead of anymal_c_flat_nerd, changing run and checkpoint lookup. Preserve the prior selection through deprecation with a targeted warning, explicit override guidance, and transition tests.

self.actor.hidden_dims = [128, 128, 128]
self.critic.hidden_dims = [128, 128, 128]

Expand Down
6 changes: 2 additions & 4 deletions source/isaaclab_tasks/test/neural/test_neural_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,12 @@ def test_recording_is_taken_on_the_reference_solver(task, selections):
assert type(steel.sim.physics.solver_cfg) is not type(reference.sim.physics.solver_cfg)


def test_anymal_action_bounds_have_one_declaration():
env, agent = resolve_task_config(TASKS[1], "rsl_rl_cfg_entry_point", overrides=["physics=newton_nerd"])
def test_anymal_recording_and_deployment_use_same_target_bounds():
env, _ = resolve_task_config(TASKS[1], None, overrides=["physics=newton_nerd"])
recording, _ = resolve_task_config(
TASKS[1], None, env_cfg_entry_point="nerd_recording_cfg_entry_point", overrides=[]
)
assert recording.actions.joint_targets.clip == env.actions.joint_pos.clip
for low, high in env.actions.joint_pos.clip.values():
assert agent.clip_actions * env.actions.joint_pos.scale == pytest.approx((high - low) / 2)


def test_optional_configuration_imports_without_neural_library():
Expand Down
Loading