Skip to content

Record custom per-episode values, including values tracked every step - #1468

Merged
cvolkcvolk merged 55 commits into
cvolk/refactor/delete-hdf5-metricsfrom
cvolk/feature/episode-recorder-terms
Nov 24, 2026
Merged

cvolkcvolk merged 55 commits into
cvolk/refactor/delete-hdf5-metricsfrom
cvolk/feature/episode-recorder-terms

Conversation

@cvolkcvolk

@cvolkcvolk cvolkcvolk commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

Let environments record their own values about each episode, including values that build up while the episode runs. An environment adds an episode recorder term, and each episode's line in the episode results holds the term's output under its name.

This PR is based on #1456, which removes the HDF5 metrics.

Why this change?

The episode results (episode_results_*.jsonl, one line per finished episode) are what the HTML report, the plots, the KPI exporters and the sensitivity analysis read. With #1456 they become the one place for everything about an episode, and HDF5 files only hold trajectories and demonstrations. The idea is to store raw per-episode values there and let users, or their agents, compute whatever metric they need, instead of Arena predefining metrics.

Today that line cannot hold a value that builds up during the episode:

  • Only end-of-episode values. An environment can add a value through IsaacLabArenaEnvironment(episode_recorder_terms=...), but only with a function that runs when the episode ends. A value that builds up during the episode, such as an object's peak speed or how high it was lifted, cannot be recorded at all.
  • The old way was a metric. It took four definitions (an Isaac Lab recorder term, its cfg, a compute function and a MetricBase class) and an HDF5 file that was read back after the run. Users who needed their own measurements, such as how far an object was pulled out, ended up combining MetricBase, progress tracking and recorder hooks.
  • The line did not say which term wrote a field. An environment term's keys went to the top level, next to success, and two terms returning the same key failed only when the first episode ended.

What changes?

  • Terms come from the environment. Terms are added through IsaacLabArenaEnvironment(episode_recorder_terms=...), as on main. No task needs its own terms today, so TaskBase gets no hook for them; one can be added when a task needs it.
  • Terms that follow the episode. A term can be a class derived from EpisodeRecorderTerm. It keeps one value per environment, updates it in post_step() after every control step, clears it in reset() when an episode starts, and returns the episode's result from __call__() when the episode ends. post_step() and __call__() are abstract, so a missing or misspelled method fails when the term is created. A plain function still works for a value that can be read at the end.
  • One line layout. Each term's result goes into the line under the term's name. EpisodeRecorderManager writes the core fields (success, episode_length, and so on) itself, at the top level as before. A duplicate term name fails when the environment is built. A term named like a core field would overwrite it, so it fails when the first episode is recorded. A term returns any JSON value, such as a number or a dict, or None to leave itself out. A NaN or infinite value, for example after a physics blow-up, is written as null with a warning that names the term, instead of failing the Run.
  • One per-step hook. Arena advances task progress and steps the episode recorder terms from ArenaRecorderManager.record_post_step(). The pinned Isaac Lab calls it only while a recorder term is active, so Arena adds PostStepHookRecorder, a term that records nothing, whenever there is task progress or a class-based episode recorder term. It replaces ProgressTrackingRecorder, which did the same and also published the progress snapshot; the environment now publishes env.extras["progress_tracking"] itself when it advances task progress. Isaac Lab #8822 calls record_post_step() every step, so the hook can go once Arena moves to an Isaac Lab release that includes it; it is on Isaac Lab main, not on the release/3.0.0 branch Arena pins. test_post_step_hook_recorder_is_still_needed fails at that point and lists what to remove.
  • Docs. The "Arena in your repo" page gains a short section, "Recording a Custom Value per Episode", on the example's two terms and what each episode's line holds.
  • Example and authoring skill. The advanced external environment example (isaaclab_arena_examples/external_environments/advanced.py) records two values per episode through episode_recorder_terms: record_object_final_height, a function term it defines, and ObjectPeakSpeed, a class term in isaaclab_arena/terms/episode_recorders.py, next to Arena's other ready-made terms. The author-environment skill points to the example for per-episode values.

This PR adds no terms to Arena's tasks. object_peak_speed_exceeded_rate and revolute_joint_moved_rate, removed in #1456, are not recorded by default; the example records an object's peak speed with ObjectPeakSpeed.

Episode recorder terms and the tracked events from #1457 do different jobs. A tracked event records when a sequence of predicates happened, inside the progress field. An episode recorder term records a value of your own under its name.

Breaking changes:

  • The result of a term added through IsaacLabArenaEnvironment(episode_recorder_terms=...) moves from the top level of the line to under the term's name. A term that returns a single number or boolean can still be a sensitivity analysis --outcome, under the term's name; a term that returns a dict cannot.
  • NaN and infinity in a term's output are written as null, with a warning.
  • A class-based term must derive from EpisodeRecorderTerm and implement post_step() and __call__().
  • The built-in core term (CoreEpisodeRecorderTermCfg) is removed. The manager writes the core fields.
  • ProgressTrackingRecorder and ProgressTrackingRecorderCfg are removed. The recorder term Arena adds is now named post_step_hook. env.extras["progress_tracking"] keeps its content.

Not included: rates or averages of custom values in the report and the console table, and adding terms from the Experiment YAML.

Usage example

The interface in short:

class EpisodeRecorderTerm(ManagerTermBase):
    def post_step(self): ...                           # after every control step
    def reset(self, env_ids=None): ...                 # when an episode starts
    def __call__(self, env, env_id, object_name): ...  # when the episode ends; one argument per params key


IsaacLabArenaEnvironment(
    ...,
    episode_recorder_terms={
        "object_peak_speed": EpisodeRecorderTermCfg(func=ObjectPeakSpeed, params={"object_name": "cracker_box"})
    },
)

func is a class derived from EpisodeRecorderTerm, or a plain function func(env, env_id, ...) that runs once when the episode ends.

Before, recording whether the object moved took a metric: an Isaac Lab recorder term that saved the object's velocity at every step into an HDF5 file, its cfg class, a function that computed the rate from the file after the run, and a MetricBase class that tied them together. The task listed it:

class PickAndPlaceTask(TaskBase):
    def get_metrics(self) -> list[MetricBase]:
        return [SuccessRateMetric(), ObjectPeakSpeedExceededRateMetric(self.pick_up_object)]
# Printed after the rollout: 'object_peak_speed_exceeded_rate': 0.9

After, ObjectPeakSpeed, the class term the example uses, follows the episode and returns one result per episode:

class ObjectPeakSpeed(EpisodeRecorderTerm):
    """Records the highest linear speed [m/s] an object reached during the episode."""

    def __init__(self, cfg, env):
        super().__init__(cfg, env)
        self._object_name = cfg.params["object_name"]
        self._peak_speed = torch.zeros(env.num_envs, device=env.device)

    def post_step(self):
        velocity_w = self._env.arena_world.get_mean_linear_velocity_w(self._object_name)
        speed = torch.linalg.norm(velocity_w, dim=-1)
        torch.maximum(self._peak_speed, speed, out=self._peak_speed)

    def reset(self, env_ids=None):
        self._peak_speed[slice(None) if env_ids is None else env_ids] = 0.0

    def __call__(self, env, env_id, object_name):
        return float(self._peak_speed[env_id])

The value is updated in place (out=...) because Arena may run steps inside torch.inference_mode() and reset outside it.

Each line of the episode results then holds the term's result under its name (some fields left out):

{"job_name": "pnp_pi0", "env_id": 0, "episode_in_env": 3, "success": true, "progress": {...},
 "object_peak_speed": 0.83}

The old rate is a comparison over the lines, and the threshold can change without running the evaluation again:

records = read_episode_records(run_dir / "episode_results_rebuild0.jsonl")
moved_rate = sum(record["object_peak_speed"] > 0.5 for record in records) / len(records)

Validation

Rebased onto the rebased #1456, which is on main (46c7699).

  • pre-commit passes. The docs build passes with sphinx-build -W.
  • After the rebase onto 645eb30, the diff of this PR is unchanged. 146 tests pass in 24 files: the 14 progress and recorder tests listed below, test_composite_task_base, test_sequential_composite_task, test_object_settling, test_place_upright_task, test_gear_insertion_task, test_open_door, test_close_door, test_external_environment, test_rollout_policy, and test_trajectory_recording.
  • After the rebase, I ran this PR's test files and the ones that read the episode results, each in its own process, on the GPU. All 23 passed, including test_gear_insertion_recording (Newton) and test_sensitivity_analysis.
  • After the last three commits (one hook term, one docs example, manager checks), I reran the affected files, each in its own process. 28 files pass: the progress tests (test_completion_criteria_tracking, test_task_success_from_progress, test_true_for_consecutive_steps, test_tracked_events, test_temporal_predicate_composition), the recorder tests (test_episode_recorder, test_episode_recorder_manager, test_arena_env_builder_episode_recorder_terms, test_recorder_dataset_export, test_arena_recorder_manager, test_episode_limit, test_isaaclab_demo_success, test_isaaclab_interop, test_record_demos), and the task and environment tests that read the published progress (test_composite_task_base, test_sequential_composite_task, test_open_door, test_close_door, test_composite_open_door, test_sequential_open_door, test_object_settling, test_object_on_termination, test_object_control_force_actions, test_object_control_runner, test_deformable_object, test_place_upright_task, test_gear_insertion_task, test_gear_insertion_environment). In test_gear_insertion_environment, the camera test fails to create its render graph when the whole file runs in one Isaac Sim process; it passes on its own, as it did before these commits.
  • After the example commit, test_external_environment passes (3 tests), and a 2-episode zero-action run of the advanced example writes "object_peak_speed": {"peak_speed": ...} on each line.
  • After the review fixes (post_step terms found while the terms are prepared, the recorder test uses the example's ObjectPeakSpeed and requires a moving box, the docs include the example terms), 27 tests pass in test_episode_recorder_manager (with a new test that builds the manager before the simulation plays; it fails with AttributeError on the previous code), test_episode_recorder, test_external_environment, test_arena_recorder_manager, test_episode_limit, and test_arena_env_builder_episode_recorder_terms. The docs build passes.
  • After replacing CORE_FIELD_NAMES with the check at record time, 28 tests pass in the same six files, with a new stand-in test for the replay source record index, and test_experiment_runner passes (14 tests).
  • After the review fixes (abstract post_step() and __call__(), post_step(self), terms only from the environment, any JSON value, NaN written as null), 108 tests pass in 16 files, covering the recorder, task, progress, demo-tool and sensitivity analysis tests, and test_experiment_runner passes (14 tests). pre-commit and the docs build pass.
  • After the rebase onto 46c7699, the diff of this PR is unchanged, pre-commit passes, and 169 tests pass in the recorder, task, progress, demo-tool, sensitivity analysis and Run table tests, plus test_experiment_runner (14 tests).
  • Not run: the full test suite and evaluations with real policies.

@cvolkcvolk
cvolkcvolk force-pushed the cvolk/refactor/delete-hdf5-metrics branch from 5891872 to 61e7a64 Compare October 22, 2026 07:47
@cvolkcvolk
cvolkcvolk force-pushed the cvolk/feature/episode-recorder-terms branch from 39964e0 to 2e5910b Compare October 22, 2026 07:47
@cvolkcvolk
cvolkcvolk force-pushed the cvolk/feature/episode-recorder-terms branch from 2e5910b to 1722b54 Compare November 17, 2026 17:15
@cvolkcvolk
cvolkcvolk force-pushed the cvolk/refactor/delete-hdf5-metrics branch from 61e7a64 to d6326cc Compare November 17, 2026 17:18
@cvolkcvolk
cvolkcvolk force-pushed the cvolk/feature/episode-recorder-terms branch from 3c9f1da to 64d9ec8 Compare November 18, 2026 15:06
@cvolkcvolk
cvolkcvolk force-pushed the cvolk/refactor/delete-hdf5-metrics branch from f96fd97 to 44d41b2 Compare November 18, 2026 15:28
@cvolkcvolk
cvolkcvolk force-pushed the cvolk/feature/episode-recorder-terms branch from 64d9ec8 to e48c10e Compare November 18, 2026 15:34
@cvolkcvolk
cvolkcvolk marked this pull request as ready for review November 19, 2026 10:25
@greptile-apps

greptile-apps Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The PR changes the shared episode-results contract used by Arena evaluations.

The PR appears safe to merge, with a non-blocking fix recommended for deferred class-based terms.

Findings

  1. P2 Deferred terms break hook checks ▶

Summary

Tasks and environments can now add named values to each episode’s results, including values collected across its steps.

  • Tasks and environments can add named values to each episode.
  • Episode results keep each term’s value under its own name.
  • Progress and episode terms advance through one per-step recorder hook.

One non-blocking issue remains: the hook check cannot read a class whose creation is deferred until simulation starts.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  T[Task terms] --> B[Environment builder]
  E[Environment terms] --> B
  B --> M[Episode recorder manager]
  S[Control step] --> U[Update term state]
  U --> M
  F[Episode finishes] --> M
  M --> J[Core fields and named term results in JSONL]
  R[New episode starts] --> C[Clear selected term state]
Loading

Reviews (1) · Last reviewed commit: "Move per-episode recording docs into the..." · Reviewed by Greptile

@arena-review-bot

Copy link
Copy Markdown
Contributor

🤖 Isaac Lab-Arena Review Bot

Summary

This PR lets tasks add episode recorder terms through TaskBase.get_episode_recorder_terms(). It adds class-based EpisodeRecorderTerms that update after every control step and stores each term's output under its name in the episode results. It also replaces ProgressTrackingRecorder with a generic PostStepHookRecorder. The design reads cleanly and I have no blocking concerns. My comments are small: a docs gap for the new class-based terms, a mismatch in has_post_step_terms that can't trigger today, and a copied class plus a weak assertion in test_episode_recorder.py. The current code addresses the earlier threads (the term rename, moving the docs page, and where the progress snapshot went).

Findings

🔵 Improvement: docs/pages/arena_in_your_repo/external_tasks_and_embodiments.rst:85: The new section and the task concepts section each point to the other for ObjectPeakSpeed, but neither shows the class. The rendered docs never show post_step(), reset(), or the rule to update state in place. Suggest adding the class to this page, next to the custom task and embodiment.

🔵 Improvement: isaaclab_arena/recording/episode_recorder_manager.py:125: has_post_step_terms raises AttributeError when func is still the class, and the comment in _prepare_terms says that can happen. With the pinned Isaac Lab, managers always load after sim.reset(), so it can't trigger today. Deciding it from term_class in _prepare_terms would remove the mismatch.

🔵 Improvement: isaaclab_arena/tests/test_episode_recorder.py:60: This is a copy of the example's ObjectPeakSpeed, and its docstring still points to the docs page that was folded into the task concepts page. Importing the real class would remove the copy and test the code the docs point to.

Test Coverage and CI Cost

For this commit, CI skipped the "Run tests" and "Run tests with subprocess" jobs; only pre-commit ran. So the test suite hasn't run in CI on these changes. The only test evidence I could see is the local runs listed in the PR description.

In _test_custom_term, the check peak_speed >= 0.0 (test_episode_recorder.py:306) also passes when post_step never runs, because the peak starts at zero. Asserting > 0.0 would catch that. Real-env post_step/reset timing is still covered elsewhere, by the StepCount term in test_episode_limit.py.

Verdict

Minor fixes needed

@cvolkcvolk
cvolkcvolk force-pushed the cvolk/refactor/delete-hdf5-metrics branch from 44d41b2 to 70560c0 Compare November 20, 2026 09:54
@cvolkcvolk
cvolkcvolk force-pushed the cvolk/feature/episode-recorder-terms branch from 28c83de to 8f712b4 Compare November 20, 2026 10:18
Comment thread isaaclab_arena/tasks/task_base.py Resolved
Comment thread docs/pages/concepts/task/index.rst Resolved
@cvolkcvolk cvolkcvolk changed the title Let tasks record their own per-episode values Let environments record their own per-episode values Nov 20, 2026
@cvolkcvolk
cvolkcvolk force-pushed the cvolk/feature/episode-recorder-terms branch 2 times, most recently from d51e767 to 335e28a Compare November 20, 2026 16:23
@cvolkcvolk cvolkcvolk changed the title Let environments record their own per-episode values Record custom per-episode values, including values tracked every step Nov 20, 2026
return make_configclass("TerminationsCfg", termination_fields)()

def _build_episode_recorders_cfg(self, extra_terms: dict[str, EpisodeRecorderTermCfg] | None = None) -> object:
def _build_episode_recorders_cfg(self, environment_terms: dict[str, EpisodeRecorderTermCfg]) -> object:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Are recorders only come from a Python environment?

Tasks can't add them and graph or Experiment YAML has no field for them, so agent-generated environments can't record custom values.

Could TaskBase get a hook for default recorders, and could YAML add them by name?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

AI-drafted (Claude Code), reviewed by me.

Tasks can add terms now: #1739 brought back TaskBase.get_episode_recorder_terms(), and it's on main with #1456. The graph and Experiment YAML still have no field for terms; adding them by name would be a separate follow-up.

EpisodeRecorderTerm only adds post_step() to Isaac Lab's
ManagerTermBase, so a class term is a term that updates every step; a
value that only needs the end of the episode is a function term. Mark
post_step() and __call__ abstract, as Isaac Lab does for ActionTerm and
CommandTerm. A missing or misspelled method now fails when the term is
created instead of being skipped without an error.

The manager no longer checks which class terms override post_step(): it
never changed whether the per-step hook is added, because no env
without task progress has a class term that leaves it out. post_step()
and has_post_step_terms use all class terms.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
post_step(env) gave a class term two handles to the same env, the
argument and self._env. reset(env_ids) and Isaac Lab's recorder term
hooks use self._env, so post_step() takes no argument now. Only
__call__ takes env, because function and class terms share that call.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
The comment said the hook is added whenever task progress or an
episode recorder term needs per-step updates. In evaluation runs the
success term already advances task progress every step, so task
progress needs the hook only when that term is missing, as in Isaac
Lab's replay_demos.py. Say so, and that the hook makes Isaac Lab
compute the observations twice per step.

Both TODOs now also say that Isaac Lab #8822 is on Isaac Lab main, not
on the release/3.0.0 branch Arena pins, so the hook stays until Arena
moves to an Isaac Lab release that includes it.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
No task returned terms from TaskBase.get_episode_recorder_terms(); only
unit tests used it. The example adds both of its terms through
IsaacLabArenaEnvironment(episode_recorder_terms=...), because its task
does not know the object. Two routes for the same thing made it unclear
which to use.

Remove get_episode_recorder_terms(), the composite task's _subtask_<i>
forwarding, and the builder's task_terms argument. Adding the task hook
back later breaks nobody; removing it after a release would.

The "Recording your own values" docs move from the task concepts page
to the environment concepts page and show the environment route.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
Terms had to return a dict because their outputs used to be merged into
the top level of the record. Each term now has its own key, so the rule
only made a single value read "object_peak_speed": {"peak_speed": 0.83}
and kept it from being a sensitivity analysis outcome, which reads
top-level numbers and booleans.

A term now returns any JSON value, such as a number or a dict. NaN and
infinity are still rejected. Both example terms return a plain number.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
After a physics blow-up, a term like ObjectPeakSpeed returns NaN. The
manager raised inside env.step(), which failed the Run and stopped the
remaining Runs unless continue_on_error was set. A NaN from an unstable
simulation is data about that episode, not a bug in the term.

The manager now writes each NaN or infinite float as null and warns
with the term name, env id, and episode. An output that is not JSON at
all is still an error, because that is a bug in the term.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
ObjectPeakSpeed lived in the advanced external environment example.
The follow-up PR has Arena's own tasks record it, so it belongs next to
the other recording code. It moves to
isaaclab_arena/recording/object_terms.py, the example imports it, and
the docs include it from there.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
The environment concepts page repeated, in a long section, what the
external tasks page shows with a worked example. Remove the section
and keep the external tasks page as the one place: it gets the anchor
the other pages link to and two sentences on what the episode results
hold, what a term returns, and that NaN is written as null. The
author-environment skill points there.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
isaaclab_arena/terms is where Arena keeps ready-made terms that tasks
and environments pick from, such as events.py and the HDF5 recorder
terms in recorders.py. The episode recorder terms are the same kind of
library, so object_terms.py in the recording package becomes
isaaclab_arena/terms/episode_recorders.py. The recording package keeps
the manager and the built-in terms that every episode records.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
cvolkcvolk added a commit that referenced this pull request Nov 23, 2026
#1456 deletes ObjectPeakSpeedExceededRateMetric, which the goal-pose,
gear-insertion, assembly, and place-upright tasks used: it read the
object's velocity at every step back from the HDF5 file and counted an
episode if the speed ever went above 0.5 m/s.

ObjectPeakSpeed, moved into isaaclab_arena.terms in #1468, records that
peak speed per episode. The four tasks return it as object_peak_speed
for the object they used for the metric. The old rate is the share of
episodes above 0.5.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
Keep one short paragraph on the external tasks page that names the
example's two terms and shows what a line holds, and drop the two
literalinclude blocks. The authoring skill points to the example.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
object's position at every step back from the HDF5 file. Its
measurement moves into ObjectDisplacement, a class-based episode
recorder term: post_step() tracks the largest distance the object got
from where it was after the episode's first step, and the episode's
line records that distance in metres.

The definition stays the same: motion during the first control step
does not count, an object moved and put back still counts, and
deformables use their mean node position. The old rate is the share of
episodes whose distance is above 0.02 m, and a different threshold can
be applied later without a new run.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
way to add their own: a value that belongs to the task, like how far
the picked object moved, would have to be added by every environment
that uses the task. #1456 deletes the task-level metrics that used to
do this.

TaskBase.get_episode_recorder_terms() is back, along with the composite
task's _subtask_<i> naming and the builder's task_terms argument.
PickAndPlaceTask uses it to record object_displacement for its picked
object, so every pick-and-place episode line has it.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
close-door tasks used: it read the door's openness at every step back
from the HDF5 file and counted an episode if the openness ever got more
than min_openness_change away from the reset openness.

OpennessChange is a class-based episode recorder term that records the
largest change of the openness from the reset openness, as a fraction
of the joint range. RotateRevoluteJointTask returns it as
openness_change, so every open-door and close-door episode line has it.
The old rate is the share of episodes above 0.05. Without a reset
openness, the reference is 0, where the reset event leaves the joint;
the old metric could not handle that case.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
#1456 deletes ObjectPeakSpeedExceededRateMetric, which the goal-pose,
gear-insertion, assembly, and place-upright tasks used: it read the
object's velocity at every step back from the HDF5 file and counted an
episode if the speed ever went above 0.5 m/s.

ObjectPeakSpeed, moved into isaaclab_arena.terms in #1468, records that
peak speed per episode. The four tasks return it as object_peak_speed
for the object they used for the metric. The old rate is the share of
episodes above 0.5.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
OpenDoorTask's success check and the openness_change term both measure
from the reset openness, and both repeated the fallback to 0 when no
reset percentage is given. RotateRevoluteJointTask now resolves it once
as reset_openness, and both read that attribute.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
Tasks now add terms that environment authors do not see. An
environment that adds its own object_displacement while using
PickAndPlaceTask got "is used more than once", although it defined the
name once. The message now says the name is already used by a built-in
or task term.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
torch, pytest and SimpleNamespace do not need the simulator; only the
isaaclab_arena.recording imports stay inside the test functions.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
OpennessChange and its openness_change field did not say what moved,
and did not point back to revolute_joint_moved_rate, the metric they
replace. Rename them to RevoluteJointMovement and
revolute_joint_movement, matching object_displacement and
object_peak_speed, which already follow the names of their metrics.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
Keep one sentence about task terms on the external tasks page and the
composite task design note, and drop the task concepts page sentence.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
RotateRevoluteJointTask stored the reset openness twice: as given and
with None resolved to 0. The reset event now gets the resolved value,
which resets the joint the same way, since rotate_revolute_joint()
defaults to 0. Nothing passes None to RotateRevoluteJointEventCfg
anymore, so its None branch goes too.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
Env 0's first reading equalled the reset openness, so a term that
measured from the first reading would also have passed.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
TaskBase.get_episode_recorder_terms() documents the task route, and
PickAndPlaceTask shows it in use.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
@cvolkcvolk
cvolkcvolk merged commit 781aa22 into cvolk/refactor/delete-hdf5-metrics Nov 24, 2026
12 checks passed
cvolkcvolk added a commit that referenced this pull request Nov 24, 2026
#1456 deletes ObjectPeakSpeedExceededRateMetric, which the goal-pose,
gear-insertion, assembly, and place-upright tasks used: it read the
object's velocity at every step back from the HDF5 file and counted an
episode if the speed ever went above 0.5 m/s.

ObjectPeakSpeed, moved into isaaclab_arena.terms in #1468, records that
peak speed per episode. The four tasks return it as object_peak_speed
for the object they used for the metric. The old rate is the share of
episodes above 0.5.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
cvolkcvolk added a commit that referenced this pull request Nov 25, 2026
…ts (#1456)

Remove the HDF5 metrics and record values about each episode in the
episode results instead. Environments and tasks add episode recorder
terms, the tasks that had metrics record those values again, and the
experiment runner's Run table shows each Run's success rate.

This PR combines three reviewed PRs: this one, #1468 and #1739. Their
review discussions stay there.

## Why this change?

Arena kept results about each episode in two places. The episode results
hold one JSON line per episode, which the report, the plots, the KPI
exporters and the OSMO output read. The metrics saved data into an HDF5
file during the run, only to print a few numbers afterwards. So success
was stored twice, every evaluation wrote an HDF5 file, and a metric took
four definitions. The episode results are now the one place for values
about an episode, and HDF5 files hold only trajectories and
demonstrations.

## What changes?

- **Metrics removed:** `isaaclab_arena.metrics`,
`TaskBase.get_metrics()`, `env.compute_metrics()` and
`ArenaRunResult.metrics`. Without trajectory recording, no HDF5 file is
written.
- **Run table:** `experiment_runner.py` adds `Recorded Episodes`,
`Success Rate` and, for composite tasks, `Subtask Success Rates`
columns, computed from the episode results. They replace the printed
metrics.
- **Episode recorder terms:** an environment adds terms through
`episode_recorder_terms`, a task through `get_episode_recorder_terms()`.
A term is a function that runs when the episode ends, or an
`EpisodeRecorderTerm` class that also updates its value in `post_step()`
after every control step. Its result goes into the episode line under
the term's name.

**Ported task metrics:**

| Metric on `main` | Now recorded per episode as |
|---|---|
| `ObjectDisplacedRateMetric` (`PickAndPlaceTask`) |
`object_displacement`, in m |
| `RevoluteJointMovedRateMetric` (`OpenDoorTask`, `CloseDoorTask`) |
`revolute_joint_movement`, as a fraction of the joint range |
| `ObjectPeakSpeedExceededRateMetric` (`GoalPoseTask`,
`GearInsertionTask`, `AssemblyTask`, `PlaceUprightTask`) |
`object_peak_speed`, in m/s |

Arena records the values but no longer computes the old rates. A shared
function for them will be added once something in Arena needs one.

Breaking changes:
- Tasks must drop `get_metrics()`, and code that called
`env.compute_metrics()` reads the episode results instead. The metric
rates and the policy runner's success rate are no longer printed.
- An environment term's result moves under the term's name in the
episode line. A class-based term must derive from `EpisodeRecorderTerm`
and implement `post_step()`, `reset()` and `__call__(env, env_id)`; it
reads its params in `__init__`.
- `CoreEpisodeRecorderTermCfg` and `ProgressTrackingRecorder` are
removed. The recorder term Arena adds is now `post_step_hook`
(`PostStepHookRecorder`), which can go once Arena's Isaac Lab includes
isaac-sim/IsaacLab#8822.

Three figures still show a "Metrics" box and need to be redrawn:
`open_door_task.png`, `arena_env_builder.png` and
`isaac_lab_arena_arch_overview.png`.

## Usage example

Before:

```python
class PickAndPlaceTask(TaskBase):
    def get_metrics(self) -> list[MetricBase]:
        return [SuccessRateMetric(), ObjectDisplacedRateMetric(self.pick_up_object)]
# Printed as: Metrics: {'num_episodes': 20, 'success_rate': 0.85, 'object_displaced_rate': 0.9}
```

After:

```python
class PickAndPlaceTask(TaskBase):
    def get_episode_recorder_terms(self) -> dict[str, EpisodeRecorderTermCfg]:
        return {
            "object_displacement": EpisodeRecorderTermCfg(
                func=ObjectDisplacement, params={"object_name": self.pick_up_object.name}
            )
        }
```

Each episode line then holds `"object_displacement": 0.031`. The old
rate is `sum(record["object_displacement"] > 0.02 for record in records)
/ len(records)`.

## Validation

After combining the three PRs and rebasing onto `main` (26e069e), the
23 related test files pass locally on the GPU (226 tests). See #1468 and
#1739 for the earlier runs. Not run: the full test suite and evaluations
with real policies.

---------

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
@cvolkcvolk
cvolkcvolk deleted the cvolk/feature/episode-recorder-terms branch November 26, 2026 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants