Unverified Commit 9df117c9 authored by ooctipus's avatar ooctipus Committed by GitHub

Fixes reset_joints_by_scale and reset_joints_by_offsets to only affect the...

Fixes reset_joints_by_scale and reset_joints_by_offsets to only affect the joint_names specified in SceneEntityCfg (#2899)

# Description

Both reset_joints_by_offsets and reset_joints_by_scale ignores the
joint_ids specified in SceneEntityCfg passed through asset_cfg and
affects all joints.

This bug is affecting all cartpole environments. 

After the fix the functions are restricted to only reset the joint
specified through SceneEntityCfg, Cartpole environment runs and reset
behaves correctly

Fixes #2800 #980 #1742 

## Type of change

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

- 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`
- [ ] 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
- [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 e2118ac9
......@@ -29,6 +29,7 @@ Guidelines for modifications:
* Matthew Trepte
* Mayank Mittal
* Nikita Rudin
* Octi (Zhengyu) Zhang
* Pascal Roth
* Sheikh Dawood
* Ossama Ahmed
......@@ -124,7 +125,6 @@ Guidelines for modifications:
* Yijie Guo
* Yujian Zhang
* Yun Liu
* Zhengyu Zhang
* Ziqi Fan
* Zoe McCarthy
* David Leon
......
[package]
# Note: Semantic Versioning is used: https://semver.org/
version = "0.40.19"
version = "0.40.20"
# Description
title = "Isaac Lab framework for Robot Learning"
......
Changelog
---------
0.40.20 (2025-07-11)
~~~~~~~~~~~~~~~~~~~~
Fixed
^^^^^
* Fixed :meth:`isaaclab.envs.mdp.events.reset_joints_by_scale`, :meth:`isaaclab.envs.mdp.events.reset_joints_by_offsets`
restricting the resetting joint indices be that user defined joint indices.
0.40.19 (2025-07-11)
~~~~~~~~~~~~~~~~~~~~
......
......@@ -1040,22 +1040,27 @@ def reset_joints_by_scale(
# extract the used quantities (to enable type-hinting)
asset: Articulation = env.scene[asset_cfg.name]
# get default joint state
joint_pos = asset.data.default_joint_pos[env_ids].clone()
joint_vel = asset.data.default_joint_vel[env_ids].clone()
joint_pos = asset.data.default_joint_pos[env_ids, asset_cfg.joint_ids].clone()
joint_vel = asset.data.default_joint_vel[env_ids, asset_cfg.joint_ids].clone()
# scale these values randomly
joint_pos *= math_utils.sample_uniform(*position_range, joint_pos.shape, joint_pos.device)
joint_vel *= math_utils.sample_uniform(*velocity_range, joint_vel.shape, joint_vel.device)
# clamp joint pos to limits
joint_pos_limits = asset.data.soft_joint_pos_limits[env_ids]
joint_pos_limits = asset.data.soft_joint_pos_limits[env_ids, asset_cfg.joint_ids]
joint_pos = joint_pos.clamp_(joint_pos_limits[..., 0], joint_pos_limits[..., 1])
# clamp joint vel to limits
joint_vel_limits = asset.data.soft_joint_vel_limits[env_ids]
joint_vel_limits = asset.data.soft_joint_vel_limits[env_ids, asset_cfg.joint_ids]
joint_vel = joint_vel.clamp_(-joint_vel_limits, joint_vel_limits)
# set into the physics simulation
asset.write_joint_state_to_sim(joint_pos, joint_vel, env_ids=env_ids)
asset.write_joint_state_to_sim(
joint_pos.view(len(env_ids), -1),
joint_vel.view(len(env_ids), -1),
env_ids=env_ids,
joint_ids=asset_cfg.joint_ids,
)
def reset_joints_by_offset(
......@@ -1074,22 +1079,27 @@ def reset_joints_by_offset(
asset: Articulation = env.scene[asset_cfg.name]
# get default joint state
joint_pos = asset.data.default_joint_pos[env_ids].clone()
joint_vel = asset.data.default_joint_vel[env_ids].clone()
joint_pos = asset.data.default_joint_pos[env_ids, asset_cfg.joint_ids].clone()
joint_vel = asset.data.default_joint_vel[env_ids, asset_cfg.joint_ids].clone()
# bias these values randomly
joint_pos += math_utils.sample_uniform(*position_range, joint_pos.shape, joint_pos.device)
joint_vel += math_utils.sample_uniform(*velocity_range, joint_vel.shape, joint_vel.device)
# clamp joint pos to limits
joint_pos_limits = asset.data.soft_joint_pos_limits[env_ids]
joint_pos_limits = asset.data.soft_joint_pos_limits[env_ids, asset_cfg.joint_ids]
joint_pos = joint_pos.clamp_(joint_pos_limits[..., 0], joint_pos_limits[..., 1])
# clamp joint vel to limits
joint_vel_limits = asset.data.soft_joint_vel_limits[env_ids]
joint_vel_limits = asset.data.soft_joint_vel_limits[env_ids, asset_cfg.joint_ids]
joint_vel = joint_vel.clamp_(-joint_vel_limits, joint_vel_limits)
# set into the physics simulation
asset.write_joint_state_to_sim(joint_pos, joint_vel, env_ids=env_ids)
asset.write_joint_state_to_sim(
joint_pos.view(len(env_ids), -1),
joint_vel.view(len(env_ids), -1),
env_ids=env_ids,
joint_ids=asset_cfg.joint_ids,
)
def reset_nodal_state_uniform(
......
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