Skip to content

Commit e5588db

Browse files
committed
fix(terminations): index before reduce in joint_pos_out_of_limit
Root cause: reduced over joints to [N] then indexed with [:, joint_ids] → IndexError. Change: compare to limits → [N,J], slice columns with joint_ids → [N,K], then .any(dim=1). Result: returns [N] without error for both [1,J,2] and [N,J,2] limit tensors; joint_ids=None still uses all joints.
1 parent 5f71ff4 commit e5588db

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

source/isaaclab/isaaclab/envs/mdp/terminations.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,19 @@ def joint_pos_out_of_limit(env: ManagerBasedRLEnv, asset_cfg: SceneEntityCfg = S
8484
if asset_cfg.joint_ids is None:
8585
asset_cfg.joint_ids = slice(None)
8686

87-
limits = asset.data.soft_joint_pos_limits[:, asset_cfg.joint_ids]
88-
out_of_upper_limits = torch.any(asset.data.joint_pos[:, asset_cfg.joint_ids] > limits[..., 1], dim=1)
89-
out_of_lower_limits = torch.any(asset.data.joint_pos[:, asset_cfg.joint_ids] < limits[..., 0], dim=1)
90-
return torch.logical_or(out_of_upper_limits, out_of_lower_limits)
87+
# compute any per-joint violations (avoid reducing before indexing)
88+
out_of_upper_limits = asset.data.joint_pos > asset.data.soft_joint_pos_limits[..., 1] # [N, J]
89+
out_of_lower_limits = asset.data.joint_pos < asset.data.soft_joint_pos_limits[..., 0] # [N, J]
90+
91+
# truncate above output to just the joints we care about
92+
out_of_upper_limits = out_of_upper_limits[:, asset_cfg.joint_ids] # [N, K]
93+
out_of_lower_limits = out_of_lower_limits[:, asset_cfg.joint_ids] # [N, K]
94+
95+
# reduce over selected joints
96+
out_of_upper_limits = torch.any(out_of_upper_limits, dim=1) # [N]
97+
out_of_lower_limits = torch.any(out_of_lower_limits, dim=1) # [N]
98+
99+
return torch.logical_or(out_of_upper_limits, out_of_lower_limits) # [N]
91100

92101

93102
def joint_pos_out_of_manual_limit(

0 commit comments

Comments
 (0)