Unverified Commit fc6042f3 authored by Mayank Mittal's avatar Mayank Mittal Committed by GitHub

Fixes order of logging metrics and sampling commands in command manager (#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: 's avatarKelly Guo <kellyg@nvidia.com>
Co-authored-by: 's avatarKelly Guo <kellyg@nvidia.com>
Co-authored-by: 's avatarKelly Guo <kellyguo123@hotmail.com>
parent fe976d76
[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"
......
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)
~~~~~~~~~~~~~~~~~~~
......
......@@ -132,10 +132,7 @@ class CommandTerm(ManagerTermBase):
# 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():
......@@ -143,6 +140,12 @@ class CommandTerm(ManagerTermBase):
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):
......@@ -175,8 +178,8 @@ class CommandTerm(ManagerTermBase):
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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment