Skip to content

Fix reset_joints_by_scale and reset_joints_by_offsets to only affect the joint_names specified in SceneEntityCfg #2803

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Guidelines for modifications:
* Matthew Trepte
* Mayank Mittal
* Nikita Rudin
* Octi (Zhengyu) Zhang
* Pascal Roth
* Sheikh Dawood
* Ossama Ahmed
Expand Down Expand Up @@ -121,7 +122,6 @@ Guidelines for modifications:
* Yijie Guo
* Yujian Zhang
* Yun Liu
* Zhengyu Zhang
* Ziqi Fan
* Zoe McCarthy
* David Leon
Expand Down
2 changes: 1 addition & 1 deletion source/isaaclab/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.40.10"
version = "0.40.11"

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

0.40.11 (2025-06-27)
~~~~~~~~~~~~~~~~~~~~

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.10 (2025-06-25)
~~~~~~~~~~~~~~~~~~~~

Expand Down
20 changes: 10 additions & 10 deletions source/isaaclab/isaaclab/envs/mdp/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -1040,22 +1040,22 @@ 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, joint_vel, env_ids=env_ids, joint_ids=asset_cfg.joint_ids)


def reset_joints_by_offset(
Expand All @@ -1074,22 +1074,22 @@ 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, joint_vel, env_ids=env_ids, joint_ids=asset_cfg.joint_ids)


def reset_nodal_state_uniform(
Expand Down