Repository navigation
[PR9C] Fix native frame reads and preserve live Fabric poses - #8782
Conversation
|
run-ci |
|
run-ci |
|
Tested working locally with Quest, G1 locomanipulation env with kit physix and XR. |
| "FrameView should only be used for non-physics frames." | ||
| ) | ||
| if validate_xform_ops: | ||
| physics_frame = prim.HasAPI(UsdPhysics.RigidBodyAPI) or prim.HasAPI(UsdPhysics.CollisionAPI) |
There was a problem hiding this comment.
Non-blocking: Previously the view also rejected paths that matched a Newton body_label or a colliding shape_label. Now physics frames are only detected from RigidBodyAPI / CollisionAPI on the USD prim. A body that exists in the Newton model but has no RigidBodyAPI (procedural or importer-built) would now resolve as a site on its parent body, with a fixed offset from USD. It would also get working writers instead of raising. Could the label match stay, used only to set _contains_physics_frames (and resolve the body to itself) instead of raising?
| def _get_world_poses_impl(self, indices: wp.array | None = None) -> tuple[ProxyArray, ProxyArray]: | ||
| """Get world-space positions and orientations.""" | ||
| state = self._backend_manager.get_state_0() | ||
| self._scene_data_provider.get_transforms(self._body_transforms) |
There was a problem hiding this comment.
Nit: the bool returned by get_transforms is ignored. If the provider has nothing to publish, self._body_transforms.transforms stays unset, and the failure shows up later as an unclear Warp launch error. Raising a short error here when it returns False would make that easier to diagnose.
| if orientations is None: | ||
| orientations = cur_quat_ta.warp | ||
| else: | ||
| self._scene_data_provider.get_transforms(self._body_transforms) |
There was a problem hiding this comment.
Nit: the bool returned by get_transforms is ignored. If the provider has nothing to publish, self._body_transforms.transforms stays unset, and the failure shows up later as an unclear Warp launch error. Raising a short error here when it returns False would make that easier to diagnose.
| ) | ||
| sim.step(render=False) | ||
| sim.forward() | ||
| frame_view = FrameView("/World/Cube", device=device) |
There was a problem hiding this comment.
Non-blocking: Moving the FrameView creation after the native write covers the fixed case well: a view created later no longer resets the live pose. The earlier ordering also covered a different case, a view that already exists before the write and still reads the new pose afterwards. Can we keep both, for example by building one view before the write and one after, and checking both?
[Medium impact] The changes affect frame-pose reads across three simulation backends. The PR appears safe to merge, with a non-blocking error when callers prepare an OVPhysX writer before physics is ready. Findings
SummaryThis PR preserves existing Fabric matrices and enables native body-frame reads.
Reviews (1) · Last reviewed commit: "Preserve bound host frame reads for tele..." · Reviewed by Greptile |
| # ------------------------------------------------------------------ | ||
|
|
||
| def _make_world_space_writer(self) -> FrameViewWorldSpaceWriter: | ||
| if self._contains_physics_frames: |
There was a problem hiding this comment.
Creating an OvPhysxFrameView writer before physics is ready now raises AttributeError, even for a non-physics frame. The constructor supports deferred setup, but _contains_physics_frames is assigned only in _initialize_impl. Callers can no longer prepare a writer before reset and enter it afterward. Set the flag during construction, or check readiness before reading it.
hougantc-nvda
left a comment
There was a problem hiding this comment.
Four P2 follow-ups on reviewed head d996e785557b9daffe08c5ebd95403ea12267a8d, recorded for awareness and later fixes now that the PR has merged.
The two Newton issues were reviewed with Claude and reproduced on real Newton XPBD CPU using the pinned Newton revision. The OVPhysX issue was reproduced at the Python constructor boundary with real USD and a stand-in not-yet-ready manager. The additional Fabric issue was reproduced with native USD/USDRT/Fabric CPU components from the pinned Isaac Sim release; the full base also mishandled that case, so it is a remaining initialization defect rather than a demonstrated newly introduced regression. Full Kit/PhysX/render-loop and CUDA verification were not performed for these follow-up reproductions.
| # ------------------------------------------------------------------ | ||
|
|
||
| def _make_world_space_writer(self) -> FrameViewWorldSpaceWriter: | ||
| if self._contains_physics_frames: |
There was a problem hiding this comment.
[P2] Apply the physics-frame write restriction to the legacy scale setter too
The new guards reject both writer factories for body/collision views, but the public set_scales() convenience API bypasses them: BaseFrameView.set_scales() calls _set_scales_impl() directly, which reaches _set_legacy_shape_scales() and writes model.shape_scale for every collision shape on the selected body. On a newly accepted body view, I reproduced both writer factories raising the intended ValueError while view.set_scales(...) silently changed native shape scales from (0.1, 0.1, 0.1) to (2, 3, 4).
This makes the advertised read-only physics-frame view capable of changing collision geometry. The setter already existed for child sites, but accepting body/collision views makes this path newly reachable through those views. A small follow-up is to apply the same _contains_physics_frames guard in _set_scales_impl() and extend the existing write-rejection coverage to this public setter.
|
|
||
| # only rigid bodies are simulated; a non-body articulation root is not a parent body | ||
| body_prim = prim.GetParent() | ||
| body_prim = prim |
There was a problem hiding this comment.
[P2] Preserve parent-relative local reads for the newly accepted body frames
Starting the ancestor walk at prim correctly produces an identity body-to-site offset for computing a body's world pose. However, _get_local_poses_impl() also returns that _site_local offset directly, so every newly accepted body view reports an identity local pose regardless of its pose relative to its USD parent. With a real Newton body at (1, 2, 3) under an identity parent, get_world_poses() returned (1, 2, 3) while get_local_poses() returned (0, 0, 0); a UsdFrameView on the same prim returned local (1, 2, 3). OVPhysX computes local reads against the parent, and the shared frame-view contracts define local poses as the structural parent-relative offset.
Newton's existing private body-local representation can remain useful for world-pose composition, but it should not silently become the public local pose for body frames. A follow-up should compute their parent-relative local pose, or explicitly reject unsupported local reads, with coverage for a non-identity body pose.
| # ------------------------------------------------------------------ | ||
|
|
||
| def _make_world_space_writer(self) -> FrameViewWorldSpaceWriter: | ||
| if self._contains_physics_frames: |
There was a problem hiding this comment.
[P2] Initialize the physics-frame flag before deferred writer access
This corroborates the existing P2 report with a base/head reproduction. When the constructor defers setup to PHYSICS_READY, _contains_physics_frames has not been assigned: its only assignment is inside _initialize_impl(). Both writer factories now read it immediately. A caller preparing a writer before reset, or making a pre-ready USD-backed scale write on a non-physics frame, therefore gets AttributeError rather than a usable writer or the appropriate readiness/ownership error.
Using the real base/head constructors against an in-memory USD Xform, with only the not-yet-ready manager interface represented by a stand-in, writer creation and set_scales() both succeeded on the base and both raised the missing-attribute error at head. This verifies the Python initialization path, not the pinned OVPhysX runtime. Computing the flag in __init__ after resolving _prims, before the synchronous/deferred branch, would address the missing state.
| rt_xformable.CreateFabricHierarchyLocalMatrixAttr() | ||
| rt_xformable.SetLocalXformFromUsd() | ||
| if not rt_prim.HasAttribute(self._WORLD_MATRIX_NAME): | ||
| matrix = usd_xforms.GetLocalToWorldTransform(usd_stage.GetPrimAtPath(path)) |
There was a problem hiding this comment.
[P2] Seed a missing child world matrix from its live Fabric parent
A valid prim can reach this branch with no Fabric matrices while its parent already has a live Fabric pose that differs from USD. I reproduced it without deleting attributes: populate a parent authored at USD x=1, move it through the native Fabric hierarchy API to x=10, create a child Camera at local x=2, then bind its FabricFrameView before pending population notices are processed. Both child matrices were absent before binding. This USD world calculation seeds the child at x=3; composing its local transform with the live parent should give x=12. The first getter returns 3 while the parent stays at 10. Processing the pending population notices and hierarchy update later corrects the child to 12. A fully populated child control reads 12 immediately.
This is a remaining initialization defect, not a demonstrated new regression against the complete base: the removed routine also seeded parent matrices from USD, and the base reproduction returned child 3 while additionally resetting the parent to 1.
A narrow follow-up is to initialize a missing local matrix first, then compose only a missing world matrix from that local matrix and the parent's available Fabric world matrix (local * parent_world in USD row-vector storage), honoring resetXformStack and preserving existing matrices. A scratch prototype returned 12 before population processing and remained correct afterward. Existing initial-scale/body-preservation tests do not cover this missing-child plus Fabric-only parent-motion combination. Verification used native CPU components from pinned Isaac Sim 6.2.0.0 (USDRT 7.6.3); full Kit/PhysX/render-loop and CUDA coverage remain unverified.
hougantc-nvda
left a comment
There was a problem hiding this comment.
LGTM. Agent flagged some issues to be aware of.
# Description On Newton, a hard `sim.reset()` closes the backend and rebuilds the model, but the sticky graph-replay flag `NewtonManager.transforms_may_change_on_graph_replay` carries over from the discarded graph. `forward()` then runs for the new model before `initialize_solver()` constructs its solver, so an asset pose read during the reset, such as one in a `PHYSICS_READY` callback, raises `RuntimeError: NewtonManager.initialize_solver() must run ...`. `_close_backend()` now clears the flag together with the graph it describes. `initialize_solver()` runs FK for the new model, so nothing pending is lost. The sensor-freshness part of the original PR (#8643) is covered on `main` by #8780 and #8782, and the pending-FK flag now lives on the backend that a hard reset recreates (#8733), so this PR is narrowed to the graph-replay flag. ## 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 `main` `release/3.0.0` predates #8733, so its backport clears `kinematics_dirty` and the graph-replay flag in `start_simulation()`. ## Tests `test_newton_manager_abstraction.py::test_reset_binds_consumers_before_constructing_the_solver` now sets the graph-replay flag before the hard reset and calls `forward()` in its `PHYSICS_READY` callback. On `main` (`9860e2bd86`) it fails with that `RuntimeError`; with this PR the file passes (106 passed). ## 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 `uv run isaaclab --format` - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have validated the changed behavior with focused coverage and applied the [test-audit criteria](https://github.com/isaac-sim/IsaacLab/blob/develop/skills/developer/test-audit/SKILL.md) to any test changes - [x] I have added a changelog fragment under `source/<pkg>/changelog.d/` for every touched package (do **not** edit `CHANGELOG.rst` or bump package versions — CI handles that) - [x] I have added my name to the `CONTRIBUTORS.md` or my name already exists there
Description
Creating a Fabric
FrameViewcould overwrite a live transform with its original USD pose. Newton and OVPhysX also rejected reads of physics-body frames, and Newton frame reads could miss a preceding articulation state write.forward().Teleop and XR retain their existing bound Fabric matrix reads. This PR adds no host-read API, pose cache, runtime class, or production module. 92 additions / 197 deletions; net 105 lines removed, including tests and changelogs.
Validation
2b696b4caand passes after this fix. Removing the prematurepxr.Gfimport lets Kit select its USD libraries before loading them.uv run isaaclab -f, the changelog gate against8c9b995cb, andgit diff --checkpassed. No new test files or cases.Host pose-read performance
Main
8c9b995cb→d996e7855, medians in microseconds. Both revisions use bound host matrices; the device below is the simulation device, not the pose storage location.Kit/PhysX on an RTX 5090, 30 alternating batches of 200 updates after 100 warmups, using fixed-revision baseline code in the same process. Four changed translation/rotation cases were checked without advancing physics. Instrumentation recorded no Warp kernel launches, global synchronizations, or Warp-to-NumPy copies in the restored target update. The teleop session and XR presentation are mocked; these numbers measure pose reads/composition, not headset latency or training FPS. GPU1 was not used.