Repository navigation
Let tasks record per-episode values, and port the pick-and-place and door metrics - #1739
Conversation
[Medium impact] The PR appears safe to merge; no actionable issues were found. SummaryTasks can now add per-episode values through
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]
Reviews (1) · Last reviewed commit: "Record the door openness change for ever..." · Reviewed by Greptile |
🤖 Isaac Lab-Arena Review BotSummaryThis PR brings back Findings🔵 Improvement: isaaclab_arena/tasks/rotate_revolute_joint_task.py:38: 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 limitationsThis review covers The CI test jobs for VerdictShip it |
80c740d to
21e01e9
Compare
|
/review |
d0b6a4b to
615ac19
Compare
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>
615ac19 to
656f250
Compare
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): |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
Thanks for the clean up. A couple of nits.
| 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. |
There was a problem hiding this comment.
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. 😅
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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").
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
See above about Maximum
There was a problem hiding this comment.
AI-drafted (Claude Code), reviewed by me.
Same here: RevoluteJointMaximumMovement and revolute_joint_maximum_movement in #1769.
781aa22
into
cvolk/feature/episode-recorder-terms
…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>
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>
Port the three task metrics that #1456 deletes,
ObjectDisplacedRateMetric,RevoluteJointMovedRateMetric, andObjectPeakSpeedExceededRateMetric, to the per-episode recording from #1468. The tasks that used them record them again by default, throughTaskBase.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?
main, deleted in #1456ObjectDisplacedRateMetric(object_displaced_rate, from #1731)PickAndPlaceTaskobject_displacement: the largest distance in metres that the picked object got from where it was after the episode's first stepRevoluteJointMovedRateMetric(revolute_joint_moved_rate)OpenDoorTask,CloseDoorTask(throughRotateRevoluteJointTask)revolute_joint_movement: how far the door's joint moved from its reset openness at most, as a fraction of the joint rangeObjectPeakSpeedExceededRateMetric(object_peak_speed_exceeded_rate)GoalPoseTask,GearInsertionTask,AssemblyTask,PlaceUprightTaskobject_peak_speed: the highest linear speed of the task's object in m/sTaskBase.get_episode_recorder_terms()returns terms likeIsaacLabArenaEnvironment(episode_recorder_terms=...)does. A composite task adds_subtask_<i>to its subtasks' term names.ObjectDisplacement,RevoluteJointMovement, andObjectPeakSpeed(from Record custom per-episode values, including values tracked every step #1468), inisaaclab_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:After:
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:Validation
ObjectDisplacementgives 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 insidetorch.inference_mode(). A NaN or infinite position now recordsnullwith a warning, as Record custom per-episode values, including values tracked every step #1468 does for every term.object_displacementin a real pick-and-place environment. Seven tests that download Lightwheel assets could not run because of an SSL certificate error onapi-dev.lightwheel.net.