Skip to content

Fix body-offset Jacobian in task-space action terms - #7989

Merged
ooctipus merged 3 commits into
isaac-sim:developfrom
Lynn-hh:fix/task-space-body-offset-jacobian
Sep 24, 2026
Merged

ooctipus merged 3 commits into
isaac-sim:developfrom
Lynn-hh:fix/task-space-body-offset-jacobian

Conversation

@Lynn-hh

@Lynn-hh Lynn-hh commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Description

DifferentialInverseKinematicsAction._compute_frame_jacobian and OperationalSpaceControllerAction._compute_ee_jacobian shift the body-origin Jacobian to the body_offset frame. jacobian_b is the body-origin geometric Jacobian expressed in the root frame. The previous correction had two problems:

  1. Translational rows. The correction used -[r]× J_w with r = body_offset.pos in the body frame. The offset point moves with v + w × (R_body_b r), so the lever arm has to be rotated into the root frame first. The two only coincide when the body's orientation in the root frame is identity. For the Franka IK tasks (pos=(0, 0, 0.107), hand pointing down), the lever arm's sign is effectively flipped.
  2. Angular rows. They were multiplied by R(body_offset.rot). The offset frame is rigidly attached to the body, so its angular velocity in the root frame equals the body's, and the angular rows must stay unchanged.

The same terms already compute the offset frame's pose correctly (combine_frame_transforms(link_pose_b, offset)). The OSC term also computes its velocity correctly (v + w × quat_apply(link_quat_b, offset_pos), with a comment that angular velocity is unaffected). So the Jacobian was inconsistent with both.

Both action terms apply the correction inline. They compute the body orientation in the root frame directly from the asset data, so the result does not depend on whether _compute_ee_pose ran earlier in the step: the OSC apply_actions computes the Jacobian before the pose.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Tests

  • Extended source/isaaclab/test/envs/test_diffik_jacobian_aliasing.py with the body-offset regression (kit-free unit, parametrized over DiffIK and OSC), reusing its existing stub.
    • Setup: one revolute joint about z, with the body rotated 90° about z.
    • With offset (1, 0, 0), the expected linear column is z × (0, 1, 0) = (-1, 0, 0). With a 90° offset rotation about x, the angular column must stay (0, 0, 1).
  • Updated test_diffik_jacobian_aliasing.py::test_compute_frame_jacobian_applies_offset_once.
    • Its out-of-place reference encoded the previous formula. It now uses non-trivial root and body orientations and the rigid-offset formula.
    • The idempotence and owned-buffer tests are unchanged and still pass.
pytest -q source/isaaclab/test/envs/test_diffik_jacobian_aliasing.py
# without the fix: 3 failed, 2 passed
# with the fix:    5 passed

Finite-difference check (script not included in the PR):

  • Setup: random 7-joint serial chain in float64, offset (0, 0, 0.107), 0.7 rad offset rotation.
  • Comparison: the Jacobian of the offset frame against finite differences of its pose.
max linear error max angular error
previous formula 7.9e-2 6.1e-1
this PR 4.7e-7 2.4e-7

Notes for reviewers

  • Changed behavior for existing tasks. Tasks that set body_offset (e.g. the Franka lift/stack/cabinet IK tasks) will now use the correct Jacobian. DiffIK is closed-loop, so the previous error mostly degraded convergence rather than causing outright failures. For OSC with inertial decoupling, the mismatch between J and the (correct) EE velocity is removed.
  • Scope. I kept the change local to the two action terms. It should not overlap with the controller consolidation in [Newton] Consolidate differential IK, joint impedance, and OSC controllers #7854, which does not touch these methods.

Checklist

  • I have read and understood the contribution guidelines
  • I have run the pre-commit checks with ./isaaclab.sh --format
  • I have added tests that prove my fix is effective or that my feature works
  • I have added a changelog fragment under source/isaaclab/changelog.d/
  • I have added my name to the CONTRIBUTORS.md or my name already exists there

The DiffIK and OSC action terms shift the body-origin Jacobian to the
body_offset frame. The Jacobian is expressed in the root frame, but the
correction used the offset in the body frame and also rotated the angular
rows by the offset rotation. The offset frame is rigidly attached to the
body: its linear velocity is v + w x (R_body_b r) and its angular
velocity equals the body's. Rotate the offset into the root frame and
leave the angular rows unchanged, matching the pose and the OSC velocity
that the terms already compute.

Signed-off-by: Lynn <[email protected]>
@Lynn-hh
Lynn-hh requested a review from a team September 24, 2026 02:22
@github-actions github-actions Bot added bug Something isn't working isaac-lab Related to Isaac Lab team labels Sep 24, 2026

@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

The shared body-offset Jacobian correction is consistent with the surrounding pose and velocity paths, but the helper documentation and new regression test use the wrong quaternion component order. Isaac Lab expects (w, x, y, z), while these additions encode or describe (x, y, z, w).

  • Design and architecture: Centralizing the offset shift in a private helper removes duplicated formulas and avoids relying on the end-effector pose computation order. The helper appropriately rotates the lever arm into the root frame while preserving angular Jacobian rows.
  • API: Existing action-term signatures and return behavior remain unchanged. However, the helper docstring incorrectly documents root_quat_w and body_quat_w as (x, y, z, w) even though the articulation data and math utilities use (w, x, y, z); this should be corrected to prevent misuse.
  • Implementation: The production correction operates on the owned Jacobian buffer and is consistent with the offset velocity calculation. The new test's hand-written root, body, and offset quaternion literals use xyzw ordering, so under Isaac Lab's wxyz convention the stated setup and expected Jacobian do not match. Rewrite the literals in wxyz order.

Minor fixes needed. Posted 2 actionable findings inline.

Automated review; human maintainers own approval decisions.


Args:
jacobian_b: Geometric Jacobian of the body origin in the root frame, rows ``[v; w]``. Shape is (N, 6, num_dofs).
root_quat_w: Root orientation in the world frame (x, y, z, w). Shape is (N, 4).

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 — Docstring states wrong quaternion component order

root_quat_w and body_quat_w are documented as (x, y, z, w), but the values come from ArticulationData.root_quat_w/body_quat_w and are consumed by math_utils.quat_inv/quat_mul/quat_apply, all of which use Isaac Lab's (w, x, y, z) layout (same as the OffsetCfg.rot default (1, 0, 0, 0)). Document (w, x, y, z) so future callers of this shared helper are not misled.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

On develop the math utilities and data use scalar-last (x, y, z, w):

  • quat_mul / quat_apply / quat_inv document "(x, y, z, w)" (isaaclab/utils/math.py).
  • DifferentialInverseKinematicsActionCfg.OffsetCfg.rot and OperationalSpaceControllerActionCfg.OffsetCfg.rot default to (0.0, 0.0, 0.0, 1.0) and are documented as (x, y, z, w) (actions_cfg.py).

The test values are therefore identity and a 90° rotation about z. The test fails on the previous formula and passes with this change, which would not happen with the other ordering. Leaving these as they are.

The body-origin Jacobian is ``v = 0`` and ``w = z``. A point ``r`` fixed on the body moves with
``w x (R_body_b @ r)`` and turns with the body's angular velocity.
"""
body_quat_w = torch.tensor([[[0.0, 0.0, math.sin(math.pi / 4.0), math.cos(math.pi / 4.0)]]])

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 — Test stub quaternions use xyzw layout

root_quat_w=[0,0,0,1] and body_quat_w=[0,0,sin45,cos45] are identity and a 90 deg z-rotation only in xyzw. Read as wxyz, body_quat_b becomes 90 deg about x, offset_pos_b stays (1,0,0), and the linear column is z x (1,0,0) = (0,1,0), so the assertion against (-1,0,0) does not hold. Rewrite both literals (and offset_rot) w-first.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

On develop the math utilities and data use scalar-last (x, y, z, w):

  • quat_mul / quat_apply / quat_inv document "(x, y, z, w)" (isaaclab/utils/math.py).
  • DifferentialInverseKinematicsActionCfg.OffsetCfg.rot and OperationalSpaceControllerActionCfg.OffsetCfg.rot default to (0.0, 0.0, 0.0, 1.0) and are documented as (x, y, z, w) (actions_cfg.py).

The test values are therefore identity and a 90° rotation about z. The test fails on the previous formula and passes with this change, which would not happen with the other ordering. Leaving these as they are.

@greptile-apps

greptile-apps Bot commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge; the implementation is consistent with the existing pose and velocity frame conventions and is covered by focused regression tests.

Summary

This PR corrects body-offset Jacobians for differential inverse kinematics and operational-space control.

  • Rotates the body-fixed lever arm into the articulation root frame before shifting the Jacobian’s translational rows.
  • Preserves angular rows because a rigidly attached offset frame has the same angular velocity as its parent body.
  • Shares the correction between both task-space action terms and adds unit coverage for nontrivial body/root orientations, offset-frame rotation, both controller paths, and aliasing behavior.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
    O[Offset position in body frame] --> R[Rotate by R_rootᵀ R_body]
    R --> L[Lever arm in root frame]
    J[Body-origin Jacobian in root frame] --> S[Jv_offset = Jv - lever-arm cross matrix times Jw]
    L --> S
    J --> A[Jw remains unchanged]
    S --> E[Offset-frame geometric Jacobian]
    A --> E
Loading

Reviews (1) · Last reviewed commit: "Fix body-offset Jacobian in task-space a..."

@ooctipus ooctipus added the ci:run-docker Trigger the on-demand Docker and GPU CI workflow label Sep 24, 2026
@ooctipus ooctipus self-assigned this Sep 24, 2026
@ooctipus ooctipus added this to the Isaac Lab 3.0 GA milestone Sep 24, 2026
@ooctipus ooctipus moved this to Ready to merge in Isaac Lab Sep 24, 2026
@ooctipus
ooctipus merged commit 2f1983c into isaac-sim:develop Sep 24, 2026
53 checks passed
@github-project-automation github-project-automation Bot moved this from Ready to merge to Done in Isaac Lab Sep 24, 2026
ooctipus added a commit that referenced this pull request Sep 25, 2026
…ts (#8018)

## Description

Completes the missing `develop` backports to `release/3.0.0` from the
48-hour audit window ending September 25, 2026 at 05:55 UTC. Of 30
merged source PRs, 25 were already present on release, three had no
backport, and two had inferred draft backports.

- #7978: report Newton reaction wrenches for fixed connections while
preserving articulation control-joint ownership.
- #7997: correct OVPhysX joint-wrench frames and move the shared
analytic sensor contract into the test tree.
- #7989: correct body-offset Jacobians in task-space actions without
mutating backend buffers.
- #8010 and #8009: backport the OVPhysX and PhysX test audits after
their wrench prerequisite.

All five source patches apply without conflicts in this order. This
supersedes the now-closed inferred draft backports #8016 and #8017,
which were generated without #7997 and adapted their sensor tests around
the old release implementation. Source commit hashes are recorded in the
commit message.

## Validation

- Audited all 778 paths touched by the 30 source PRs. Remaining
differences in those paths are existing release metadata, cloning
documentation, a CLI test version example, and release-only renderer
tests.
- **55 focused checks passed:** 6 Jacobian/shared-contract unit tests,
14 Newton sensor tests, 9 OVPhysX sensor tests across CPU/GPU, 9 PhysX
sensor tests, 14 changed shared-ordering cases, and 3 live PhysX OSC
tracking/gravity cases. Seven PhysX ordering variants skipped in the
direct invocation; the live PhysX checks ran separately with Kit.
- Backend validation used Newton 1.6.0, Warp 1.17.0, OVPhysX 0.6.3, and
the pinned Isaac Sim 6.1.0 installation. Package imports were verified
to resolve to this backport checkout.
- `uv run --no-sync isaaclab -f`, `git diff --check`, and the full `make
-C docs current-docs` build with warnings as errors passed.
- Additional renderer contract coverage: 53 passed; two live-render
cases could not initialize the local native CRenderApi library despite
installing the pinned `ov` extra. Full Docker/GPU CI is running on the
PR head.
- The broader shared ordering file has 14 OVPhysX failures on both this
branch and unchanged release, with identical failing node IDs and no
added failures. The changed cases listed above passed.

## Controller coverage review

The live PhysX OSC tests remain in
`source/isaaclab/test/controllers/test_operational_space.py`; its
fixture uses `SimulationCfg`'s default `PhysxCfg`, and the file is
included in CI. The existing absolute-pose tracking,
gravity-compensation, and nullspace-centering cases passed against Isaac
Sim 6.1.0. The test audit removes the duplicate asset-suite cases while
retaining this controller-suite coverage.

## Existing release CI failures

The latest [release
run](https://github.com/isaac-sim/IsaacLab/actions/runs/36097576980) and
[develop
run](https://github.com/isaac-sim/IsaacLab/actions/runs/36099567240)
fail the same five OvStage image comparisons in
`rendering-correctness-kitless (ovstage)` and `ovrtx-cache-warm`:
Cartpole on Newton and OVPhysX, plus Newton Franka cable, cloth, and
soft. Cartpole is 2.03–2.04% different against a 1.50% threshold on both
branches; cloth is 32.48% on both. These shared rendering failures
predate this catch-up; this PR does not change rendering output or image
thresholds.

## Checklist

- [x] Contribution guidance followed and formatting checks passed
- [x] Original package changelog fragments and documentation included
- [x] File-by-file backport audit completed
- [x] Warning-free documentation build completed
- [ ] Full CI completed

Targets `release/3.0.0`; no further backport is needed.
ooctipus added a commit that referenced this pull request Oct 6, 2026
# Description

A task-space action with `body_offset` needs a Jacobian at the offset
point. The core DiffIK and OSC actions received the corrected frame
convention in #7989, but the Newton model-free action retained its own
formula: it used a body-local lever arm against a root-frame Jacobian
and rotated the angular rows by the offset orientation. With a rotated
body or root, `J @ qdot` therefore disagreed with the offset-frame
twist.

This PR fixes the Newton action by rotating the offset into world axes,
applying `Jv_point = Jv_origin + Jw × r`, and then rotating the Jacobian
into root axes. The angular rows stay unchanged. Core DiffIK and OSC now
use the same direct `torch.linalg.cross` operation in root axes instead
of constructing a skew matrix and multiplying it by the angular
Jacobian. The two forms are mathematically equivalent; the direct cross
product avoids an extra matrix allocation and multiplication. No new
math wrapper is needed.

The Newton task-space actions use Newton's model-free controllers, which
require a caller-supplied tool-point pose and Jacobian. Newton's
separate model-based controllers and IK objectives support
tool-site/link offsets, but are not the controller API used here. The
Newton action continues to accept both Newton and PhysX asset data
through the public link-origin Jacobian contract.

On the official Franka validation from the original fix (rotated fixed
root and a hand offset), `J @ qdot` matched the simulator's offset-frame
twist: Newton linear error fell from about 0.27 m/s to 2e-6 m/s and
angular error from about 0.95 rad/s to 1e-7 rad/s. PhysX errors were
1e-4 to 4e-4, matching the core term's floor. Only configurations with
`body_offset` are affected; no shipped task currently uses these Newton
action terms.

Fixes #8202

## Type of change

- Bug fix and task-space offset performance improvement

## Release backport

- [x] Backport this pull request to the active release branch after it
merges into `develop`

## Validation

- `uv run --frozen --extra test python -m pytest
source/isaaclab/test/envs/test_diffik_jacobian_aliasing.py -q` — 5
passed.
- `uv run --frozen --extra test python -m pytest
source/isaaclab_newton/test/controllers/test_newton_controllers.py -q` —
8 passed; the existing DiffIK case now checks the offset Jacobian.
- `uv run --frozen isaaclab -f` — passed with the local changelog base
set to this PR's upstream base commit.
- 4,096-env, 7-joint Torch GPU microbenchmarks on RTX 5090 (median of 8
paired rounds of 100 calls): Newton world-frame point shift, direct
cross 149.6 us/call versus skew matrix 213.5 us/call; core root-frame
point shift, direct cross 107.0 us/call versus skew matrix 181.0
us/call. These measure Jacobian computation, not a full simulation step.

## Checklist

- [x] I have read and understood the contribution guidelines.
- [x] I have run the pre-commit checks.
- [x] I have added changelog fragments for both touched packages.
- [x] The focused regression tests pass.
- [ ] I have made corresponding changes to the documentation.

---------

Co-authored-by: Octi Zhang <[email protected]>
AntoineRichard pushed a commit to kellyguo11/IsaacLab-public that referenced this pull request Oct 6, 2026
…c-sim#8203)

# Description

A task-space action with `body_offset` needs a Jacobian at the offset
point. The core DiffIK and OSC actions received the corrected frame
convention in isaac-sim#7989, but the Newton model-free action retained its own
formula: it used a body-local lever arm against a root-frame Jacobian
and rotated the angular rows by the offset orientation. With a rotated
body or root, `J @ qdot` therefore disagreed with the offset-frame
twist.

This PR fixes the Newton action by rotating the offset into world axes,
applying `Jv_point = Jv_origin + Jw × r`, and then rotating the Jacobian
into root axes. The angular rows stay unchanged. Core DiffIK and OSC now
use the same direct `torch.linalg.cross` operation in root axes instead
of constructing a skew matrix and multiplying it by the angular
Jacobian. The two forms are mathematically equivalent; the direct cross
product avoids an extra matrix allocation and multiplication. No new
math wrapper is needed.

The Newton task-space actions use Newton's model-free controllers, which
require a caller-supplied tool-point pose and Jacobian. Newton's
separate model-based controllers and IK objectives support
tool-site/link offsets, but are not the controller API used here. The
Newton action continues to accept both Newton and PhysX asset data
through the public link-origin Jacobian contract.

On the official Franka validation from the original fix (rotated fixed
root and a hand offset), `J @ qdot` matched the simulator's offset-frame
twist: Newton linear error fell from about 0.27 m/s to 2e-6 m/s and
angular error from about 0.95 rad/s to 1e-7 rad/s. PhysX errors were
1e-4 to 4e-4, matching the core term's floor. Only configurations with
`body_offset` are affected; no shipped task currently uses these Newton
action terms.

Fixes isaac-sim#8202

## Type of change

- Bug fix and task-space offset performance improvement

## Release backport

- [x] Backport this pull request to the active release branch after it
merges into `develop`

## Validation

- `uv run --frozen --extra test python -m pytest
source/isaaclab/test/envs/test_diffik_jacobian_aliasing.py -q` — 5
passed.
- `uv run --frozen --extra test python -m pytest
source/isaaclab_newton/test/controllers/test_newton_controllers.py -q` —
8 passed; the existing DiffIK case now checks the offset Jacobian.
- `uv run --frozen isaaclab -f` — passed with the local changelog base
set to this PR's upstream base commit.
- 4,096-env, 7-joint Torch GPU microbenchmarks on RTX 5090 (median of 8
paired rounds of 100 calls): Newton world-frame point shift, direct
cross 149.6 us/call versus skew matrix 213.5 us/call; core root-frame
point shift, direct cross 107.0 us/call versus skew matrix 181.0
us/call. These measure Jacobian computation, not a full simulation step.

## Checklist

- [x] I have read and understood the contribution guidelines.
- [x] I have run the pre-commit checks.
- [x] I have added changelog fragments for both touched packages.
- [x] The focused regression tests pass.
- [ ] I have made corresponding changes to the documentation.

---------

Co-authored-by: Octi Zhang <[email protected]>
(cherry picked from commit e67c5cb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ci:run-docker Trigger the on-demand Docker and GPU CI workflow isaac-lab Related to Isaac Lab team

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants