Skip to content

[Bug Report] joint_effort_out_of_limit flags non-violations #3155

@moribots

Description

@moribots

Describe the bug

isaaclab/envs/mdp/terminations.py::joint_effort_out_of_limit uses:

out_of_limits = torch.isclose(
    asset.data.computed_torque[:, asset_cfg.joint_ids],
    asset.data.applied_torque[:, asset_cfg.joint_ids],
)
return torch.any(out_of_limits, dim=1)

This logic is inverted. If no clipping occurs, computed == applied and the function wrongly returns True. If clipping occurs (i.e., torques exceed limits), computed != applied and the function wrongly returns False.

Steps to reproduce

Minimal repro illustrating the truth table:

from isaaclab.managers import SceneEntityCfg
from isaaclab.envs.mdp.terminations import joint_effort_out_of_limit

env = ...  # any ManagerBasedRLEnv with an Articulation named "robot"
cfg = SceneEntityCfg(name="robot", joint_ids=[0])  # single joint for clarity
art = env.scene["robot"]

# Case A: no clipping (should be False but returns True now)
art.data.computed_torque[:] = 0.0
art.data.applied_torque[:] = 0.0
assert joint_effort_out_of_limit(env, cfg).item() is False  # CURRENT: True (bug)

# Case B: clipping (should be True but returns False now)
art.data.computed_torque[:] = 100.0
art.data.applied_torque[:] = 50.0  # pretend actuator clipped to ±50
assert joint_effort_out_of_limit(env, cfg).item() is True   # CURRENT: False (bug)

System Info

Commit: b5d094e (branch: feature/isaacsim_5_0)

Isaac Sim Version: 5.0

OS: Ubuntu 22.04

GPU: RTX 5080

CUDA: 12.8

GPU Driver: 570.144

Additional context

Option 1: detect clipping via inequality

comp = asset.data.computed_torque[:, asset_cfg.joint_ids]
appl = asset.data.applied_torque[:, asset_cfg.joint_ids]
clipped = ~torch.isclose(comp, appl)
return clipped.any(dim=1)

Option 2: compare against effort limits when available

comp = asset.data.computed_torque[:, asset_cfg.joint_ids]
lims = asset.data.soft_joint_effort_limits[:, asset_cfg.joint_ids]  # shape [N,K]
viol = torch.abs(comp) > lims
return viol.any(dim=1)

Checklist

  • I have checked that there is no similar issue in the repo (required)
  • I have checked that the issue is not in running Isaac Sim itself and is related to the repo

Acceptance Criteria

  • Predicate corrected so non-clipped torques do not trigger termination and clipped torques do.
  • Unit tests for both “no-clip” and “clip” cases, and for presence/absence of soft_joint_effort_limits.
  • Docstring documenting the corrected logic.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions