Commit 6d9cfc49 authored by Kelly Guo's avatar Kelly Guo Committed by Kelly Guo

Updates warning logging when writing joint limits (#252)

In `omni.isaac.lab.assets.Articulation.write_joint_limits_to_sim`, we
previously added a check for if default joint positions exceed the new
limits being set. When this is True, we log a warning message to
indicate that the default joint positions will be clipped to be within
the range of the new limits. However, the warning message can become
overly verbose in a randomization setting where this API is called on
every environment reset. We now default to only writing the message to
info level logging if called within randomization, and expose a
parameter that can be used to choose the logging level desired.

<!-- As you go through the list, delete the ones that are not
applicable. -->

- Bug fix (non-breaking change which fixes an issue)
- New feature (non-breaking change which adds functionality)

- [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./isaaclab.sh --format`
- [ ] 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
- [x] I have updated the changelog and the corresponding version in the
extension's `config/extension.toml` file
- [ ] I have added my name to the `CONTRIBUTORS.md` or my name already
exists there

<!--
As you go through the checklist above, you can mark something as done by
putting an x character in it

For example,
- [x] I have done this task
- [ ] I have not done this task
-->
parent f4548020
[package]
# Note: Semantic Versioning is used: https://semver.org/
version = "0.33.10"
version = "0.33.11"
# Description
title = "Isaac Lab framework for Robot Learning"
......
Changelog
---------
0.33.10 (2025-01-30)
0.33.11 (2025-01-30)
~~~~~~~~~~~~~~~~~~~~
Fixed
......@@ -12,6 +12,15 @@ Fixed
to the event being triggered at the wrong time after the reset.
0.33.10 (2025-01-22)
~~~~~~~~~~~~~~~~~~~~
Changed
^^^^^^^
* In :meth:`omni.isaac.lab.assets.Articulation.write_joint_limits_to_sim`, we previously added a check for if default joint positions exceed the new limits being set. When this is True, we log a warning message to indicate that the default joint positions will be clipped to be within the range of the new limits. However, the warning message can become overly verbose in a randomization setting where this API is called on every environment reset. We now default to only writing the message to info level logging if called within randomization, and expose a parameter that can be used to choose the logging level desired.
0.33.9 (2025-01-22)
~~~~~~~~~~~~~~~~~~~
......
......@@ -692,6 +692,7 @@ class Articulation(AssetBase):
limits: torch.Tensor | float,
joint_ids: Sequence[int] | slice | None = None,
env_ids: Sequence[int] | None = None,
warn_limit_violation: bool = True,
):
"""Write joint limits into the simulation.
......@@ -699,6 +700,7 @@ class Articulation(AssetBase):
limits: Joint limits. Shape is (len(env_ids), len(joint_ids), 2).
joint_ids: The joint indices to set the limits for. Defaults to None (all joints).
env_ids: The environment indices to set the limits for. Defaults to None (all environments).
warn_limit_violation: Whether to use warning or info level logging when default joint positions exceed the new limits. Defaults to True.
"""
# note: This function isn't setting the values for actuator models. (#128)
# resolve indices
......@@ -721,10 +723,16 @@ class Articulation(AssetBase):
self._data.default_joint_pos[env_ids, joint_ids] = torch.clamp(
self._data.default_joint_pos[env_ids, joint_ids], limits[..., 0], limits[..., 1]
)
omni.log.warn(
violation_message = (
"Some default joint positions are outside of the range of the new joint limits. Default joint positions"
" will be clamped to be within the new joint limits."
)
if warn_limit_violation:
# warn level will show in console
omni.log.warn(violation_message)
else:
# info level is only written to log file
omni.log.info(violation_message)
# set into simulation
self.root_physx_view.set_dof_limits(self._data.joint_limits.cpu(), indices=physx_env_ids.cpu())
......
......@@ -436,7 +436,9 @@ def randomize_joint_parameters(
" upper joint limits."
)
asset.write_joint_limits_to_sim(dof_limits[env_ids][:, joint_ids], joint_ids=joint_ids, env_ids=env_ids)
asset.write_joint_limits_to_sim(
dof_limits[env_ids][:, joint_ids], joint_ids=joint_ids, env_ids=env_ids, warn_limit_violation=False
)
def randomize_fixed_tendon_parameters(
......
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