Adding Collision USD data classes and writers - #6254
Conversation
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.
87f3f4e to
f7e42f5
Compare
Greptile SummaryAdds the collision schema-fragment family (
Confidence Score: 5/5Safe 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
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]
%%{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]
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: |
There was a problem hiding this comment.
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.
| 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
# 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
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.CollisionFragmentmarker +UsdPhysicsCollisionCfg(physics:collisionEnabled;UsdPhysics.CollisionAPIanchor) inisaaclab.PhysxCollisionCfg(physxCollision:*—contact_offset,rest_offset,torsional_patch_radius,min_torsional_patch_radius) inisaaclab_physx.NewtonCollisionCfg(newton:*) inisaaclab_newton.apply_collision_propertiesfamily writer (applies the anchor, then dispatches each fragment via itsfunc; core imports no backend).collision_propsslot now also accepts aCollisionFragment/list[CollisionFragment].This PR is purely additive and self-contained: it builds only on the single-namespace schema-fragment base (
SchemaFragment+apply_namespaced) already indevelop, existing call sites are untouched (a transition bridge routes legacy single cfgs to the existingdefine_/modify_writers), and it does not depend on any other open PR.Type of change
Screenshots
N/A — non-visual API change.
Checklist
pre-commitchecks with./isaaclab.sh --formatsource/<pkg>/changelog.d/for every touched package (do not editCHANGELOG.rstor bumpextension.toml— CI handles that)CONTRIBUTORS.mdor my name already exists there