Skip to content

Adding Collision USD data classes and writers - #6254

Merged
vidurv-nvidia merged 6 commits into
isaac-sim:developfrom
vidurv-nvidia:vidurv/schema-frag-collision
Jun 26, 2026
Merged

Adding Collision USD data classes and writers#6254
vidurv-nvidia merged 6 commits into
isaac-sim:developfrom
vidurv-nvidia:vidurv/schema-frag-collision

Conversation

@vidurv-nvidia

@vidurv-nvidia vidurv-nvidia commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Description

Adds the collision schema-fragment API: a prim can carry collision properties from multiple USD namespaces (UsdPhysics + PhysX + Newton) at once, and core names no backend.

  • CollisionFragment marker + UsdPhysicsCollisionCfg (physics:collisionEnabled; UsdPhysics.CollisionAPI anchor) in isaaclab.
  • PhysxCollisionCfg (physxCollision:*contact_offset, rest_offset, torsional_patch_radius, min_torsional_patch_radius) in isaaclab_physx.
  • NewtonCollisionCfg (newton:*) in isaaclab_newton.
  • apply_collision_properties family writer (applies the anchor, then dispatches each fragment via its func; core imports no backend).
  • The spawner collision_props slot now also accepts a CollisionFragment / list[CollisionFragment].

This PR is purely additive and self-contained: it builds only on the single-namespace schema-fragment base (SchemaFragment + apply_namespaced) already in develop, existing call sites are untouched (a transition bridge routes legacy single cfgs to the existing define_/modify_ writers), and it does not depend on any other open PR.

Type of change

  • New feature (non-breaking change which adds functionality)

Screenshots

N/A — non-visual API change.

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

Add the additive single-namespace collision fragment family mirroring the
rigid-body pilot: the CollisionFragment marker and UsdPhysicsCollisionCfg
in core, PhysxCollisionCfg in isaaclab_physx, and NewtonCollisionCfg in
isaaclab_newton. Add the apply_collision_properties family writer that
applies UsdPhysics.CollisionAPI as the implicit anchor and dispatches each
fragment via its func.

Widen the collision_props spawner and mesh-converter slots to accept a
fragment list and add a transition bridge at every spawn site so legacy
CollisionPropertiesCfg cfgs keep working. Export the new public names from
the core, sim-level, physx, and newton stubs, add a fragment test file, and
add changelog fragments.
@vidurv-nvidia
vidurv-nvidia force-pushed the vidurv/schema-frag-collision branch from 87f3f4e to f7e42f5 Compare June 24, 2026 21:18
@vidurv-nvidia vidurv-nvidia self-assigned this Jun 25, 2026
@vidurv-nvidia
vidurv-nvidia marked this pull request as ready for review June 25, 2026 05:18
@greptile-apps

greptile-apps Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds the collision schema-fragment family (CollisionFragment, UsdPhysicsCollisionCfg, PhysxCollisionCfg, NewtonCollisionCfg) and the apply_collision_properties writer, mirroring the rigid-body fragment structure from #5976. Spawner and converter collision_props slots are widened to also accept a fragment list, with a transition shim that routes new fragment lists to apply_collision_properties and legacy single cfgs to the existing writers unchanged.

  • New config classes: CollisionFragment marker in core; UsdPhysicsCollisionCfg (physics:collisionEnabled), PhysxCollisionCfg (physxCollision:*), and NewtonCollisionCfg (newton:*) each carry _usd_namespace/_usd_applied_schema metadata consumed by the shared apply_namespaced dispatcher.
  • Writer: apply_collision_properties applies UsdPhysics.CollisionAPI as the implicit anchor then dispatches each fragment; it differs from its rigid-body counterpart in that it omits the prim-validity guard and always returns True (flagged previously).
  • Transition shims: Identical 5-line routing blocks are duplicated in four spawner/converter files; all carry a # remove later note acknowledging the tech debt.

Confidence Score: 5/5

Safe to merge; the change is additive and all existing call sites continue to work through the transition bridge.

The fragment classes, the apply_collision_properties writer, and the transition shims are all strictly additive. Legacy collision_props call sites are untouched in the else-branch of every shim. The only open concern (missing prim-validity guard and always-True return in apply_collision_properties) was raised in a prior review round; no new issues of that kind appear in this diff.

source/isaaclab/isaaclab/sim/schemas/schemas.py — apply_collision_properties still lacks the prim-validity guard present in its rigid-body counterpart (flagged in a prior review).

Important Files Changed

Filename Overview
source/isaaclab/isaaclab/sim/schemas/schemas.py Adds apply_collision_properties; missing prim validity guard and always-True return (previously flagged) relative to the apply_rigid_body_properties mirror function
source/isaaclab/isaaclab/sim/schemas/schemas_cfg.py Adds CollisionFragment marker and UsdPhysicsCollisionCfg; mirrors RigidBodyFragment/UsdPhysicsRigidBodyCfg structure cleanly
source/isaaclab_physx/isaaclab_physx/sim/schemas/schemas_cfg.py Adds PhysxCollisionCfg with correct _usd_namespace/applied_schema metadata for physxCollision namespace; fields align with PhysxCollisionAPI attributes
source/isaaclab_newton/isaaclab_newton/sim/schemas/schemas_cfg.py Adds NewtonCollisionCfg; contact_gap docstring has a contradictory range claim vs. the sentinel -inf value described
source/isaaclab/isaaclab/sim/spawners/from_files/from_files.py Adds transition shim routing fragment lists to apply_collision_properties and legacy cfgs to modify_collision_properties; backward-compatible
source/isaaclab/test/sim/test_collision_fragments.py New test file covering metadata defaults, per-backend namespace writes, multi-namespace composition, and spawner routing

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[collision_props slot] --> B{isinstance list/tuple?}
    B -- yes --> C[coll_frags = collision_props]
    B -- no --> D[coll_frags = wrapped in list]
    C --> E{all SchemaFragment?}
    D --> E
    E -- yes --> F[apply_collision_properties]
    E -- no --> G[legacy define_/modify_collision_properties]
    F --> H[Apply UsdPhysics.CollisionAPI anchor]
    H --> I[For each fragment: call cfg.func]
    I --> J1[apply_namespaced → UsdPhysicsCollisionCfg\nphysics:collisionEnabled]
    I --> J2[apply_namespaced → PhysxCollisionCfg\nphysxCollision:contactOffset etc.\nApply PhysxCollisionAPI]
    I --> J3[apply_namespaced → NewtonCollisionCfg\nnewton:contactMargin etc.\nApply NewtonCollisionAPI]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[collision_props slot] --> B{isinstance list/tuple?}
    B -- yes --> C[coll_frags = collision_props]
    B -- no --> D[coll_frags = wrapped in list]
    C --> E{all SchemaFragment?}
    D --> E
    E -- yes --> F[apply_collision_properties]
    E -- no --> G[legacy define_/modify_collision_properties]
    F --> H[Apply UsdPhysics.CollisionAPI anchor]
    H --> I[For each fragment: call cfg.func]
    I --> J1[apply_namespaced → UsdPhysicsCollisionCfg\nphysics:collisionEnabled]
    I --> J2[apply_namespaced → PhysxCollisionCfg\nphysxCollision:contactOffset etc.\nApply PhysxCollisionAPI]
    I --> J3[apply_namespaced → NewtonCollisionCfg\nnewton:contactMargin etc.\nApply NewtonCollisionAPI]
Loading

Reviews (2): Last reviewed commit: "fix(schemas): type apply_collision_prope..." | Re-trigger Greptile

"""


def apply_collision_properties(prim_path: str, fragments, stage: Usd.Stage | None = None) -> bool:

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 The fragments parameter is untyped, unlike the parallel apply_rigid_body_properties which uses Iterable[schemas_cfg.RigidBodyFragment]. Add the matching type annotation for consistency and to let type checkers catch misuse early.

Suggested change
def apply_collision_properties(prim_path: str, fragments, stage: Usd.Stage | None = None) -> bool:
def apply_collision_properties(
prim_path: str, fragments: Iterable[schemas_cfg.CollisionFragment], stage: Usd.Stage | None = None
) -> bool:

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!

Match apply_rigid_body_properties: annotate fragments as
Iterable[CollisionFragment] for consistency and type-checking.
mesh_converter imported the schemas module (isaaclab.sim.schemas.schemas),
which defines the writer funcs but not SchemaFragment (that lives in
schemas_cfg and is re-exported by the package). The collision/rigid
transition shims referenced schemas.SchemaFragment, raising AttributeError
at convert time. Import the isaaclab.sim.schemas package instead, matching
the shapes/meshes spawners; all symbols used here are package-exported.
# Conflicts:
#	source/isaaclab/isaaclab/sim/__init__.pyi
#	source/isaaclab/isaaclab/sim/schemas/__init__.pyi
#	source/isaaclab/isaaclab/sim/spawners/from_files/from_files.py
@vidurv-nvidia
vidurv-nvidia merged commit dc8e89d into isaac-sim:develop Jun 26, 2026
60 of 61 checks passed
@vidurv-nvidia
vidurv-nvidia deleted the vidurv/schema-frag-collision branch June 26, 2026 05:10
@vidurv-nvidia
vidurv-nvidia restored the vidurv/schema-frag-collision branch June 26, 2026 07:20
matthewtrepte pushed a commit to matthewtrepte/IsaacLab that referenced this pull request Aug 4, 2026
# Description

Adds the **collision** schema-fragment API: a prim can carry collision
properties from multiple USD namespaces (`UsdPhysics` + PhysX + Newton)
at once, and core names no backend.

- `CollisionFragment` marker + `UsdPhysicsCollisionCfg`
(`physics:collisionEnabled`; `UsdPhysics.CollisionAPI` anchor) in
`isaaclab`.
- `PhysxCollisionCfg` (`physxCollision:*` — `contact_offset`,
`rest_offset`, `torsional_patch_radius`, `min_torsional_patch_radius`)
in `isaaclab_physx`.
- `NewtonCollisionCfg` (`newton:*`) in `isaaclab_newton`.
- `apply_collision_properties` family writer (applies the anchor, then
dispatches each fragment via its `func`; core imports no backend).
- The spawner `collision_props` slot now also accepts a
`CollisionFragment` / `list[CollisionFragment]`.

This PR is purely **additive** and self-contained: it builds only on the
single-namespace schema-fragment base (`SchemaFragment` +
`apply_namespaced`) already in `develop`, existing call sites are
untouched (a transition bridge routes legacy single cfgs to the existing
`define_`/`modify_` writers), and it does **not** depend on any other
open PR.

## Type of change

- New feature (non-breaking change which adds functionality)

## Screenshots

N/A — non-visual API change.

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

None yet

Development

Successfully merging this pull request may close these issues.

2 participants