Skip to content

Apply Newton external wrenches on every solver substep - #8269

Merged
StafaH merged 3 commits into
isaac-sim:developfrom
NeoZng:fix/newton-substep-external-wrench
Oct 8, 2026
Merged

StafaH merged 3 commits into
isaac-sim:developfrom
NeoZng:fix/newton-substep-external-wrench

Conversation

@NeoZng

@NeoZng NeoZng commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Description

On Newton, the external wrenches of Articulation, RigidObject and RigidObjectCollection acted only on the first
solver substep. The assets write state_0.body_f once per step, and NewtonManager._run_solver_substeps clears the
input state's forces after every substep. A constant wrench therefore delivered 1/num_substeps of its impulse, and
1/(decimation x num_substeps) when Newton runs the decimation loop, which is the default for supported explicit
actuators.

NewtonManager now copies state_0.body_f at the start of each step and writes it into the input state of every
solver substep, before the state-force callbacks (viewer picking) add their forces. The copy is allocated in
initialize_solver, so graph capture allocates nothing. The forces are still cleared after each substep, so a write
applies to exactly one step() call. Only body_f is staged; Isaac Lab writes no particle forces.

Draft #8218 re-applies authored forces in its manager rewrite as well; this PR fixes the current manager, so the fix
can also be backported.

Fixes #8268

Type of change

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

Release backport

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

Tests

test_staged_body_force_acts_on_every_solver_substep in
source/isaaclab_newton/test/physics/test_newton_manager_abstraction.py writes a body_f that cancels gravity on a
1 kg free body and checks that its velocity stays zero over one step: MJWarp (single state) with 2 substeps, and Kamino
(double-buffered) with 3 substeps and a folded decimation of 2. On develop qd_z is -0.0245 and -0.0818 m/s.

pytest source/isaaclab_newton/test/physics/test_newton_manager_abstraction.py -k test_staged_body_force_acts_on_every_solver_substep
# before: 2 failed    after: 2 passed

The rest of the file and the external-force tests of the rigid object, rigid object collection and articulation pass.
The repro in the issue prints 0.100 m/s for 1, 2 and 4 substeps. Cost: one body_f copy per step and one per
substep; 4096 envs x 8 bodies, 2 substeps: 0.882 -> 0.886 ms per step (measured without a wrench, so both trees
integrate the same motion).

Checklist

  • I have read and understood the contribution guidelines
  • I have run the pre-commit checks with uv run isaaclab --format
  • 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

The assets write state_0.body_f once per step, but the substep loop
clears the input state's forces after every solver substep, so only the
first substep received the wrench. Copy body_f at the start of each step
and write it into the input state of every substep.
@NeoZng
NeoZng requested a review from a team October 2, 2026 12:40
@github-actions github-actions Bot added bug Something isn't working isaac-lab Related to Isaac Lab team labels Oct 2, 2026
@greptile-apps

greptile-apps Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium risk] Fixes external forces on physics substeps.

The PR appears safe to merge; no actionable issue was identified.

Summary

This PR stages Newton body forces once per step and reapplies them before every solver substep, including substeps within a decimation loop. It adds a regression test for single- and double-buffered solvers and a changelog fragment.

Reviews (1) · Last reviewed commit: "Apply Newton external wrenches on every ..."

@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 force-staging fix is coherent across single-state, double-buffered, decimation, and graph-capture paths, with focused regression coverage. One minor style fix remains: the expanded _run_solver_substeps docstring narrates operations already evident from the loop and nearby documentation.

  • Design and architecture: NewtonManager owns the staging buffer across initialization and teardown, and both solver-state modes reuse the same staging mechanism without introducing backend-specific branches. Staging once outside the decimation loop correctly preserves the authored force for the full step() call.
  • API: No public symbol, configuration field, export, or stub changed. The new staging state and helper methods are private internals, while state-force callbacks retain their ordering and add forces after the staged body force is restored.
  • Compatibility and deprecation: Breaking changes: none identified. The observable change corrects external wrenches to act on every solver substep and folded decimation iteration while retaining one-write-per-step() semantics. The package includes the required fix changelog fragment.
  • Implementation: The staging buffer is allocated before graph capture, copied from state_0.body_f at each stepping boundary, and restored before each solver substep. The existing post-substep clearing and double-buffer copy/swap logic prevent force leakage into later step() calls and preserve the canonical state.
  • Style consistency: The class-state placement, lifecycle cleanup, and helper structure follow adjacent conventions. However, the added _run_solver_substeps docstring paragraph restates the loop sequence—restore staged forces, then invoke callbacks—and duplicates nearby rationale. Remove it or replace it with the non-obvious invariant that callbacks add on top of the staged force.
  • Test quality: The added regression test protects observable physics behavior and covers two distinct paths: MJWarp single-state substeps and Kamino double-buffering with folded decimation. Existing graph-capture and callback-order tests do not cover the multi-substep force-retention regression, so the new cases are warranted and not duplicative.

Minor fixes needed. Posted 1 actionable finding inline.

Automated review; human maintainers own approval decisions.

@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.

This looks like a reasonable fix considering the limitations in newton. Thanks @NeoZng. I'll open an issue in newton as well

@StafaH

StafaH commented Oct 8, 2026

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 8, 2026
@StafaH

StafaH commented Oct 8, 2026

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 8, 2026
@StafaH
StafaH merged commit adeb1f2 into isaac-sim:develop Oct 8, 2026
58 of 59 checks passed
@isaaclab-bot

isaaclab-bot Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Backported to release/3.0.0 as 5608601.

isaaclab-bot Bot pushed a commit that referenced this pull request Oct 8, 2026
# Description

On Newton, the external wrenches of `Articulation`, `RigidObject` and
`RigidObjectCollection` acted only on the first
solver substep. The assets write `state_0.body_f` once per step, and
`NewtonManager._run_solver_substeps` clears the
input state's forces after every substep. A constant wrench therefore
delivered 1/`num_substeps` of its impulse, and
1/(decimation x `num_substeps`) when Newton runs the decimation loop,
which is the default for supported explicit
actuators.

`NewtonManager` now copies `state_0.body_f` at the start of each step
and writes it into the input state of every
solver substep, before the state-force callbacks (viewer picking) add
their forces. The copy is allocated in
`initialize_solver`, so graph capture allocates nothing. The forces are
still cleared after each substep, so a write
applies to exactly one `step()` call. Only `body_f` is staged; Isaac Lab
writes no particle forces.

Draft #8218 re-applies authored forces in its manager rewrite as well;
this PR fixes the current manager, so the fix
can also be backported.

Fixes #8268

## Type of change

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

## Release backport

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

## Tests

`test_staged_body_force_acts_on_every_solver_substep` in

`source/isaaclab_newton/test/physics/test_newton_manager_abstraction.py`
writes a `body_f` that cancels gravity on a
1 kg free body and checks that its velocity stays zero over one step:
MJWarp (single state) with 2 substeps, and Kamino
(double-buffered) with 3 substeps and a folded decimation of 2. On
develop `qd_z` is -0.0245 and -0.0818 m/s.

```
pytest source/isaaclab_newton/test/physics/test_newton_manager_abstraction.py -k test_staged_body_force_acts_on_every_solver_substep
# before: 2 failed    after: 2 passed
```

The rest of the file and the external-force tests of the rigid object,
rigid object collection and articulation pass.
The repro in the issue prints 0.100 m/s for 1, 2 and 4 substeps. Cost:
one `body_f` copy per step and one per
substep; 4096 envs x 8 bodies, 2 substeps: 0.882 -> 0.886 ms per step
(measured without a wrench, so both trees
integrate the same motion).

## 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`
- [ ] 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/develop/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

---------

Co-authored-by: Mustafa H <[email protected]>

(cherry picked from commit adeb1f2)
@NeoZng
NeoZng deleted the fix/newton-substep-external-wrench branch November 3, 2026 09:13
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] Newton: external wrenches act only on the first solver substep

4 participants