Skip to content

Commit

Permalink
Fixes order of logging metrics and sampling commands in command manag…
Browse files Browse the repository at this point in the history
…er (#1352)

# Description

In the command manager, we were logging the metrics after resampling the
commands. This leads to incorrect logging of metrics when inside the
`resample` call, the metrics tensors get reset. This MR fixes the order
to make sure the bug doesn't happen.

## Type of change

- Bug fix (non-breaking change which fixes an issue)

## Checklist

- [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./isaaclab.sh --format`
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] I have updated the changelog and the corresponding version in the
extension's `config/extension.toml` file
- [x] I have added my name to the `CONTRIBUTORS.md` or my name already
exists there

---------

Signed-off-by: Kelly Guo <[email protected]>
Co-authored-by: Kelly Guo <[email protected]>
Co-authored-by: Kelly Guo <[email protected]>
  • Loading branch information
3 people authored Dec 16, 2024
1 parent fe976d7 commit fc6042f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion source/extensions/omni.isaac.lab/config/extension.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]

# Note: Semantic Versioning is used: https://semver.org/
version = "0.29.2"
version = "0.29.3"

# Description
title = "Isaac Lab framework for Robot Learning"
Expand Down
9 changes: 9 additions & 0 deletions source/extensions/omni.isaac.lab/docs/CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
Changelog
---------

0.29.3 (2024-12-16)
~~~~~~~~~~~~~~~~~~~

Fixed
^^^^^

* Fixed ordering of logging and resamping in the command manager, where we were logging the metrics after resampling the commands. This leads to incorrect logging of metrics when inside the resample call, the metrics tensors get reset.


0.29.2 (2024-12-16)
~~~~~~~~~~~~~~~~~~~

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,17 +132,20 @@ def reset(self, env_ids: Sequence[int] | None = None) -> dict[str, float]:
# resolve the environment IDs
if env_ids is None:
env_ids = slice(None)
# set the command counter to zero
self.command_counter[env_ids] = 0
# resample the command
self._resample(env_ids)

# add logging metrics
extras = {}
for metric_name, metric_value in self.metrics.items():
# compute the mean metric value
extras[metric_name] = torch.mean(metric_value[env_ids]).item()
# reset the metric value
metric_value[env_ids] = 0.0

# set the command counter to zero
self.command_counter[env_ids] = 0
# resample the command
self._resample(env_ids)

return extras

def compute(self, dt: float):
Expand Down Expand Up @@ -175,8 +178,8 @@ def _resample(self, env_ids: Sequence[int]):
Args:
env_ids: The list of environment IDs to resample.
"""
# resample the time left before resampling
if len(env_ids) != 0:
# resample the time left before resampling
self.time_left[env_ids] = self.time_left[env_ids].uniform_(*self.cfg.resampling_time_range)
# increment the command counter
self.command_counter[env_ids] += 1
Expand Down

0 comments on commit fc6042f

Please sign in to comment.