Repository navigation
Conversation
RigidObjectCollection.set_coms_index passed wp.transformf data to the PhysX tensor API, which raises a KeyError. It also marked the lazily filled body_com_pose_b cache as fresh after a partial write, so the unselected entries read back as zeros when the cache had not been read before. set_inertias_index flattened the (num_instances, num_bodies, 9) inertias with the 2D reshape, which the backend rejects. Pass the COM poses as float32, let the next read refresh the COM cache from the view as RigidObject does, and reshape the inertias with the 3D helper. A new test writes both properties to a non-sorted subset of (env, body) cells and checks the PhysX view and the data buffers.
|
There was a problem hiding this comment.
Isaac Lab Review Bot
The PhysX-only COM and inertia setter fixes are scoped appropriately and covered by a focused regression test. One changed comment inaccurately describes the COM cache behavior and should be corrected before merge.
- Design and architecture: The changes remain within the PhysX
RigidObjectCollectionbackend and reuse its established reshape and float-view mechanisms without altering shared abstractions or other backend implementations. - API: The public signatures, selectors, shapes, dtypes, and mask wrappers for
set_coms_indexandset_inertias_indexremain unchanged. Only PhysX payload layout and internal cache bookkeeping are corrected. - Compatibility and deprecation: Breaking changes: none identified. The patch repairs failing setter paths and prevents invalid cached COM values without removing or changing the supported public contract.
- Implementation: The COM payload is converted to the float32 representation required by the PhysX tensor API, and inertia data now uses the three-dimensional reshape path with width 9. Omitting the premature COM timestamp update allows a previously stale source cache to refresh, while the selected cache cells are still updated by the write kernel.
- Style consistency: The helper usage, layout comments, and changelog follow adjacent patterns. However, the new comment at line 1035 says the cached buffers are invalidated and the next read refreshes from the view, while the following call only invalidates dependent buffers;
_body_com_pose_bitself is deliberately left at its existing timestamp. Reword the comment to describe that distinction accurately. - Test quality: The added regression test exercises non-sorted subset selectors and independently checks both PhysX view readback and public COM/inertia buffers on the repository-supported devices. It covers the three reported failures at the owning PhysX boundary without duplicating the existing link-pose subset-write test or mocked interface coverage.
Minor fixes needed. Posted 1 actionable finding inline.
Automated review; human maintainers own approval decisions.
| ) | ||
| # Invalidate the cached buffer | ||
| self.data._body_com_pose_b.timestamp = self.data._sim_timestamp | ||
| # Invalidate the cached buffers. The next read refreshes from the view, so that a partial write does not |
There was a problem hiding this comment.
🔵 Suggestion · Style Consistency — Comment overstates COM cache invalidation
The comment says the cached buffers are invalidated and the next read refreshes from the view, but the call below only resets dependents; _body_com_pose_b itself is never invalidated. A refresh happens only when that buffer was already stale, and the described behavior comes from the removed timestamp assignment rather than this call. Reword to state that only dependents are reset and the source is deliberately left unmarked so a stale cache refreshes.
# Description The asset tests repeated expensive scenes, replayed the same contracts on every backend, and carried custom scaffolding that made them hard to follow. This PR consolidates them across PhysX, Newton, and OVPhysX into lean, directly readable tests: cheap mocked contracts own the shared API, and real-solver tests only cover what needs the real solver. This is the combined PR for review and merge. The split PRs are not being updated. ## Test organization - **One file per asset family and backend.** Every test file pays a fixed 4–7 s of imports (and a Kit launch for PhysX and in the CI core job), so tests live in the file that already pays those costs: unit-level checks sit beside the real-solver tests of the same asset, rigid objects and rigid-object collections share one file and one scene, and the shared contracts are two files. The asset tests went from 39 files to 19. - **Shared contracts** (`source/isaaclab/test/assets/contract/`): `test_articulation_contract.py` (including joint/body ordering) and `test_rigid_object_contract.py` (rigid objects and collections, one factory) run every backend on mocked views. `backends.py` owns the Kit/kitless bootstrap, backend availability, and the manager doubles; unavailable backends collect as skips. Newton runs on CPU only, since its asset code has no CUDA-specific path; PhysX and OVPhysX keep CUDA rows for their pinned-staging paths. - **Writers** are one table-driven test per family covering warp and torch inputs, index and mask selection, partial writes through the public getters (unselected entries must be untouched), scalar writes, and oversized-input rejection. - **Ordering** is a small set of table-driven contracts (property routing, body-state reads, duplicate selectors, stale staging, reset rereads) using cyclic orderings, since a reversal is its own inverse and cannot catch a swapped index map. - **Backend tests** reuse module-scoped composite scenes, with two environments so partial writes prove untouched state, and build each scene on one device unless a Lab code path differs by device (OVPhysX CPU stage serialization, CUDA-graph capture, CPU-only regressions). Tests that own a simulation run before the composite scene; PhysX asserts this so a misplaced test fails loudly. - **Actuator equivalence** on PhysX and Newton runs on the local two-leg and cartpole USD fixtures (in `isaaclab_newton/test/assets/data`) instead of ANYmal. - **WrenchComposer** keeps literal unit cases and one real PhysX delivery test. Newton OSC controllers run closed-loop tracking and gravity compensation on an island of the Newton articulation scene. ## What was removed or merged - Custom framework: `capabilities.py`, `contract_boot.py`, `mock_backends.py`, `public_surface.py`, and tests that only exercised test scaffolding or a copied member inventory. - Duplicate index/mask, root/body/joint/tendon, and rigid/collection writer tests; per-helper `_make_*` variants; tests that rebuilt the same mocked asset to check overlapping properties. - PhysX: Franka and Shadow Hand scenes (local branching fixture covers the Jacobian, gravity compensation, and fixed tendons), the 800-step IK test, ~15 ANYmal actuator simulations reduced to 3, and gravity tests folded into the shared scenes. - OVPhysX: unit files merged into the asset files that already pay the same imports; collection tests share the rigid-object scene; heterogeneous clone tests share scenes; collision-filter and rejection variants no longer doubled across devices; reset checks folded into the wrench tests. - Newton: rigid-object scenes run on CPU only (CUDA stays covered by the actuator, CUDA-graph, and capture tests); authoring tests merged into one table; shorter controller tracking loops; eight files merged into three. - A source-inspection WrenchComposer test, and redundant dtype/selector matrices. - `device_split` runner support (`tools/_device_split.py`, its test, the pytest marker, and workflow mentions). No test declares it after the OVPhysX device fix below. - `DC_MOTOR_ACTUATORS` and `ActuatorStateResetBase` from `isaaclab.test.utils.actuator_equivalence`, which no longer have callers. Every merged or removed contract has a keeper. Non-obvious merges were checked with a one-line production mutation that turns the keeper red (for example, writer kernels ignoring the mask, COM caches not invalidated, Jacobian link shift skipped, collection COM/inertia fixes reverted). Coverage deliberately given up: the Lab-path DelayedPD reset check now runs on Newton only (PhysX asserts reset forwards environment IDs); armature-to-mass-matrix invalidation is no longer tested because PhysX does not reflect armature writes in the mass matrix within one step; PhysX composite-scene checks run on CUDA only (CPU staging stays covered by the mocked contracts); OVPhysX collision isolation, mimic fingers, and non-geometry heterogeneous articulation variants run on CUDA only. ## Runtime changes included in this PR - Fix PhysX rigid-object-collection COM and inertia setters (stacked from #8131). - Allow OVPhysX CPU and CUDA simulations in one process: configure each USD physics scene for the selected device instead of pinning the process to its first device or using the sticky CPU mode. Lifecycle coverage includes CPU → CUDA → CPU. ## Validation Each file ran in its own process on an NVIDIA RTX PRO 6000 Blackwell (warm Warp cache), comparing the head of this PR before the cleanup (`ad9b10a37`) with the current one: | Scope | Files | Time before → after | |---|---:|---:| | Shared contracts | 5 → 2 | 40 s → 17 s | | Core WrenchComposer, actuators, terminations | 5 → 4 | 19 s → 15 s | | Newton assets, actuators, controllers | 8 → 3 | 84 s → 42 s | | PhysX assets | 9 → 5 | 85 s → 40 s | | OVPhysX assets and physics manager | 12 → 5 | 100 s → 52 s | | **Asset tests total** | **39 → 19** | **328 s → 166 s** | Current results: 1,042 passed, 31 skipped, 10 strict xfails, 99 deselected (Newton CUDA contract rows). The OVPhysX sensor, view, and randomization files are unchanged apart from dropping their device-split fixtures (~134 s, not counted above). Fewer files also means fewer Kit launches in CI, where each one costs more than locally. Formatting, lint, LFS, and whitespace hooks pass. The changelog check passes against upstream `develop`. ## Known failures pinned as strict xfails - OVPhysX partial body writes overwrite unselected bodies of the selected environment (rigid-object collection). - Newton fixed-tendon mask setters accept data with extra environments. - PhysX and OVPhysX rigid objects do not reject an enabled articulation root. - After a failed PhysX initialization, the first CPU simulation reads zero poses for kinematic collection bodies. The previous file order masked this. - GPU PhysX applies mass and inertia writes to the mass matrix and gravity compensation on the next step. Other limitations exposed by the redesign and left out of scope: full PhysX collection reset leaves wrench composers active; GPU link-frame wrench delivery can use stale transforms after teleports; Newton native-actuator reset is model-wide. ## Type of change - Test-suite redesign and cleanup - Bug fixes for PhysX collection setters and OVPhysX device lifecycle - CI tooling cleanup (`device_split` removal) ## Checklist - [x] Read the contribution guidelines - [x] Run the formatting and lint checks - [x] Apply the test-audit criteria and verify keepers with mutations - [x] Validate the changed tests on CPU and CUDA where configured - [x] Add changelog fragments for every touched package - [x] Make corresponding documentation changes for the runtime behavior - [x] Existing contributor listed in `CONTRIBUTORS.md` --------- Co-authored-by: Mustafa Haiderbhai <[email protected]> Co-authored-by: Mustafa H <[email protected]>
|
run-ci |
Description
isaaclab_physx.assets.RigidObjectCollectionhas three bugs in its inertial-property setters. #8009 and #8022 found the first one during the test audit (set_coms_indexraisesKeyError) and left it unfixed.set_coms_indexraisesKeyError: <class 'warp._src.types.transformf'>. The COM poses were reshaped into view order but passed to the PhysX tensor API aswp.transformf. Every other view write in this class already calls.view(wp.float32); this path now does too.body_com_pose_b.body_com_pose_bis filled lazily from the view.set_coms_indexwrote the selected cells into the buffer and then marked it fresh, so cells that had never been read back returned all-zero poses (including a zero quaternion) whenever the setter ran before the first read. An example is a COM randomization event applied to a subset of bodies at startup. The setter no longer marks the cache fresh, so the next read refreshes from the view, which is whatRigidObjectdoes.set_inertias_indexfails withFailed to set rigid body inertias in backend. The(num_instances, num_bodies, 9)inertias were flattened with the 2D reshape helper. They now usereshape_data_to_view_3d(..., 9).Only the PhysX collection is affected.
RigidObjectandArticulationhandle these paths correctly, and the mocked interface tests accept either layout, which is why this was missed.Testing
A new test,
test_inertial_property_subset_writes_reach_selected_view_entries, writes COM and inertia to a non-sorted subset of (env, body) cells. It then checks both the PhysX view readback and the data buffers, on CPU and CUDA. Each bug turns it red on its own:developKeyError: transformfinset_coms_indexbody_com_pose_bmismatch: 4/42 elements (zero quaternionwin unselected cells)Exception: Failed to set rigid body inertias in backendsource/isaaclab_physx/test/assets/test_rigid_object_collection.py: 40 passedsource/isaaclab/test/assets/test_rigid_object_collection_iface.py: 107 passed./isaaclab.sh -f: all hooks passType of change
Release backport
developChecklist
Docker and GPU tests run on demand. Push the commits you want tested, then
comment
run-cion the pull request.pre-commitchecks withuv run isaaclab --formatsource/<pkg>/changelog.d/for every touched package (do not editCHANGELOG.rstor bump package versions — CI handles that)CONTRIBUTORS.mdor my name already exists there