Repository navigation
Enable OVPhysX shape-material test via OvPhysxView - #6239
AntoineRichard merged 1 commit into
Conversation
442c8fe to
13c58a1
Compare
Greptile SummaryThis PR introduces
Confidence Score: 4/5Safe to merge; all three findings are in annotation accuracy or the mock's fidelity to the real interface, not in the simulation data path. The
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["Articulation._initialize_impl()"] --> B["OvPhysxView(physx, pattern, device)"]
B --> C["try_binding_for(tt) for tt in eager_types"]
C --> D["_binding(tt) → physx.create_tensor_binding(...)"]
D -->|"count == 0"| E["AttributeUnavailable → skip / None"]
D -->|"count > 0"| F["Cache binding in _bindings[tt]"]
F --> G["Metadata: count, dof_count, body_count…"]
G --> H["ArticulationData(view, device)"]
subgraph "Step: write path"
I["set_attribute(tt, values, indices, mask)"]
I --> J{"read-only?"}
J -->|yes| K["ReadOnlyAttribute raised"]
J -->|no| L["_binding(tt) → cached or created"]
L --> M{"device match?"}
M -->|no| N["DeviceMismatch raised"]
M -->|yes| O["_as_binding_view(values) → float32 reinterpret"]
O --> P["binding.write(view, indices, mask)"]
end
subgraph "Step: read path"
Q["read_into(tt, dst)"]
Q --> R["_binding(tt)"]
R --> S["_read_view(dst, binding) — cache by id(dst)"]
S --> T["binding.read(float32_reinterpret)"]
end
H --> I
H --> Q
%%{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["Articulation._initialize_impl()"] --> B["OvPhysxView(physx, pattern, device)"]
B --> C["try_binding_for(tt) for tt in eager_types"]
C --> D["_binding(tt) → physx.create_tensor_binding(...)"]
D -->|"count == 0"| E["AttributeUnavailable → skip / None"]
D -->|"count > 0"| F["Cache binding in _bindings[tt]"]
F --> G["Metadata: count, dof_count, body_count…"]
G --> H["ArticulationData(view, device)"]
subgraph "Step: write path"
I["set_attribute(tt, values, indices, mask)"]
I --> J{"read-only?"}
J -->|yes| K["ReadOnlyAttribute raised"]
J -->|no| L["_binding(tt) → cached or created"]
L --> M{"device match?"}
M -->|no| N["DeviceMismatch raised"]
M -->|yes| O["_as_binding_view(values) → float32 reinterpret"]
O --> P["binding.write(view, indices, mask)"]
end
subgraph "Step: read path"
Q["read_into(tt, dst)"]
Q --> R["_binding(tt)"]
R --> S["_read_view(dst, binding) — cache by id(dst)"]
S --> T["binding.read(float32_reinterpret)"]
end
H --> I
H --> Q
|
The ovphysx wheel now exposes per-shape material as the ARTICULATION_SHAPE_FRICTION_AND_RESTITUTION / RIGID_BODY_SHAPE_FRICTION_AND_RESTITUTION tensor types, closing the gap that kept test_set_material_properties xfailed. - Add tensor_types aliases SHAPE_FRICTION_AND_RESTITUTION and RIGID_BODY_SHAPE_FRICTION_AND_RESTITUTION (guarded for older wheels). - Rewrite test_set_material_properties to read/write the material through OvPhysxView.get_attribute / set_attribute on the new tensor type instead of the PhysX-only root_view.get/set_material_properties / max_shapes API; derive the per-articulation shape count from the binding shape [N, S, 3] and skip on wheels that lack the type. Drop the now-unused gap reason. The binding is device-resident; verified the set -> step -> read round-trip on both cpu and cuda:0.
13c58a1 to
e86997f
Compare
…6241) > **Stacked on #6227** (OVPhysX `RigidObjectCollection` → `OvPhysxView`), which is stacked on #6224 (`OvPhysxView`). Review/merge those first. Sibling of #6239 (articulation) and #6240 (rigid object). ## What The ovphysx wheel now exposes per-collision-shape rigid-body material as the `RIGID_BODY_SHAPE_FRICTION_AND_RESTITUTION` tensor type. This closes the gap that kept the collection's `test_set_material_properties` `xfail`ed (it was an empty `NotImplementedError` stub written against the PhysX-only `root_view.get/set_material_properties()` API). - Add the `tensor_types` alias `RIGID_BODY_SHAPE_FRICTION_AND_RESTITUTION`, guarded with `try/except AttributeError` (shared with the sibling material PRs; documented there). - Implement `test_set_material_properties`, mirroring the PhysX backend but reading/writing the material through `OvPhysxView.get_attribute` / `set_attribute`. The collection's fused binding is body-major flat, so data `[num_envs, num_cubes, 3]` is mapped to/from the view layout with `reshape_data_to_view_3d` and its inverse. ## Verification OVPhysX runs the PhysX solver. The material round-trip passes on both `cpu` and `cuda:0` for `num_envs` 1/3 × `num_cubes` 1/2. The changelog fragment is a `.skip` because the only user-facing addition (the alias) is documented by the sibling material PRs; this PR is test enablement.
> **Stacked on #6226** (OVPhysX `RigidObject` → `OvPhysxView`), which is stacked on #6224 (`OvPhysxView`). Review/merge those first — the diff here collapses to a single commit once they land. Sibling of #6239 (the articulation equivalent). ## What The ovphysx wheel now exposes per-collision-shape rigid-body material as the `RIGID_BODY_SHAPE_FRICTION_AND_RESTITUTION` tensor type (shape `[N, S, 3]` = static friction, dynamic friction, restitution). This closes the gap that kept **five** rigid-object material tests `xfail`ed — they were empty `NotImplementedError` stubs written against the PhysX-only `root_view.get/set_material_properties()` / `max_shapes` view API. - Add the `tensor_types` alias `RIGID_BODY_SHAPE_FRICTION_AND_RESTITUTION`, guarded with `try/except AttributeError` so the module stays import-safe against older wheels. - Implement, mirroring the PhysX backend but reading/writing the material through `OvPhysxView.get_attribute` / `set_attribute`: - `test_rigid_body_set_material_properties` and `test_set_material_properties_via_view` — set/get round-trip. - `test_rigid_body_no_friction`, `test_rigid_body_with_static_friction`, `test_rigid_body_with_restitution` — physical-behavior tests. - Ground planes use the solver-common `RigidBodyMaterialBaseCfg`; masses come from `data.body_mass`. The no-friction test settles the cube and uses zero restitution so the resting contact is clean before asserting the sliding velocity is preserved. ## Verification OVPhysX runs the PhysX solver, so the physical tests use the PhysX reference tolerances. All five pass on both `cpu` and `cuda:0` for `num_cubes` 1 and 2. Full `test_rigid_object.py` is green (53 passed on cpu, no regressions).
> **Stacked on #6239 (articulation material) and #6240 (rigid-object material)** — this branch merges both so the MDP term has `Articulation.root_view` + `RigidObject.root_view` (the #6225/#6226 migrations) and the material aliases. Review/merge those (and their bases #6224/#6225/#6226) first; the diff here collapses to a single commit once they land. (#6241/collection is **not** needed — this MDP term targets `RigidObject`/`Articulation`, not collections.) ## What `randomize_rigid_body_material` previously **no-op'd on the OVPhysX backend** (the wheel lacked a material binding). The wheel now exposes per-shape material as `*_SHAPE_FRICTION_AND_RESTITUTION`, so this replaces the no-op with a real implementation. OVPhysX runs the PhysX solver, so the new `_RandomizeRigidBodyMaterialOvPhysx`: - mirrors the **PhysX bucket approach** (PhysX's 64000 unique-material limit applies): pre-samples `num_buckets` materials and randomly assigns them to shapes; - writes per-shape `(static_friction, dynamic_friction, restitution)` through the asset's `OvPhysxView` (`set_attribute` on `SHAPE_FRICTION_AND_RESTITUTION` for articulations, `RIGID_BODY_SHAPE_FRICTION_AND_RESTITUTION` for rigid objects), read-modify-writing the full `[N, S, 3]` buffer so non-selected envs are preserved. ### Limitation Randomizes **all shapes** only. Per-body selection (`asset_cfg.body_ids`) raises `NotImplementedError` — the ovphysx wheel exposes no per-body shape counts (unlike PhysX's `link_physx_view.max_shapes` / Newton's `num_shapes_per_body`), so body→shape ranges can't be indexed. ## Verification New real-backend test (`test_randomize_rigid_body_material_mdp.py`) drives the implementation against an OVPhysX `RigidObject`: it asserts the written friction/restitution land within the sampled ranges, and that a per-body selection fails loud. Passes on both `cpu` and `cuda:0`. The PhysX and Newton paths are untouched.
> **Stacked on isaac-sim#6225** (OVPhysX `Articulation` → `OvPhysxView`), which is stacked on isaac-sim#6224 (`OvPhysxView`). Review/merge those first — the diff here collapses to a single commit once they land. ## What The ovphysx wheel now exposes per-collision-shape material as the `ARTICULATION_SHAPE_FRICTION_AND_RESTITUTION` / `RIGID_BODY_SHAPE_FRICTION_AND_RESTITUTION` tensor types. This closes the gap that kept `test_set_material_properties` `xfail`ed: the test had been written against the PhysX-only `root_view.get_material_properties()` / `set_material_properties()` / `max_shapes` view API, which `OvPhysxView` does not provide. - Add `tensor_types` aliases `SHAPE_FRICTION_AND_RESTITUTION` and `RIGID_BODY_SHAPE_FRICTION_AND_RESTITUTION`, guarded with `try/except AttributeError` so the module stays import-safe against older wheels. - Rewrite `test_set_material_properties` to read/write the material through `OvPhysxView.get_attribute` / `set_attribute` on the new tensor type. The per-articulation shape count is derived from the binding shape `[N, S, 3]` (`[static_friction, dynamic_friction, restitution]`); the test skips on wheels that lack the type. The now-unused `_MATERIAL_GAP_REASON` is removed. ## Verification The material binding is device-resident (it follows the simulation device). The `set → step → read` round-trip passes on both `cpu` and `cuda:0` for `num_articulations` 1 and 2.
…saac-sim#6241) > **Stacked on isaac-sim#6227** (OVPhysX `RigidObjectCollection` → `OvPhysxView`), which is stacked on isaac-sim#6224 (`OvPhysxView`). Review/merge those first. Sibling of isaac-sim#6239 (articulation) and isaac-sim#6240 (rigid object). ## What The ovphysx wheel now exposes per-collision-shape rigid-body material as the `RIGID_BODY_SHAPE_FRICTION_AND_RESTITUTION` tensor type. This closes the gap that kept the collection's `test_set_material_properties` `xfail`ed (it was an empty `NotImplementedError` stub written against the PhysX-only `root_view.get/set_material_properties()` API). - Add the `tensor_types` alias `RIGID_BODY_SHAPE_FRICTION_AND_RESTITUTION`, guarded with `try/except AttributeError` (shared with the sibling material PRs; documented there). - Implement `test_set_material_properties`, mirroring the PhysX backend but reading/writing the material through `OvPhysxView.get_attribute` / `set_attribute`. The collection's fused binding is body-major flat, so data `[num_envs, num_cubes, 3]` is mapped to/from the view layout with `reshape_data_to_view_3d` and its inverse. ## Verification OVPhysX runs the PhysX solver. The material round-trip passes on both `cpu` and `cuda:0` for `num_envs` 1/3 × `num_cubes` 1/2. The changelog fragment is a `.skip` because the only user-facing addition (the alias) is documented by the sibling material PRs; this PR is test enablement.
…ac-sim#6240) > **Stacked on isaac-sim#6226** (OVPhysX `RigidObject` → `OvPhysxView`), which is stacked on isaac-sim#6224 (`OvPhysxView`). Review/merge those first — the diff here collapses to a single commit once they land. Sibling of isaac-sim#6239 (the articulation equivalent). ## What The ovphysx wheel now exposes per-collision-shape rigid-body material as the `RIGID_BODY_SHAPE_FRICTION_AND_RESTITUTION` tensor type (shape `[N, S, 3]` = static friction, dynamic friction, restitution). This closes the gap that kept **five** rigid-object material tests `xfail`ed — they were empty `NotImplementedError` stubs written against the PhysX-only `root_view.get/set_material_properties()` / `max_shapes` view API. - Add the `tensor_types` alias `RIGID_BODY_SHAPE_FRICTION_AND_RESTITUTION`, guarded with `try/except AttributeError` so the module stays import-safe against older wheels. - Implement, mirroring the PhysX backend but reading/writing the material through `OvPhysxView.get_attribute` / `set_attribute`: - `test_rigid_body_set_material_properties` and `test_set_material_properties_via_view` — set/get round-trip. - `test_rigid_body_no_friction`, `test_rigid_body_with_static_friction`, `test_rigid_body_with_restitution` — physical-behavior tests. - Ground planes use the solver-common `RigidBodyMaterialBaseCfg`; masses come from `data.body_mass`. The no-friction test settles the cube and uses zero restitution so the resting contact is clean before asserting the sliding velocity is preserved. ## Verification OVPhysX runs the PhysX solver, so the physical tests use the PhysX reference tolerances. All five pass on both `cpu` and `cuda:0` for `num_cubes` 1 and 2. Full `test_rigid_object.py` is green (53 passed on cpu, no regressions).
…#6243) > **Stacked on isaac-sim#6239 (articulation material) and isaac-sim#6240 (rigid-object material)** — this branch merges both so the MDP term has `Articulation.root_view` + `RigidObject.root_view` (the isaac-sim#6225/isaac-sim#6226 migrations) and the material aliases. Review/merge those (and their bases isaac-sim#6224/isaac-sim#6225/isaac-sim#6226) first; the diff here collapses to a single commit once they land. (isaac-sim#6241/collection is **not** needed — this MDP term targets `RigidObject`/`Articulation`, not collections.) ## What `randomize_rigid_body_material` previously **no-op'd on the OVPhysX backend** (the wheel lacked a material binding). The wheel now exposes per-shape material as `*_SHAPE_FRICTION_AND_RESTITUTION`, so this replaces the no-op with a real implementation. OVPhysX runs the PhysX solver, so the new `_RandomizeRigidBodyMaterialOvPhysx`: - mirrors the **PhysX bucket approach** (PhysX's 64000 unique-material limit applies): pre-samples `num_buckets` materials and randomly assigns them to shapes; - writes per-shape `(static_friction, dynamic_friction, restitution)` through the asset's `OvPhysxView` (`set_attribute` on `SHAPE_FRICTION_AND_RESTITUTION` for articulations, `RIGID_BODY_SHAPE_FRICTION_AND_RESTITUTION` for rigid objects), read-modify-writing the full `[N, S, 3]` buffer so non-selected envs are preserved. ### Limitation Randomizes **all shapes** only. Per-body selection (`asset_cfg.body_ids`) raises `NotImplementedError` — the ovphysx wheel exposes no per-body shape counts (unlike PhysX's `link_physx_view.max_shapes` / Newton's `num_shapes_per_body`), so body→shape ranges can't be indexed. ## Verification New real-backend test (`test_randomize_rigid_body_material_mdp.py`) drives the implementation against an OVPhysX `RigidObject`: it asserts the written friction/restitution land within the sampled ranges, and that a per-body selection fails loud. Passes on both `cpu` and `cuda:0`. The PhysX and Newton paths are untouched.
What
The ovphysx wheel now exposes per-collision-shape material as the
ARTICULATION_SHAPE_FRICTION_AND_RESTITUTION/RIGID_BODY_SHAPE_FRICTION_AND_RESTITUTIONtensor types. This closes the gap that kepttest_set_material_propertiesxfailed: the test had been written against the PhysX-onlyroot_view.get_material_properties()/set_material_properties()/max_shapesview API, whichOvPhysxViewdoes not provide.tensor_typesaliasesSHAPE_FRICTION_AND_RESTITUTIONandRIGID_BODY_SHAPE_FRICTION_AND_RESTITUTION, guarded withtry/except AttributeErrorso the module stays import-safe against older wheels.test_set_material_propertiesto read/write the material throughOvPhysxView.get_attribute/set_attributeon the new tensor type. The per-articulation shape count is derived from the binding shape[N, S, 3]([static_friction, dynamic_friction, restitution]); the test skips on wheels that lack the type. The now-unused_MATERIAL_GAP_REASONis removed.Verification
The material binding is device-resident (it follows the simulation device). The
set → step → readround-trip passes on bothcpuandcuda:0fornum_articulations1 and 2.