Skip to content

Let tasks record per-episode values, and port the pick-and-place and door metrics - #1739

Merged
cvolkcvolk merged 12 commits into
cvolk/feature/episode-recorder-termsfrom
cvolk/feature/object-displacement-term
Nov 24, 2026
Merged

cvolkcvolk merged 12 commits into
cvolk/feature/episode-recorder-termsfrom
cvolk/feature/object-displacement-term

Conversation

@cvolkcvolk

@cvolkcvolk cvolkcvolk commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Port the three task metrics that #1456 deletes, ObjectDisplacedRateMetric, RevoluteJointMovedRateMetric, and ObjectPeakSpeedExceededRateMetric, to the per-episode recording from #1468. The tasks that used them record them again by default, through TaskBase.get_episode_recorder_terms(), which this PR brings back.

This PR is based on #1468.

Why this change?

#1456 removes the HDF5 metrics, including the ones tasks declared in get_metrics(), and #1468 lets environments record their own per-episode values. A value that belongs to the task, like how far the picked object moved, would then have to be added by every environment that uses the task. This PR brings back a way for tasks to record such values, and ports the deleted task metrics with it.

What changes?

Metric on main, deleted in #1456 Used by Now recorded per episode as The old rate
ObjectDisplacedRateMetric (object_displaced_rate, from #1731) PickAndPlaceTask object_displacement: the largest distance in metres that the picked object got from where it was after the episode's first step share of episodes above 0.02
RevoluteJointMovedRateMetric (revolute_joint_moved_rate) OpenDoorTask, CloseDoorTask (through RotateRevoluteJointTask) revolute_joint_movement: how far the door's joint moved from its reset openness at most, as a fraction of the joint range share of episodes above 0.05
ObjectPeakSpeedExceededRateMetric (object_peak_speed_exceeded_rate) GoalPoseTask, GearInsertionTask, AssemblyTask, PlaceUprightTask object_peak_speed: the highest linear speed of the task's object in m/s share of episodes above 0.5
  • Task terms: TaskBase.get_episode_recorder_terms() returns terms like IsaacLabArenaEnvironment(episode_recorder_terms=...) does. A composite task adds _subtask_<i> to its subtasks' term names.
  • Terms: ObjectDisplacement, RevoluteJointMovement, and ObjectPeakSpeed (from Record custom per-episode values, including values tracked every step #1468), in isaaclab_arena/terms/episode_recorders.py, keep the definitions of the metrics they replace.

Arena records these values but no longer computes or prints the rates. Whoever needs a rate computes it from the episode results, as in the usage example below.

Usage example

Before, on main:

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

After:

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 pick-and-place episode line then holds "object_displacement": 0.031. Nothing in Arena turns this into a rate yet. A shared function for the old rates will be added once something in Arena needs one. Until then, a script or notebook computes the rate from the episode results:

records = read_episode_records(run_dir / "episode_results_rebuild0.jsonl")
displaced_rate = sum(record["object_displacement"] > 0.02 for record in records) / len(records)

Validation

  • ObjectDisplacement gives the same per-episode answer as the old function on random trajectories at thresholds from 0 to 0.05 m, including partial resets and steps inside torch.inference_mode(). A NaN or infinite position now records null with a warning, as Record custom per-episode values, including values tracked every step #1468 does for every term.
  • Locally on the GPU, the recorder, builder, composite, door, and pick-and-place environment tests pass, and the recorder test checks object_displacement in a real pick-and-place environment. Seven tests that download Lightwheel assets could not run because of an SSL certificate error on api-dev.lightwheel.net.
  • Not run: evaluations with real policies.

@greptile-apps

greptile-apps Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

Tasks can now add per-episode values through get_episode_recorder_terms().

  • Tasks can add per-episode values to their environment's records.
  • Pick-and-place records the greatest distance its object moves during an episode.
  • Door episodes record the greatest change from the door's reset openness.

No actionable issues were found. Tests were inspected but not run.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  B[Built-in terms] --> M[Combine and check names]
  T[Task terms] --> M
  C[Composite subtask terms] --> S[Add subtask suffix]
  S --> T
  E[Environment terms] --> M
  M --> R[EpisodeRecorderManager]
  R --> P[Update after each step]
  P --> W[Write finished episode before reset]
Loading

Reviews (1) · Last reviewed commit: "Record the door openness change for ever..." · Reviewed by Greptile

@arena-review-bot

arena-review-bot Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

🤖 Isaac Lab-Arena Review Bot

Summary

This PR brings back TaskBase.get_episode_recorder_terms() and uses it to record the three task metrics that #1456 deletes. PickAndPlaceTask records object_displacement, the door tasks record revolute_joint_movement, and the goal-pose, gear-insertion, assembly, and place-upright tasks record object_peak_speed. Each term uses the same object and the same reference point as the old metric on main, so applying the old thresholds to the recorded values reproduces the old rates. The author has addressed all three points from the earlier review.

Findings

🔵 Improvement: isaaclab_arena/tasks/rotate_revolute_joint_task.py:38: RotateRevoluteJointTask now stores the reset openness twice, as reset_joint_percentage (may be None) and as reset_openness (resolved). Passing reset_openness to the reset event would leave one attribute.

Test Coverage and CI Cost

🔵 isaaclab_arena/tests/test_episode_recorder_terms.py:100: The door test starts at the reset openness (0.2), so a term that measured from the first observed openness would still pass. Starting at 0.25 would make the test check that the term measures from the reset openness.

Scope and test limitations

This review covers 615ac198. A newer commit, d0b6a4b5, was pushed after the review was requested and isn't covered here. It adds the rate helpers in report_data.py, the docs paragraph on v0.4 rates, and the run-experiment skill note.

The CI test jobs for 615ac198 were cancelled when the newer commit was pushed, so the simulation tests aren't confirmed for this commit. Pre-commit and the image build passed.

Verdict

Ship it

@cvolkcvolk
cvolkcvolk force-pushed the cvolk/feature/object-displacement-term branch from 80c740d to 21e01e9 Compare November 23, 2026 21:44
@cvolkcvolk

Copy link
Copy Markdown
Collaborator Author

/review

@cvolkcvolk
cvolkcvolk force-pushed the cvolk/feature/object-displacement-term branch from d0b6a4b to 615ac19 Compare November 23, 2026 22:37
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>
@cvolkcvolk
cvolkcvolk force-pushed the cvolk/feature/object-displacement-term branch from 615ac19 to 656f250 Compare November 23, 2026 22:56
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>
for name, term_cfg in environment_terms.items():
assert name not in terms, f"Episode recorder term name '{name}' is used by a built-in term."
terms[name] = term_cfg
for added_terms in (task_terms, environment_terms):

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.

My understanding is users can add new term to record. Does it support removing/replacing the default task term? Would it be a valid case to consider?

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.

Mh might be. Do you have a case in mind?
Replacing by name isn't supported here an environment term with the same name as a task term asserts when the environment is built

@alexmillane alexmillane left a comment

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.

Thanks for the clean up. A couple of nits.

Comment on lines +42 to +44
The start position is taken after the episode's first control step, so motion during that step, such as a
short drop onto the support after spawning, does not count; settling that lasts longer does. An object that
is moved and put back still counts with its largest distance. Deformable objects use their mean node position.

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.

I don't suppose we can use our settling infrastructure? We already have some method of getting post-settling poses. This would seem like a place to use it?

Perhaps there's some reason we can't? In that case - fine. Let's get this in, before we go down any more rabit holes. 😅

@cvolkcvolk cvolkcvolk Nov 26, 2026 •

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.

We looked at it and kept the start after the first step to keep the term simple. Measuring from rest would need its own rest check, because a sequential composite doesn't evaluate a later subtask's objects_settled until the earlier ones finish. The field would also be missing whenever the object never comes to rest.

return float(self._peak_speed[env_id])


class ObjectDisplacement(EpisodeRecorderTerm):

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.

To me ObjectDisplacement would be a continuous measurement of the displacement. Suggestion to either:

  • rename: ObjectMaximumDisplacement, or
  • change: actually record the continuous displacement and let some agent calculate the max in post (arguably that's more in line with our ethos of "record raw signals, let users process").

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.

Renamed to ObjectMaximumDisplacement and object_maximum_displacement in #1769. I kept the maximum rather than recording the displacement every step: the episode results hold one line per episode, and per-step data goes into the trajectory HDF5 files.

return float(self._largest_displacement[env_id])


class RevoluteJointMovement(EpisodeRecorderTerm):

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.

See above about Maximum

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.

Same here: RevoluteJointMaximumMovement and revolute_joint_maximum_movement in #1769.

@cvolkcvolk
cvolkcvolk merged commit 781aa22 into cvolk/feature/episode-recorder-terms Nov 24, 2026
10 checks passed
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/object-displacement-term branch November 26, 2026 12:03
cvolkcvolk added a commit that referenced this pull request Nov 27, 2026
Follow-up to #1456: address Alex's review comments on #1739, which were
not addressed before #1456 merged.

Rename `ObjectDisplacement` to `ObjectMaximumDisplacement` and
`RevoluteJointMovement` to `RevoluteJointMaximumMovement`, together with
the episode result fields they write.

## Why this change?

#1739 was merged into #1456 before these comments were addressed:

- `ObjectDisplacement` reads like the object's displacement over time,
while the term records the largest displacement in the episode. The same
holds for `RevoluteJointMovement`. Recording the value at every step
instead does not fit the episode results, which hold one line per
episode; per-step data belongs in the trajectory HDF5 files.

The terms are not in a release yet, so renaming them now breaks no
released code.

## What changes?

- The two term classes and the fields `PickAndPlaceTask` and
`RotateRevoluteJointTask` record are renamed to
`object_maximum_displacement` and `revolute_joint_maximum_movement`.
`object_peak_speed` keeps its name, since "peak" already says it is a
maximum.
- `ObjectMaximumDisplacement` keeps measuring from the object's position
after the episode's first step. Alex also asked whether it could measure
from the resting position instead; the reply on #1739 explains why it
does not.

Breaking changes on `main`:
- The episode result fields `object_displacement` and
`revolute_joint_movement` are now `object_maximum_displacement` and
`revolute_joint_maximum_movement`.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
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.

3 participants