• Maurice Rahme's avatar
    Fixes termination term effort limit check logic (#3163) · a60168a2
    Maurice Rahme authored
    # Description
    
    Fix the logic in `joint_effort_out_of_limit()`; this function aims to
    detect effort limit violations by comparing the desired (computed)
    effort against the applied effort, noting that the simulator clips
    applied torque to the limit assign on creation.
    
    Originally, the logic was written such that if the applied and computed
    torques are equal, then a violation has occurred. However, this is wrong
    as shown by the below example:
    
    ```python
    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)
    
    ```
    
    The solution is hence simply to flip the limit detection logic.
    
    Fixes #3155
    
    
    ## Type of change
    
    - 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`
    - [x] I have made corresponding changes to the documentation (N/A)
    - [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 (N/A)
    - [x] I have added my name to the `CONTRIBUTORS.md` or my name already
    exists there
    a60168a2
extension.toml 728 Bytes