Skip to content

Fix FORGE wrench transforms and PhysX joint-wrench frames - #7967

Merged
ooctipus merged 4 commits into
isaac-sim:developfrom
Lynn-hh:fix/forge-ft-frame-transform
Sep 24, 2026
Merged

ooctipus merged 4 commits into
isaac-sim:developfrom
Lynn-hh:fix/forge-ft-frame-transform

Conversation

@Lynn-hh

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

Copy link
Copy Markdown
Contributor

Description

Fixes #3513 and the PhysX joint-wrench frame discrepancy discussed in #7978.

forge_utils.change_FT_frame used the inverse rotation and the wrong lever-arm sign when expressing a wrench in another frame. It now computes the source pose in the target frame and applies:

  • f_t = R_ts f_s
  • tau_t = R_ts tau_s + p_ts × f_t

The existing independent point-force test covers translated frames with identity and arbitrary rotations. FORGE's current force-only observation remains unchanged because its call uses identity rotations.

The PhysX sensor had a separate error: get_link_incoming_joint_force() already returns forces and torques in the child-side joint frame, about its anchor. The sensor applied localPos1 and localRot1 again. It now exposes the native components directly, removing the redundant USD traversal, frame buffers, and GPU transformations. This follows the PhysX tensor API contract.

Replaced the circular PhysX frame test with one shared integration fixture used by both Newton and PhysX. It uses the same timestep, geometry, loads, expected values, and tolerances: a passive vertical hinge supports a 2 kg body through an offset child frame rotated 90 degrees relative to the body. The articulation is also rotated about world Z. Both backends must report F=(0, 0, 19.62) N and tau=(-1.962, 4.905, 0) N·m, calculated from gravity and the known lever arm. The test checks that the body stays at rest. No raw wrench or production conversion is used to calculate the reference.

The fixture reuses the existing simple articulation asset with temporary USD overrides; no asset is added to the repository. The existing backend test files invoke the shared check. Removed the old circular reference helper.

Validation

  • Newton sensor suite and FORGE tests: 12 passed.
  • PhysX sensor suite: 16 passed, including eager/recorded updates and reset behavior.
  • The shared physical test failed with the original PhysX implementation, with a 19.62 N force-component error, and passed after removing the duplicate transform. Newton passes the same analytic contract.
  • Architecture audit and uv run --no-sync isaaclab -f passed.
  • Recorded GPU update microbenchmark at 1024 environments × 8 links: approximately 3 microseconds per launch before and after. Initialization no longer scans USD joint frames or allocates their buffers.

Type of change

  • Bug fix
  • Documentation update

Checklist

  • I have read and understood the contribution guidelines
  • I have run the pre-commit checks
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective
  • I have added a changelog fragment for every touched package
  • My name already exists in CONTRIBUTORS.md

Follow-up

FORGE names its raw incoming-joint wrench force_sensor_world, although the API reports the child joint frame. Moving FORGE's observation to an explicitly selected frame is separate work because it can change policy inputs. This PR preserves its current force observation.

change_FT_frame applied the rotation of the target pose in the source frame
instead of its transpose, and shifted the torque with the wrong lever-arm
sign. Express the source pose in the target frame and apply the wrench
transform from Modern Robotics eq. 3.95.

The FORGE force observation is unchanged: the environment passes identity
rotations and only consumes the force components.

Fixes isaac-sim#3513

Signed-off-by: Lynn <[email protected]>
@Lynn-hh
Lynn-hh requested a review from a team September 23, 2026 04:04
@github-actions github-actions Bot added bug Something isn't working isaac-lab Related to Isaac Lab team labels Sep 23, 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 wrench transform correction and regression coverage are coherent, but the updated frame-convention documentation retains an incorrect quaternion ordering that should be fixed before merge.

  • Design and architecture: The implementation remains localized to the FORGE helper and preserves its signature and tuple ordering. Computing the source pose in the target frame with subtract_frame_transforms matches the wrench transformation exercised by the point-force reference test.
  • API: The updated docstring labels frame quaternions as quat_xyzw, while subtract_frame_transforms, quat_apply, and the test inputs use Isaac Lab's scalar-first (w, x, y, z) convention. Change both frame tuple descriptions to quat_wxyz to avoid misleading callers.
  • Implementation: The revised force and torque calculations consistently use the source pose expressed in the target frame, and the tests cover both translated identity-axis frames and independently rotated frames. The remaining issue is confined to the documented input contract.

Minor fixes needed. Posted 1 actionable finding inline.

Automated review; human maintainers own approval decisions.

target_frame: Tuple of (quat_xyzw, pos) for target frame.
source_F: Force in source frame [N]. Shape is (N, 3).
source_T: Torque in source frame, about the source frame's origin [N·m]. Shape is (N, 3).
source_frame: Tuple of (quat_xyzw, pos) for source frame, both expressed in a common frame.

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.

🔵 Suggestion · Api — Docstring states wrong quaternion ordering

The rewritten Args block documents the frame tuples as (quat_xyzw, pos), but these quaternions are passed to subtract_frame_transforms and quat_apply, which use Isaac Lab's scalar-first (w, x, y, z) ordering; the new test correspondingly feeds quat_from_matrix output. Since these lines are being rewritten specifically to state the frame conventions, document them as (quat_wxyz, pos) so callers do not silently pass the wrong layout.

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.

I believe (quat_xyzw, pos) is correct on develop. The math utilities use scalar-last ordering: quat_apply documents "The quaternion in (x, y, z, w)" (isaaclab/utils/math.py:640), subtract_frame_transforms/combine_frame_transforms document q01 as "(x, y, z, w)", quat_from_matrix returns "(x, y, z, w)", and the only caller (forge_env.py:109) builds the identity as [0, 0, 0, 1]. The regression test passes these through with random rotations and matches the point-force reference, which would not hold with the wrong ordering. So I have left the docstring as is.

@greptile-apps

greptile-apps Bot commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge; the corrected transformation is mathematically consistent and covered by an independent physical reference test.

Summary

This PR corrects change_FT_frame so forces and torques are re-expressed using the source pose in the target frame.

  • Replaces the inverse wrench transformation with the correct rotation and lever-arm calculation.
  • Documents frame conventions, tensor shapes, and physical units.
  • Adds an independent point-force reference test covering translated frames and arbitrary rotations.
  • Adds a changelog fragment explaining why current FORGE observations remain unchanged.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
    WS["Source wrench<br/>Fₛ, τₛ"] --> RF["Rotate force<br/>Fₜ = Rₜₛ Fₛ"]
    WS --> RT["Rotate torque<br/>Rₜₛ τₛ"]
    PS["Source origin in target frame<br/>pₜₛ"] --> LM["Lever-arm torque<br/>pₜₛ × Fₜ"]
    RF --> LM
    RT --> TT["Target torque<br/>τₜ = Rₜₛ τₛ + pₜₛ × Fₜ"]
    LM --> TT
Loading

Reviews (1) · Last reviewed commit: "Fix wrench transform in FORGE change_FT_..."

@Lynn-hh

Lynn-hh commented Sep 23, 2026

Copy link
Copy Markdown
Contributor Author

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 Sep 23, 2026
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Sep 24, 2026
@ooctipus ooctipus changed the title Fix wrench transform in FORGE change_FT_frame Fix FORGE wrench transforms and PhysX joint-wrench frames Sep 24, 2026
@ooctipus ooctipus self-assigned this Sep 24, 2026
@ooctipus ooctipus added the ci:run-docker Trigger the on-demand Docker and GPU CI workflow label Sep 24, 2026
@ooctipus

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 Sep 24, 2026
@ooctipus ooctipus added the ci:run-docker Trigger the on-demand Docker and GPU CI workflow label Sep 24, 2026
@ooctipus ooctipus removed the ci:run-docker Trigger the on-demand Docker and GPU CI workflow label Sep 24, 2026
@ooctipus ooctipus 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 Sep 24, 2026
@ooctipus
ooctipus enabled auto-merge (squash) September 24, 2026 03:46
@ooctipus
ooctipus disabled auto-merge September 24, 2026 04:18
@ooctipus
ooctipus merged commit 37cfd63 into isaac-sim:develop Sep 24, 2026
53 checks passed
@Lynn-hh

Lynn-hh commented Sep 24, 2026

Copy link
Copy Markdown
Contributor Author

Thank you @ooctipus for picking up the PhysX joint-wrench frame fix in this PR, for the shared physics-based frame test, and for getting it merged so quickly. I really appreciate it!

One follow-up: the OVPhysX joint-wrench sensor (isaaclab_ov/sensors/joint_wrench) applies the same extra transform. I measured it with OVPhysX 0.6.3 on a welded tool with rotated and offset child frames. The raw OVPhysX wrench matched the analytic value in every case, while the sensor output did not (e.g. a 90° rotation about x flipped the reported force to (0, 0, -mg)). I'll open a small PR that mirrors your PhysX change for OVPhysX and reuses check_joint_wrench_frame.

ooctipus added a commit that referenced this pull request Sep 24, 2026
# Description

Follow-up to #7967, which fixed this for PhysX. The OVPhysX joint-wrench
sensor had the same extra frame transform.

OVPhysX reports `LINK_INCOMING_JOINT_FORCE` in the **child-side joint
frame at the joint anchor**, the same convention as PhysX.
`isaaclab_ov/sensors/joint_wrench/kernels.py` treated that reading as
"body1's frame at body1's origin" and shifted/rotated it again by the
child joint pose (`localPos1`/`localRot1`). Readings were therefore
wrong whenever that pose was not identity.

This PR mirrors the PhysX correction in #7967 and makes the physical
contract explicit across all three backends:
- The OVPhysX split kernel passes force and torque through; unused USD
joint-frame buffers are removed.
- The shared `test_joint_wrench_frame` lives in
`source/isaaclab/test/sensors/joint_wrench_contract.py`. Newton, PhysX,
and OVPhysX import it directly into their existing sensor suites and
provide their existing `sim` fixtures, following the FrameView
contract-test pattern.
- The runtime test utility, forwarding test functions, and circular
OVPhysX frame-transform test are removed. The same physical scene and
analytic force/torque expectations remain shared.
- A small structural test checks that every joint-wrench backend imports
the shared tests, rejects backend dependencies in the contract, and
prevents restoration of the old utility.
- OVPhysX uses the existing `device_split` CI marker so CPU and CUDA
cases run in separate processes instead of silently skipping one device.

## Measurement (OVPhysX 0.6.3, before this PR)

The setup is a 0.5 kg tool welded to an arm. The tool's COM is 0.15 m
past the wrist anchor. I authored the child and parent frames of the
weld as below and compared the tool's reading with the analytic wrench.

| Child joint frame | Sensor force | Sensor torque | Analytic (joint
frame, at anchor) | Raw OVPhysX |
|---|---|---|---|---|
| identity | (0, 0, 4.905) | (0, -0.736, 0) | (0, 0, 4.905) / (0,
-0.736, 0) | = analytic |
| 90° about z | (0, 0, 4.905) | (0, **+0.736**, 0) | (0, 0, 4.905) /
(-0.736, 0, 0) | = analytic |
| anchor offset (lever 0.25 m) | (0, 0, 4.905) | (0, **-1.717**, 0) |
(0, 0, 4.905) / (0, -1.226, 0) | = analytic |
| 90° about z + offset | (0, 0, 4.905) | (**-0.491**, **1.226**, 0) |
(0, 0, 4.905) / (-1.226, 0, 0) | = analytic |
| 90° about x | (0, 0, **-4.905**) | (0, **0.736**, 0) | (0, 4.905, 0) /
(0, 0, 0.736) | = analytic |

In every case the raw OVPhysX tensor already matches the analytic
wrench, and only the extra transform makes the sensor output wrong. With
a 90° rotation about x, the reported force even points the wrong way.

## Type of change

- Bug fix (non-breaking change which fixes an issue)
  - Readings change only for joints whose child frame is not identity.
  - The documented `incoming_joint_frame` convention is unchanged.

## Tests

Local validation with OVPhysX 0.6.3, running backends in separate
processes (CUDA on an RTX 5090):

- Newton joint-wrench suite: 14 passed.
- PhysX joint-wrench suite: 16 passed.
- OVPhysX CPU pass (`-k 'cpu or not cuda'`): 12 passed, including the
device-independent pre-init test.
- OVPhysX CUDA pass (`-k cuda`): 11 passed.
- Shared-contract structural gate: 1 passed. Removing the OVPhysX
contract import makes it fail.
- Restoring the original OVPhysX sensor and kernel makes the shared
physical test fail on both CPU and CUDA with a maximum force-component
error of 19.62 N.
- File-by-file architecture audit and `uv run --no-sync isaaclab -f`
passed.

The physical scenario count is unchanged; the existing per-backend frame
tests now collect the same test function. Full PR CI remains pending.

## Checklist

- [x] I have read and understood the contribution guidelines
- [x] I have run the `pre-commit` checks with `./isaaclab.sh --format`
- [x] I have made corresponding changes to the documentation (kernel
docstring)
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] I have added a changelog fragment for every touched package
- [x] I have added my name to the `CONTRIBUTORS.md` or my name already
exists there

cc @ooctipus

---------

Signed-off-by: Lynn <[email protected]>
Co-authored-by: Octi Zhang <[email protected]>
ooctipus added a commit that referenced this pull request Sep 24, 2026
…7996)

## Description

Backports #7967 (`37cfd637f6521dd36865f25918c303f120980acd`) to
`release/3.0.0`, following the merged backport batch #7993.

Corrects the rotation and torque lever-arm sign in FORGE's wrench
transform. Removes the duplicate PhysX joint-frame conversion because
the native wrench already uses the child-side joint frame and anchor.
Includes the shared physical regression fixture, backend tests,
documentation, and changelog fragments.

The source change applies without conflicts. All added and removed lines
match #7967; existing release-specific context in the Newton tests,
sensor documentation, and development guidelines is preserved.

## Validation

- Newton joint-wrench sensor suite and FORGE tests: **12 passed**.
- PhysX joint-wrench sensor suite: **16 passed**, including the shared
analytic frame check, recorded/eager updates, and resets.
- File-by-file backport audit, `uv run --no-sync isaaclab -f`, and `git
diff --check` passed.
- Full Docker/GPU CI requested for this backport.

Co-authored-by: Lynn <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug Report] The function change_ft_frame in the FORGE task seems to be incorrect

2 participants