Skip to content

Fix action clipping for task-space action terms - #8715

Merged
hujc7 merged 4 commits into
isaac-sim:mainfrom
Lynn-hh:fix/task-space-action-clip
Nov 6, 2026
Merged

hujc7 merged 4 commits into
isaac-sim:mainfrom
Lynn-hh:fix/task-space-action-clip

Conversation

@Lynn-hh

@Lynn-hh Lynn-hh commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Description

ActionTermCfg.clip keys are regular expressions that the joint action terms match against joint names. The task-space terms could not do anything sensible with that:

  • DifferentialInverseKinematicsAction resolved the keys against the joint names and then indexed its task-space clip buffer (num_envs, action_dim, 2) with the resulting joint indices. With seven matching joints and a 6-dimensional pose_rel action this raises IndexError; with fewer, joint ranges are silently applied to pose components.
  • OperationalSpaceControllerAction copied clip into its IO descriptor and never applied it.

This follows the direction from #1548 (action-specific key names, interpreted by each action class):

  • Both terms expose action_names, the component names in the order of the action vector. DiffIK: pos_x, pos_y, pos_z plus rot_x, rot_y, rot_z (relative pose) or quat_x, quat_y, quat_z, quat_w (absolute pose). OSC: the components of each target type in order (pos_*/rot_*, pos_*/quat_*, force_*/torque_*), then stiffness_<axis> and damping_ratio_<axis> for the variable impedance modes; if both pose targets are configured, the pose components are prefixed with their target type (pose_abs_pos_x, pose_rel_pos_x, ...); the impedance names are unchanged.
  • clip keys are resolved against these names. A key that matches nothing raises, and so does a key that matches a quaternion component, because clamping quaternion components does not give a valid orientation (the concern raised in [Bug Report] Issues with recently added action clipping for task space actions #1548).
  • The OSC term applies the clip after its scaling and before the controller limits on stiffness and damping ratio, so the limits always bound the result.
  • action_names is also added to the IO descriptors, and the clip docstrings on ActionTermCfg and the two task-space cfgs describe the keys.

#1732 proposes the alternative of removing processed-action clipping from the task-space terms altogether and relying on raw-action clipping in the RL wrappers (RslRlOnPolicyRunnerCfg.clip_actions exists today). If the maintainers prefer that, I am happy to reduce this PR to raising a clear error for clip on task-space terms plus the documentation changes.

Fixes #1548
Related to #1732

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality): the action_names property

Validation

Kit-less unit tests (no simulator), new file source/isaaclab/test/envs/test_task_space_action_clip.py:

python -m pytest source/isaaclab/test/envs/test_task_space_action_clip.py source/isaaclab/test/envs/test_diffik_jacobian_aliasing.py
19 passed

With the three source files reverted to develop, all 11 new tests fail (IndexError / missing action_names / unclipped OSC actions / no ValueError). The tests build the action terms on a stub articulation and environment, the same way test_diffik_jacobian_aliasing.py does, and cover: the names for every DiffIK command layout and for OSC target/impedance combinations, DiffIK clipping of selected components, OSC clipping of position and stiffness including the interaction with the controller limits, and the error cases (joint-name keys, quaternion keys with and without a block prefix). The simulator-based controller tests were not run locally; a run-ci would be appreciated.

Release backport

  • Backport this pull request to the active release branch after it merges into develop

Checklist

  • I have read and understood the contribution guidelines
  • I have run the pre-commit checks (all hooks pass on the changed files)
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have validated the changed behavior with focused coverage and applied the test-audit criteria to any test changes
  • I have added a changelog fragment under source/<pkg>/changelog.d/ for every touched package (do not edit CHANGELOG.rst or bump package versions — CI handles that)
  • I have added my name to the CONTRIBUTORS.md or my name already exists there

ActionTermCfg.clip keys are regular expressions that the joint action
terms match against joint names. DifferentialInverseKinematicsAction did
the same but indexed its task-space clip buffer with the resulting joint
indices, which raises an IndexError when more joints match than the
action has components and otherwise applies joint ranges to pose
components. OperationalSpaceControllerAction only copied the setting
into its IO descriptor and never applied it.

Both terms now expose action_names, the component names in the order of
the action vector (pos_x, rot_x, quat_x, force_x, stiffness_x, ...), and
resolve the clip keys against them. Keys that match nothing raise, and
so do keys that match quaternion components, since clamping those does
not give a valid orientation. The OSC term applies the clip after its
scaling and keeps the controller limits on the impedance parameters.

Fixes isaac-sim#1548
@Lynn-hh
Lynn-hh requested a review from a team October 18, 2026 17:04
@github-actions github-actions Bot added bug Something isn't working isaac-lab Related to Isaac Lab team labels Oct 18, 2026
@greptile-apps

greptile-apps Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] Fixes action clipping logic for task-space control modes.

Fix the quaternion rejection for prefixed action names before merging.

Findings

  1. P1 Quaternion clips escape rejection ▶

Summary

Fixes task-space clipping by matching ranges against action component names rather than joint names.

  • Task-space action clips now select named command components.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
    A[Configured targets] --> B[Build action names]
    B --> C[Match clip keys]
    C --> D[Reject quaternion matches]
    D --> E[Clip scaled actions]
    E --> F[Controller clamps gains]
    F --> G[Controller sets targets]
Loading

Reviews (1) · Last reviewed commit: "Fix action clipping for task-space actio..." · Reviewed by Greptile

if not isinstance(clip, dict):
raise ValueError(f"Unsupported clip type: {type(clip)}. Supported types are dict.")
index_list, matched_names, value_list = string_utils.resolve_matching_names_values(clip, action_names)
quat_names = [name for name in matched_names if name in _QUATERNION_NAMES]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Quaternion clips escape rejection

With target_types=("pose_rel", "pose_abs"), _resolve_action_names produces names such as pose_abs_quat_x. This check only recognizes unprefixed names, so clip={"pose_abs_quat_.*": (-0.1, 0.1)} is accepted and clamps quaternion components instead of raising. The controller then normalizes the altered quaternion, which can change the requested orientation.

Recognize quaternion components even when their names have a block prefix, and add a regression test for this configuration.

@isaaclab-review-bot isaaclab-review-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isaac Lab Review Bot

Needs attention: Scope and over-engineering (1), API (1), Compatibility and deprecation (1), Implementation (2), Style consistency (1), Test quality (2). Other reviewed categories look good.

  • PR description: Correct the claim that controller limits narrow OSC clip ranges, because clipping currently runs afterward, and state that DiffIK position commands expose only position names.
  • Design and architecture: Architecture looks good.
  • Scope and over-engineering: Minimal implementation: keep _resolve_task_space_clip in task_space_actions.py, merge OSC name generation into command-index resolution, and retain the cfg, changelog, and focused tests; no source modules were added. Scope is cohesive; no split recommended.
  • API: Prefixing every OSC block on pose-name collisions produces undocumented stiffness_stiffness_* and damping_ratio_damping_ratio_* names; prefix only colliding pose blocks.
  • Compatibility and deprecation: Breaking changes: previously accepted joint-name clip dictionaries now fail without a functional deprecation bridge; preserve them temporarily with a targeted warning and documented migration.
  • Implementation: OSC clipping runs after controller gain clamps, allowing configured clip minima to exceed controller limits; apply user clipping before the controller limits.
  • Style consistency: The private clip resolver precedes public classes, violating repository file ordering; move it below the public classes.
  • Test quality: Of eight added cases, one DiffIK position row repeats the same path and the OSC unmatched-key case duplicates shared-resolver coverage; remove both.

Significant concerns. Posted 8 inline findings.

Automated review; human maintainers own approval decisions.

min=self.cfg.controller_cfg.motion_damping_ratio_limits_task[0],
max=self.cfg.controller_cfg.motion_damping_ratio_limits_task[1],
)
# Clip the processed actions. The controller limits above still apply, so a user range only narrows them.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Critical · Implementation — Clip can exceed controller gain limits

Clipping runs after the stiffness and damping clamps, so a clip range above the controller limit raises the clamped value past it, contradicting this comment and the cfg docs. Clip before the limits.

self._clip = torch.tensor([[-float("inf"), float("inf")]], device=self.device).repeat(
self.num_envs, self.action_dim, 1
)
index_list, _, value_list = string_utils.resolve_matching_names_values(self.cfg.clip, self._joint_names)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Warning · Compatibility — Clip key namespace changed without transition

Joint-name clip dictionaries that previously resolved here (including .* when joint and action counts matched) now raise at construction. Keep them working with a deprecation warning, or raise an error naming the accepted action names.

_TASK_AXES = ("x", "y", "z", "rx", "ry", "rz")


def _resolve_task_space_clip(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Warning · Style Consistency — Private helper precedes public classes

The guide's file order is public functions, public classes, then private functions. Move _resolve_task_space_clip below the two action classes.

if not isinstance(clip, dict):
raise ValueError(f"Unsupported clip type: {type(clip)}. Supported types are dict.")
index_list, matched_names, value_list = string_utils.resolve_matching_names_values(clip, action_names)
quat_names = [name for name in matched_names if name in _QUATERNION_NAMES]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Warning · Implementation — Quaternion guard misses prefixed names

With both pose targets, names become pose_abs_quat_x, which is not in _QUATERNION_NAMES, so quaternion clipping is silently accepted despite the documented rejection. Match the component suffix or track quaternion indices.

targets), every name is prefixed with the name of its block.
"""
blocks: list[tuple[str, tuple[str, ...]]] = []
for target_type in self.cfg.controller_cfg.target_types:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Warning · Scope Complexity — Duplicate target-type layout switch

_resolve_command_indexes already enumerates each target type's block size; this second switch must stay in sync and silently skips unknown types. Produce the names inside the existing index resolution and delete this method.

blocks.append(("damping_ratio", tuple(f"damping_ratio_{axis}" for axis in _TASK_AXES)))
names = [name for _, block_names in blocks for name in block_names]
if len(set(names)) != len(names):
names = [f"{block}_{name}" for block, block_names in blocks for name in block_names]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Warning · Api — Prefixing breaks documented impedance keys

A pose_abs plus pose_rel collision prefixes every block, yielding stiffness_stiffness_x and damping_ratio_damping_ratio_x, so the stiffness_<axis> keys documented in the cfg no longer match. Prefix only the colliding pose blocks.

("command_type", "use_relative_mode", "expected"),
[
("position", False, ["pos_x", "pos_y", "pos_z"]),
("position", True, ["pos_x", "pos_y", "pos_z"]),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Warning · Test Quality — Duplicate position parametrize row

action_names branches only on command_type == "pose", so the position/True row runs the same path and asserts the same list as position/False. Drop one row.

torch.testing.assert_close(processed[:, :2], raw[:, :2])


def test_osc_clip_unknown_key_raises():

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Warning · Test Quality — Duplicate unmatched-key error test

The no-match ValueError comes from the shared _resolve_task_space_clip, already proven by test_diff_ik_clip_with_joint_names_raises, and OSC clip wiring is proven by the clipping test. Remove this replay.

@Lynn-hh

Lynn-hh commented Oct 19, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the review findings in e49bc4c:

  • Quaternion guard (greptile P1 / review bot): the check matches the component suffix, so pose_abs_quat_x is rejected like quat_x. Regression test test_osc_clip_prefixed_quaternion_raises.
  • Clip vs. controller limits: the OSC clip now runs after the scaling and before the stiffness / damping-ratio limits, so the limits always bound the result (test_osc_controller_limits_bound_clip). The PR description is corrected accordingly.
  • Prefixing: only the colliding blocks are prefixed. With pose_abs + pose_rel the pose components become pose_abs_pos_x / pose_rel_pos_x, while stiffness_<axis> / damping_ratio_<axis> keep their documented names.
  • Single layout switch: the names are produced by _resolve_command_indexes from the same blocks that set the indexes; _resolve_action_names is gone.
  • File order / tests: _resolve_task_space_clip moved below the public classes; the duplicate parametrize row and the duplicate unmatched-key test are removed.
  • Joint-name keys: these never worked for the task-space terms (an IndexError, or joint ranges applied to pose components), so there is no behaviour to keep under a deprecation. The error now lists the action names and says that the clip of a task-space term is matched against them rather than the joint names.

pytest source/isaaclab/test/envs/test_task_space_action_clip.py source/isaaclab/test/envs/test_diffik_jacobian_aliasing.py: 19 passed; pre-commit clean.

@AntoineRichard AntoineRichard self-assigned this Oct 27, 2026

@AntoineRichard AntoineRichard left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Lynn-hh for the PR! Moved the tests, and added a small fix. Thanks again!

@AntoineRichard

Copy link
Copy Markdown
Collaborator

run-ci

@isaaclab-bot isaaclab-bot Bot added ci:run-docker Trigger the on-demand Docker and GPU CI workflow and removed ci:run-docker Trigger the on-demand Docker and GPU CI workflow labels Oct 27, 2026
@Lynn-hh

Lynn-hh commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for consolidating the tests and for the empty-dict guard, @AntoineRichard!

@maxkra15 maxkra15 self-assigned this Oct 28, 2026
@maxkra15
maxkra15 self-requested a review October 28, 2026 12:43
@StafaH StafaH self-assigned this Nov 6, 2026
@hujc7
hujc7 merged commit 0a02a29 into isaac-sim:main Nov 6, 2026
59 checks passed
@Lynn-hh

Lynn-hh commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

Thank you @AntoineRichard for the review and the test consolidation, and @hujc7 for merging!

AntoineRichard pushed a commit that referenced this pull request Nov 16, 2026
# Description

Follow-up to #8715 for the two action terms it didn't cover.
`RMPFlowAction` and `NonHolonomicAction` still resolved
`ActionTermCfg.clip` keys against joint names and then indexed the
action vector with those joint indices:

- `RMPFlowAction` has a task-space action (6-D relative, 7-D absolute
pose). With a 7-joint arm in relative mode, `clip={".*": ...}` raised
`IndexError: index 6 is out of bounds for dimension 0 with size 6`; with
fewer joints, joint ranges were applied to pose components.
- `NonHolonomicAction` has a 2-D action (forward velocity, turning rate)
but matched the keys against its three dummy base joints.

Both terms now expose `action_names` and resolve `clip` against them, as
#8715 did for DiffIK and OSC:

- RMPFlow: `pos_x`, `pos_y`, `pos_z`, then `rot_x`, `rot_y`, `rot_z`
(relative) or `quat_x`, `quat_y`, `quat_z`, `quat_w` (absolute). It
reuses `_resolve_task_space_clip`, so keys that match nothing or a
quaternion component raise.
- Non-holonomic: `lin_vel_x`, `ang_vel_z`. Unmatched keys raise through
the strict name resolver.

No task in the repo sets `clip` on either term.

Fixes #1732 (together with #2019 for raw-action clipping in the RL
wrappers and #8715 for the other task-space terms).

## Type of change

- Bug fix
- Breaking change: `clip` keys that name joints on these two terms now
raise a `ValueError`; use the action names listed above (recorded as
**Breaking** in the changelog, with a major bump)

## Checklist

- [x] I have read and understood the [contribution
guidelines](https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html)
- [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`uv run isaaclab --format`
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have validated the changed behavior with focused coverage and
applied the [test-audit
criteria](https://github.com/isaac-sim/IsaacLab/blob/HEAD/skills/developer/test-audit/SKILL.md)
to any test changes
- [x] I have added a changelog fragment under
`source/<pkg>/changelog.d/` for every touched package (do **not** edit
`CHANGELOG.rst` or bump package versions — CI handles that)
- [x] I have added my name to the `CONTRIBUTORS.md` or my name already
exists there

Testing: the existing DiffIK clip tests are parametrized over RMPFlow:
valid keys clip the processed pose actions, joint-name keys raise, and
quaternion keys raise. On `main` the RMPFlow cases fail (joint-name keys
hit `IndexError: index 6 is out of bounds for dimension 0 with size 6`;
the other keys don't match any joint name). With this change all 20
tests in `source/isaaclab/test/envs/mdp/test_actions.py` pass. The
non-holonomic change has no test coverage here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug Report] Issues with recently added action clipping for task space actions

5 participants