isaaclab_physx.sim.views#
PhysX simulation views.
Classes#
The following classes are part of the public isaaclab_physx.sim.views API.
FrameView with Fabric GPU acceleration for the PhysX backend. |
- class isaaclab_physx.sim.views.FabricFrameView[source]#
Bases:
BaseFrameViewFrameView with Fabric GPU acceleration for the PhysX backend.
Uses composition: holds a
UsdFrameViewinternally for USD fallback and non-accelerated operations (visibility, and all pose/scale operations when Fabric is disabled).When Fabric is enabled, world-pose, local-pose, and scale operations run on the GPU via Warp kernels that read and write
omni:fabric:worldMatrixandomni:fabric:localMatrixdirectly. All other operations delegate to the internal USD view.All writes go through the writer-scope API (
xform_world_space_writer()/xform_local_space_writer(), recommended) or the convenienceset_world_poses()/set_local_poses()/ etc. helpers inherited fromBaseFrameView.Behavior (Fabric path):
Leaf-prim assumption. This view manages a flat set of sibling prims (e.g. all cameras under
/World/Env_*/Camera). It does NOT propagate transforms to child prims. If a managed prim has children whose world matrices depend on the parent, those children must be updated via a separate view, a physics step, orIFabricHierarchy.update_world_xforms.No write-back to USD. Fabric writes update only
omni:fabric:worldMatrix/omni:fabric:localMatrix; the prim’s USDxformOp:*attributes are unchanged. Downstream consumers that read the prim’s USD attributes after a Fabric write will see stale values until the next USD-side sync.Eager dual-write inside a writer scope (no dirty tracking). When a writer scope is open, all writes go to the primary attribute (
worldMatrixfor the world writer,localMatrixfor the local writer). On scope exit, a single Warp kernel derives the opposite attribute and a singlewp.synchronize()runs. After the scope exits, both Fabric matrices are self-consistent. Getters launch their own decompose kernel andwp.synchronize()before returning, so a returnedProxyArrayis always immediately readable from either GPU or host code (no caller-side sync required).The opposite-space derive runs even when the scope unwinds via exception (including
KeyboardInterruptin interactive notebooks), as a best-effort to keepworldMatrixandlocalMatrixmutually consistent on whatever partial-write state Fabric holds. The partial write itself is not rolled back – if you need transactional all-or-nothing semantics, snapshot the matrices yourself before entering the scope.Fabric Hierarchy listeners are paused while a writer scope is active when the hierarchy bindings are available. On enter, the writer calls
IFabricHierarchy.track_local_xform_changes(False)()/track_world_xform_changes(False)()(saving the prior state). Fabric itself is just a flat attribute store; the plugin that keepsomni:fabric:worldMatrixandomni:fabric:localMatrixmutually consistent across the prim hierarchy isusdrt.hierarchy.IFabricHierarchy(a.k.a. Fabric Hierarchy). Its change tracking is pull-based: a per-attribute listener records writes into a private changelog, and the plugin drains and processes that changelog on the next call toIFabricHierarchy::update_world_xforms()(typically from the render path). “Tracking off” just stops the listener from recording new entries – writes still land in Fabric storage; they are simply invisible to the nextupdate_world_xforms()call.That is exactly what we want. Inside the scope we write one space (world or local) and, at scope exit, derive the other in a single batched kernel so both matrices are mutually consistent. If tracking were left on, our writes would be queued in the changelog and the next
update_world_xforms()tick would process them – choosing a canonical direction (e.g. “user authored local, recompute world from it”) and potentially overwriting one half of our just-consistent pair. With tracking paused for the duration of the scope, the changelog stays empty for these prims and the next tick is a no-op for them.__exit__restores the prior tracking state (so we do not re-enable listeners the caller had previously paused). The Fabric Scene Delegate (FSD) readsomni:fabric:worldMatrixdirectly from Fabric storage on the render path; it observes our final writes unchanged.Headless experiences without FSD do not expose the hierarchy Python bindings and do not run hierarchy update ticks. In that case the writer skips listener pause/restore while retaining the same direct Fabric matrix writes.
Note: the scope is synchronous Python code, so no simulation step and no render tick can run while it is open – callers must not advance the simulation from inside the scope (see
isaaclab.sim.views.xform_space_writerfor the full contract). The “torn data” concern is what motivates that no-step rule; it is separate from why the tracking pause exists.Selections are scoped to the view, not the stage. The view tags its own prims (and their parents) with private per-view index attributes and requires those attributes in every prim selection, so a selection resolves to exactly the prims the view manages however large the stage grows. Tag names are unique per view instance, so views never interfere with one another. The tags are authored on first use and removed again by
close()– or, best-effort and with a warning, when the view is garbage collected. Callclose()when done with a view; collection timing is up to the interpreter, so relying on it can remove the tags at an arbitrary point in the frame (or, on a leaked reference, not at all).Topology changes are absorbed, with no cache to invalidate. The view-to-Fabric mapping is re-derived from live Fabric data on every access, so prims moving between Fabric buckets can never leave a stale mapping behind. If a managed prim disappears (prim or attribute removed) the next access raises
RuntimeErrorand the view must be recreated. See_refresh_child_selectionfor how this is done.
Pose getters return
ProxyArray; the convenienceset_world_poses()/set_local_poses()helpers acceptwp.array. Inside a writer scope, the writer’sset_poses()/set_scales()acceptwp.array.Methods:
- __init__(prim_path: str, device: str = 'cpu', validate_xform_ops: bool = True, stage: Stage | None = None, **kwargs)[source]#
Initialize the view.
- Parameters:
prim_path¶ – USD prim-path pattern to match.
device¶ – Device for Warp arrays. Either
"cpu"or any CUDA device string ("cuda:0","cuda:1", …); Fabric acceleration is supported on every CUDA index.validate_xform_ops¶ – Whether to validate prim xform-ops.
stage¶ – USD stage; defaults to the current sim context’s stage.
**kwargs¶ – Additional keyword arguments (ignored). Matches the signature of
UsdFrameViewso that the top-levelFrameViewfactory can forward backend-agnostic kwargs without each backend having to know about every option.
- classmethod __new__(*args, **kwargs)#