Repository navigation
Record metric inputs and run metadata during generation #84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a058fd8
feat: record metric inputs and run metadata during generation
bokalnv 96a15bd
docs: describe what generation records per step, attempt and run
bokalnv 5303c8f
fix: keep earlier runs' records and label only this run's datasets
bokalnv 5948fc0
docs: say the result file and attempt log come with --result_file
bokalnv 77b511d
feat: make metric recording opt-in and keep algorithm diagnostics in …
bokalnv 9ea6a76
fix: record metric inputs with a custom recorder and without a succes…
bokalnv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| # Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| """Recorder terms that store the per-step data annotation, generation and the dataset metrics read.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from typing import TYPE_CHECKING | ||
|
|
||
| from isaaclab.envs.mdp.recorders.recorders_cfg import ActionStateRecorderManagerCfg | ||
| from isaaclab.managers import RecorderTerm, RecorderTermCfg, TerminationTermCfg | ||
| from isaaclab.utils import configclass | ||
|
|
||
| if TYPE_CHECKING: | ||
| from autodata_interfaces.datastream import Datastream | ||
|
|
||
|
|
||
| class PreStepDatagenInfoRecorder(RecorderTerm): | ||
| """Records end-effector and commanded target poses, and optionally object poses, before each step. | ||
|
|
||
| Attributes: | ||
| datastream: Datastream to read. Set it on the class once the Datastream exists, since Isaac Lab | ||
| copies recorder configurations when building the env. | ||
| """ | ||
|
|
||
| datastream: Datastream | None = None | ||
|
|
||
| def record_pre_step(self): | ||
| assert self.datastream is not None, "Set PreStepDatagenInfoRecorder.datastream before stepping the env." | ||
| datagen_info = { | ||
| "eef_pose": self.datastream.embodiment_adapter.get_eef_poses(env_ids=None), | ||
| "target_eef_pose": self.datastream.action_to_target_eef_pose(self._env.action_manager.action), | ||
| } | ||
| if self.cfg.record_object_poses: | ||
| datagen_info["object_pose"] = self.datastream.get_object_poses() | ||
| return "obs/datagen_info", datagen_info | ||
|
|
||
|
|
||
| @configclass | ||
| class PreStepDatagenInfoRecorderCfg(RecorderTermCfg): | ||
| """Configuration for :class:`PreStepDatagenInfoRecorder`.""" | ||
|
|
||
| class_type: type[RecorderTerm] = PreStepDatagenInfoRecorder | ||
| record_object_poses: bool = True | ||
| """Annotation needs object poses for the source pool; generation leaves them out, as no metric reads them.""" | ||
|
|
||
|
|
||
| class PostStepSuccessRecorder(RecorderTerm): | ||
| """Records whether the task's success term holds after each step, as ``step_success``.""" | ||
|
|
||
| def record_post_step(self): | ||
| success_term = self.cfg.success_term | ||
| return "step_success", success_term.func(self._env, **success_term.params) | ||
|
|
||
|
|
||
| @configclass | ||
| class PostStepSuccessRecorderCfg(RecorderTermCfg): | ||
| """Configuration for :class:`PostStepSuccessRecorder`.""" | ||
|
|
||
| class_type: type[RecorderTerm] = PostStepSuccessRecorder | ||
| success_term: TerminationTermCfg | None = None | ||
| """The task's success term; the env itself runs without termination terms.""" | ||
|
|
||
|
|
||
| @configclass | ||
| class DatagenInfoRecorderManagerCfg(ActionStateRecorderManagerCfg): | ||
| """Action/state recorder plus the per-step ``obs/datagen_info`` term.""" | ||
|
|
||
| record_pre_step_datagen_info = PreStepDatagenInfoRecorderCfg() | ||
|
|
||
|
|
||
| def add_step_success_recorder(recorder_cfg: object, success_term: TerminationTermCfg | None) -> None: | ||
| """Add the ``step_success`` term to any recorder manager configuration. | ||
|
|
||
| Nothing is added without a success term, since there is then no success to record. | ||
|
|
||
| Args: | ||
| recorder_cfg: Recorder manager configuration the env will be built with. | ||
| success_term: The task's success term, or None when the task has none. | ||
| """ | ||
| if success_term is not None: | ||
| recorder_cfg.record_post_step_success = PostStepSuccessRecorderCfg(success_term=success_term) | ||
|
|
||
|
|
||
| def add_pose_recorder(recorder_cfg: object) -> None: | ||
| """Add the per-step end-effector and commanded target pose term to any recorder manager configuration. | ||
|
|
||
| Object poses are left out, as no metric reads them. A configuration that already has the | ||
| ``record_pre_step_datagen_info`` term, such as :class:`DatagenInfoRecorderManagerCfg`, keeps its own. | ||
|
|
||
| Args: | ||
| recorder_cfg: Recorder manager configuration the env will be built with. | ||
| """ | ||
| if not hasattr(recorder_cfg, "record_pre_step_datagen_info"): | ||
| recorder_cfg.record_pre_step_datagen_info = PreStepDatagenInfoRecorderCfg(record_object_poses=False) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.