Unverified Commit 11b1096d authored by renezurbruegg's avatar renezurbruegg Committed by GitHub

Adds preserve order flag to JointPositionToLimitsAction (#3716)

# Description

Adds `preserve_order` flag to `JointPositionToLimitsActionCfg`

## Type of change

- New feature (non-breaking change which adds functionality)

## Screenshots

Please attach before and after screenshots of the change if applicable.

<!--
Example:

| Before | After |
| ------ | ----- |
| _gif/png before_ | _gif/png after_ |

To upload images to a PR -- simply drag and drop an image while in edit
mode and it should upload the image directly. You can then paste that
source into the above before/after sections.
-->

## Checklist

- [x] I have read and understood the [contribution
guidelines](https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html)
- [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
- [x] 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
- [x] 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
-->

---------
Signed-off-by: 's avatarKelly Guo <kellyg@nvidia.com>
Co-authored-by: 's avatarKelly Guo <kellyg@nvidia.com>
parent 26083c77
[package]
# Note: Semantic Versioning is used: https://semver.org/
version = "0.48.7"
version = "0.48.8"
# Description
title = "Isaac Lab framework for Robot Learning"
......
Changelog
---------
0.48.8 (2025-10-15)
~~~~~~~~~~~~~~~~~~~
Added
^^^^^
* Added :attr:`preserve_order` flag to :class:`~isaaclab.envs.mdp.actions.actions_cfg.JointPositionToLimitsActionCfg`
0.48.7 (2025-11-25)
~~~~~~~~~~~~~~~~~~~
......
......@@ -131,6 +131,9 @@ class JointPositionToLimitsActionCfg(ActionTermCfg):
This operation is performed after applying the scale factor.
"""
preserve_order: bool = False
"""Whether to preserve the order of the joint names in the action output. Defaults to False."""
@configclass
class EMAJointPositionToLimitsActionCfg(JointPositionToLimitsActionCfg):
......
......@@ -55,7 +55,9 @@ class JointPositionToLimitsAction(ActionTerm):
super().__init__(cfg, env)
# resolve the joints over which the action term is applied
self._joint_ids, self._joint_names = self._asset.find_joints(self.cfg.joint_names)
self._joint_ids, self._joint_names = self._asset.find_joints(
self.cfg.joint_names, preserve_order=cfg.preserve_order
)
self._num_joints = len(self._joint_ids)
# log the resolved joint names for debugging
logger.info(
......@@ -77,17 +79,22 @@ class JointPositionToLimitsAction(ActionTerm):
elif isinstance(cfg.scale, dict):
self._scale = torch.ones(self.num_envs, self.action_dim, device=self.device)
# resolve the dictionary config
index_list, _, value_list = string_utils.resolve_matching_names_values(self.cfg.scale, self._joint_names)
index_list, _, value_list = string_utils.resolve_matching_names_values(
self.cfg.scale, self._joint_names, preserve_order=cfg.preserve_order
)
self._scale[:, index_list] = torch.tensor(value_list, device=self.device)
else:
raise ValueError(f"Unsupported scale type: {type(cfg.scale)}. Supported types are float and dict.")
# parse clip
if self.cfg.clip is not None:
if isinstance(cfg.clip, dict):
self._clip = torch.tensor([[-float("inf"), float("inf")]], device=self.device).repeat(
self.num_envs, self.action_dim, 1
)
index_list, _, value_list = string_utils.resolve_matching_names_values(self.cfg.clip, self._joint_names)
index_list, _, value_list = string_utils.resolve_matching_names_values(
self.cfg.clip, self._joint_names, preserve_order=cfg.preserve_order
)
self._clip[:, index_list] = torch.tensor(value_list, device=self.device)
else:
raise ValueError(f"Unsupported clip type: {type(cfg.clip)}. Supported types are dict.")
......
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