Skip to content

[Core] Refactor and cleanup core subpackage for 3.0 [5D/N] - #7992

Merged
ooctipus merged 3 commits into
isaac-sim:developfrom
StafaH:core-cleanup/05d-backend-routing
Sep 25, 2026
Merged

ooctipus merged 3 commits into
isaac-sim:developfrom
StafaH:core-cleanup/05d-backend-routing

Conversation

@StafaH

@StafaH StafaH commented Sep 24, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Part of the series that splits the core cleanup in #7949 into small, reviewable pieces. Following #7985, event terms and task code should not branch on the physics manager's class name; they should call the asset API and let each backend handle (or reject) what it supports. An audit found the remaining places that branched on the backend name, plus one Newton solver gap. This PR fixes them. It is independent of #7985 / #7990 / #7991.

Changes

  • randomize_joint_parameters chose the friction write path with "newton" in manager_name, treating every other backend (including OVPhysX) as PhysX. It now randomizes dynamic friction whenever the asset data exposes joint_dynamic_friction_coeff (PhysX, OVPhysX; not Newton), and makes one write_joint_friction_coefficient_to_sim_index call on every backend. Newton's writer already applies the viscous part and ignores dynamic friction. Its invalid-operation error also named 'randomize_fixed_tendon_parameters'; it now names the right term.
  • randomize_rigid_body_com sliced the pose to a position on Newton ("newton" in manager_name) because Newton's set_coms_* accepted positions only, unlike the base API, PhysX, and OVPhysX, which take poses. Newton's set_coms_index / set_coms_mask (articulation, rigid object, rigid object collection) now also accept poses (trailing dimension 7 or wp.transformf) and ignore the orientation, since Newton models the center of mass as a position. The event passes poses on every backend.
  • randomize_rigid_body_scale detected articulations with cls.__name__ == "Articulation" over the MRO; it now uses isinstance(asset, BaseArticulation).
  • NIST reset_end_effector_around_asset (isaaclab_tasks contrib) no longer performs a backend-specific Jacobian refresh. Joint writes invalidate articulation data, and subsequent body-pose reads refresh forward kinematics on demand. This also removes the invalid root_physx_view access on OVPhysX.
  • Newton Featherstone inertia changes. SolverFeatherstone derives its inertia data (body_I_m, body_X_com) from the model only in its constructor, and its notify_model_changed ignores ModelFlags.BODY_INERTIAL_PROPERTIES. So set_masses_*, set_coms_*, set_inertias_*, and the mass/CoM/inertia randomization events silently had no effect on Featherstone. The real fix is upstream in Newton. Until then, a manager can declare model changes its solver does not apply (NewtonManager._ignored_model_changes). Featherstone declares BODY_INERTIAL_PROPERTIES, and the manager logs a warning the first time such a change is flushed.
  • Pretrained checkpoints (isaaclab_rl): OVPhysX configs resolve to the PhysX checkpoints through the "physx" substring match. This is intended, since they run the same PhysX engine, so it is only documented.

Not changed: Newton ignores joint_velocity_limit on MJWarp (documented by Newton). A warning was considered, but actuator setup writes velocity limits for every articulation, so it would fire on every MJWarp run.

Tests

  • isaaclab_physx/test/assets/test_articulation.py: the two CUDA cases of test_write_joint_state_data_consistency pass, verifying fresh body state after manual joint writes without a simulation step or explicit Jacobian read.
  • test/envs/test_articulation_ordering_events.py: the Newton joint-parameter randomization test no longer gives the term a physics manager. It fails on develop, where the term reads env.sim. The fake Newton articulation now forwards viscous friction the way Newton's writer does.
  • isaaclab_newton/test/assets/test_articulation.py: test_randomize_rigid_body_com also sets CoMs from full poses (fails on develop with a shape mismatch).
  • isaaclab_newton/test/physics/test_newton_manager_abstraction.py: test_initialize_solver_populates_canonical_state checks that only Featherstone registers BODY_INERTIAL_PROPERTIES as ignored (8 solver variants).
  • Also passing: the full Newton manager abstraction tests (199) and the Newton articulation / rigid object / collection CoM and friction tests.

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

Checklist

  • I have read and understood the contribution guidelines
  • I have run the pre-commit checks with ./isaaclab.sh --format
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • I have added a changelog fragment under source/<pkg>/changelog.d/ for every touched package (do not edit CHANGELOG.rst or bump extension.toml — CI handles that)
  • I have added my name to the CONTRIBUTORS.md or my name already exists there

@StafaH
StafaH requested a review from a team September 24, 2026 02:39
@github-actions github-actions Bot added the isaac-lab Related to Isaac Lab team label Sep 24, 2026
@greptile-apps

greptile-apps Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

The PR appears safe to merge; the remaining concern is a non-blocking coverage gap for the expanded Newton CoM input contract.

Findings

  1. P2 CoM Paths Lack Coverage ▶

Summary

This PR removes physics-manager-name routing from core event terms, extends Newton’s CoM setters to accept pose-shaped inputs, warns when Featherstone cannot apply runtime inertial changes, and makes NIST Jacobian refresh capability-based.

  • Joint friction randomization now delegates backend-specific behavior through the articulation API.
  • Newton articulation and rigid-object APIs discard CoM orientation consistently.
  • Featherstone surfaces ignored runtime inertia updates rather than dropping them silently.
  • The implementation appears behaviorally sound, with a non-blocking test-coverage gap around the expanded CoM API.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  E[Event term] --> A[Asset API]
  A --> P[PhysX / OVPhysX]
  A --> N[Newton]
  P --> PF[Apply static, dynamic, and viscous friction]
  N --> NF[Apply static and viscous friction]
  A --> C[Set CoM pose]
  C --> CP[PhysX / OVPhysX consume pose]
  C --> CN[Newton extracts XYZ and ignores orientation]
  CN --> F{Featherstone solver?}
  F -->|Yes| W[Warn once that runtime inertia changes are not applied]
  F -->|No| U[Notify solver of model change]
Loading

Reviews (1) · Last reviewed commit: "Route backend-specific behavior through ..."

Comment on lines +1575 to +1578
if isinstance(coms, wp.array) and coms.dtype == wp.transformf:
coms = wp.to_torch(coms)
if isinstance(coms, torch.Tensor) and coms.shape[-1] == 7:
return coms[..., :3].contiguous()

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.

P2 CoM Paths Lack Coverage

The new CoM conversion supports Torch pose tensors and wp.transformf arrays across six index and mask methods, but the added regression test covers only a Torch pose passed to Articulation.set_coms_index. The Warp conversion branch and the mask, rigid-object, and rigid-object-collection paths remain untested, so regressions in the newly supported input paths may go unnoticed. Please add focused coverage for wp.transformf and the remaining public setters.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@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 backend-routing refactor consistently moves CoM and friction handling behind asset APIs, but the new Newton CoM conversion helper exposes an input type that its consumers cannot handle.

  • Design and architecture: Backend-specific CoM pose narrowing is appropriately localized at the Newton asset boundary. No architectural issue was identified in the routing change itself.
  • API: The widened Newton set_coms_index and set_coms_mask contracts remain backward compatible. However, com_positions is annotated to accept and return float, despite its documented tensor/array contract and downstream shape validation rejecting scalar inputs; remove float from both annotations.
  • Implementation: The tensor and wp.transformf conversion paths are coherent, and existing position inputs remain unchanged. The required fix is limited to aligning the new helper's type signature with its actual supported inputs.

Minor fixes needed. Posted 1 actionable finding inline.

Automated review; human maintainers own approval decisions.

)


def com_positions(coms: float | torch.Tensor | wp.array) -> float | torch.Tensor | wp.array:

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 — Helper annotation advertises unsupported float input

com_positions is annotated float | torch.Tensor | wp.array for both parameter and return, but every caller declares coms: torch.Tensor | wp.array, and a scalar would fall through both branches and then fail the subsequent assert_shape_and_dtype(..., wp.vec3f, "coms"). The documented contract only covers trailing-dim-3/wp.vec3f and trailing-dim-7/wp.transformf inputs, so drop float from the annotations.

@StafaH

StafaH commented Sep 24, 2026

Copy link
Copy Markdown
Collaborator 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 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 merged commit 8835a34 into isaac-sim:develop Sep 25, 2026
53 checks passed
isaaclab-bot Bot pushed a commit that referenced this pull request Sep 25, 2026
# Description

Part of the series that splits the core cleanup in #7949 into small,
reviewable pieces. Following #7985, event terms and task code should not
branch on the physics manager's class name; they should call the asset
API and let each backend handle (or reject) what it supports. An audit
found the remaining places that branched on the backend name, plus one
Newton solver gap. This PR fixes them. It is independent of #7985 /
#7990 / #7991.

## Changes
- **`randomize_joint_parameters`** chose the friction write path with
`"newton" in manager_name`, treating every other backend (including
OVPhysX) as PhysX. It now randomizes dynamic friction whenever the asset
data exposes `joint_dynamic_friction_coeff` (PhysX, OVPhysX; not
Newton), and makes one `write_joint_friction_coefficient_to_sim_index`
call on every backend. Newton's writer already applies the viscous part
and ignores dynamic friction. Its invalid-operation error also named
`'randomize_fixed_tendon_parameters'`; it now names the right term.
- **`randomize_rigid_body_com`** sliced the pose to a position on Newton
(`"newton" in manager_name`) because Newton's `set_coms_*` accepted
positions only, unlike the base API, PhysX, and OVPhysX, which take
poses. Newton's `set_coms_index` / `set_coms_mask` (articulation, rigid
object, rigid object collection) now also accept poses (trailing
dimension 7 or `wp.transformf`) and ignore the orientation, since Newton
models the center of mass as a position. The event passes poses on every
backend.
- **`randomize_rigid_body_scale`** detected articulations with
`cls.__name__ == "Articulation"` over the MRO; it now uses
`isinstance(asset, BaseArticulation)`.
- **NIST `reset_end_effector_around_asset`** (`isaaclab_tasks` contrib)
no longer performs a backend-specific Jacobian refresh. Joint writes
invalidate articulation data, and subsequent body-pose reads refresh
forward kinematics on demand. This also removes the invalid
`root_physx_view` access on OVPhysX.
- **Newton Featherstone inertia changes.** `SolverFeatherstone` derives
its inertia data (`body_I_m`, `body_X_com`) from the model only in its
constructor, and its `notify_model_changed` ignores
`ModelFlags.BODY_INERTIAL_PROPERTIES`. So `set_masses_*`, `set_coms_*`,
`set_inertias_*`, and the mass/CoM/inertia randomization events silently
had no effect on Featherstone. The real fix is upstream in Newton. Until
then, a manager can declare model changes its solver does not apply
(`NewtonManager._ignored_model_changes`). Featherstone declares
`BODY_INERTIAL_PROPERTIES`, and the manager logs a warning the first
time such a change is flushed.
- **Pretrained checkpoints** (`isaaclab_rl`): OVPhysX configs resolve to
the PhysX checkpoints through the `"physx"` substring match. This is
intended, since they run the same PhysX engine, so it is only
documented.

Not changed: Newton ignores `joint_velocity_limit` on MJWarp (documented
by Newton). A warning was considered, but actuator setup writes velocity
limits for every articulation, so it would fire on every MJWarp run.

## Tests
- `isaaclab_physx/test/assets/test_articulation.py`: the two CUDA cases
of `test_write_joint_state_data_consistency` pass, verifying fresh body
state after manual joint writes without a simulation step or explicit
Jacobian read.
- `test/envs/test_articulation_ordering_events.py`: the Newton
joint-parameter randomization test no longer gives the term a physics
manager. It fails on `develop`, where the term reads `env.sim`. The fake
Newton articulation now forwards viscous friction the way Newton's
writer does.
- `isaaclab_newton/test/assets/test_articulation.py`:
`test_randomize_rigid_body_com` also sets CoMs from full poses (fails on
`develop` with a shape mismatch).
- `isaaclab_newton/test/physics/test_newton_manager_abstraction.py`:
`test_initialize_solver_populates_canonical_state` checks that only
Featherstone registers `BODY_INERTIAL_PROPERTIES` as ignored (8 solver
variants).
- Also passing: the full Newton manager abstraction tests (199) and the
Newton articulation / rigid object / collection CoM and friction tests.

## 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`

## 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
`./isaaclab.sh --format`
- [x] I have made corresponding changes to the documentation
- [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 added a changelog fragment under
`source/<pkg>/changelog.d/` for every touched package (do **not** edit
`CHANGELOG.rst` or bump `extension.toml` — CI handles that)
- [x] I have added my name to the `CONTRIBUTORS.md` or my name already
exists there

---------

Signed-off-by: Octi Zhang <[email protected]>
Co-authored-by: Octi Zhang <[email protected]>

(cherry picked from commit 8835a34)
@isaaclab-bot

isaaclab-bot Bot commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

Backported to release/3.0.0 as 1edeb38.

@ooctipus ooctipus self-assigned this Sep 25, 2026
@ooctipus ooctipus added this to the Isaac Lab 3.0 GA milestone Sep 25, 2026
@ooctipus ooctipus moved this to Done in Isaac Lab Sep 25, 2026
@StafaH
StafaH deleted the core-cleanup/05d-backend-routing branch October 10, 2026 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

isaac-lab Related to Isaac Lab team

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants