Repository navigation
[OvPhysX] Add RayCaster sensor for the OVPhysX backend - #5691
AntoineRichard merged 8 commits into
Conversation
There was a problem hiding this comment.
Review: OVPhysX RayCaster Sensor Implementation
This PR adds the OVPhysX backend for RayCaster, RayCasterCamera, MultiMeshRayCaster, and MultiMeshRayCasterCamera sensors. The implementation follows the established pattern from the PhysX and Newton backends while addressing OVPhysX-specific constraints around USD cloning and tensor bindings.
✅ Strengths
-
Clean Mixin Architecture: The
_OvPhysxRayCasterMixincentralizes all backend-specific logic, allowing the four sensor classes to be simple composition modules. This mirrors the structure inisaaclab_physx. -
Proper Clone-Plan Integration: The latest commit (f4b6d4f) correctly delegates to
SensorBase._resolve_rigid_body_ancestor_expr()for pose binding resolution, which handles clone-plan sources even when destination USD prims do not exist. -
Static Frame Fallback: Non-physics sensor frames (no rigid-body ancestor) correctly fall back to a one-time USD pose snapshot via
_initialize_static_pose_tracking. -
Resource Cleanup:
_invalidate_initialize_callbackproperly destroys tensor bindings and clears mesh view buffers when the simulation stops. -
Well-Documented Limitations: The v1 single-pattern constraint for multi-mesh targets is clearly documented with
NotImplementedErrorand matches the ContactSensor limitation.
⚠️ Suggestions (Non-Blocking)
1. Test Coverage for Multi-Mesh Dynamic Targets (Low)
The new test_ray_caster.py covers the clone-plan resolution path, but _create_tracked_target_view and _update_mesh_transforms for MultiMeshRayCaster with track_mesh_transforms=True remain untested. Consider adding coverage in a follow-up.
2. Floor-Division Safety in _update_mesh_transforms (Low)
In ray_caster.py (around line 240), meshes_per_env = view_count // self._num_envs assumes exact divisibility. An assertion like assert view_count % self._num_envs == 0 would catch misconfigured scene graphs early.
📋 Summary
Commits reviewed (4 total):
781b587b- Wire OvPhysX preset into shared RoughPhysicsCfge098c274- Route RayCaster dispatch to ovphysx backend0fbd27b1- Add isaaclab_ovphysx.sensors.ray_caster packagef4b6d4f0- Fix OVPhysX RayCaster clone source resolution
The implementation is well-structured and complete:
| Component | Status |
|---|---|
Factory dispatch routing (_backend_class_names) |
✅ |
OvPhysX sensor module (isaaclab_ovphysx.sensors.ray_caster) |
✅ |
| Mixin-based pose tracking via RIGID_BODY_POSE tensor binding | ✅ |
| Clone-plan source resolution (f4b6d4f fix) | ✅ |
Velocity env preset (RoughPhysicsCfg.ovphysx) |
✅ |
| Unit test for clone-plan path | ✅ |
| Changelogs | ✅ |
The final commit (f4b6d4f) addresses a key integration concern: the mixin now correctly resolves pose bindings through the shared _resolve_rigid_body_ancestor_expr() method, which properly handles clone-plan sources without requiring destination USD prims to exist. The accompanying test validates this behavior.
Recommendation: This implementation is ready for merge.
Reviewed at f4b6d4f
Update (706b1da): New commit adds proper per-environment offset alignment to OVPhysX binding row order. The refactored _resolve_offsets_in_binding_order method correctly maps sensor prim offsets to their corresponding RIGID_BODY_POSE binding rows, handling cases where OVPhysX may return environments in non-sequential order. New test validates this ordering behavior. No new issues introduced.
Previous suggestions status:
- Multi-mesh test coverage: still a follow-up item (non-blocking)
- Floor-division assertion: not yet added (non-blocking)
Recommendation remains: ready for merge.
Update (c5d2721): This commit reverses the per-environment offset alignment introduced in 706b1da. The complex _resolve_offsets_in_binding_order machinery (including _get_binding_prim_paths, _resolve_sensor_offsets_by_body_path, and _validate_binding_paths_match_glob) has been removed entirely. Offset initialization now simply replicates the fixed offset for all views.
Changes:
- Removed ~75 lines of offset-resolution logic and the
fnmatchimport - Simplified
_FakeBinding/_FakePhysxtest fixtures - Removed the binding-order alignment test
Assessment: This simplification is reasonable if per-sensor-prim offsets are not needed for the initial version (single uniform offset per raycaster). It reduces complexity and potential failure modes. However, this means all environments must use identical sensor-to-body offsets — non-uniform offsets (e.g., sensors at different body-relative positions across envs) are no longer supported.
Previous suggestions status:
- Multi-mesh test coverage: still a follow-up item (non-blocking)
- Floor-division assertion: still not added (non-blocking), but less likely to trigger given simplified code path
Recommendation remains: ready for merge.
Update (b2313bf): Single new commit removes @pytest.mark.isaacsim_ci markers from all OVPhysX test files (articulation, rigid object, rigid object collection, contact sensor) since IsaacSim CI cannot run the OVPhysX backend. Pure test-configuration cleanup — no functional changes, no new issues.
Previous suggestions status:
- Stale comment re: clone_usd=True: not addressed (non-blocking, original inline comment stands)
- Floor-division assertion: not addressed (non-blocking, original inline comment stands)
- Warp view() alignment: not addressed (non-blocking, original inline comment stands)
- Multi-mesh test coverage: still a follow-up item (non-blocking)
Recommendation remains: ready for merge.
Update (22886c5): New commits add minor improvements to the OvPhysX raycaster: replaced manual destination.partition("{}") with the new shared split_clone_template() utility (cleaner, adds validation). Also removed redundant queue_usd_replication(cfg) calls from OvPhysX asset constructors (articulation, rigid_object, rigid_object_collection) — the USD replication is now handled at a higher level, avoiding duplicate work during scene cloning.
Previous suggestions status:
- Stale comment re: clone_usd=True: not addressed (non-blocking, original inline comment stands)
- Floor-division assertion: not addressed (non-blocking, original inline comment stands)
- Warp view() alignment: not addressed (non-blocking, original inline comment stands)
- Multi-mesh test coverage: still a follow-up item (non-blocking)
No new issues introduced. Recommendation remains: ready for merge.
1550bd8 to
027d979
Compare
Greptile SummaryThis PR adds OVPhysX backend support for the four ray-caster sensor variants (
Confidence Score: 4/5Safe to merge with minor cleanup; the core pose-tracking and env-0-only export logic is sound and locally validated at 4096 envs. The mixin and frame view follow established PhysX backend patterns. Three findings: a stale comment (harmless), an unguarded floor-division in multi-mesh transform update (silently wrong mesh count on misconfiguration), and an inconsistent wp.array.view() call on a 2D tensor. None affect the verified Anymal-D use case. sensors/ray_caster/ray_caster.py for the mesh-count division and static-path warp reinterpretation; interactive_scene.py for the hedge comment. Important Files Changed
|
| # Under OVPhysX ``clone_usd=True`` only env_0 carries USD prims (the | ||
| # env_1..N bodies are physics-layer clones created by physx.clone()), | ||
| # so a single discovered prim must be broadcast to ``self._view_count`` | ||
| # offset rows. Same broadcast PhysX applies. |
There was a problem hiding this comment.
Stale comment after
clone_usd=True change: the comment says "only env_0 carries USD prims (the env_1..N bodies are physics-layer clones)" but the interactive_scene.py change makes clone_usd=True unconditional, so all envs now have authored USD prims in the live stage. find_matching_prims will return one prim per env, and the broadcast branch (len == 1) will not fire. The comment documents a scenario that no longer applies, which would mislead future readers.
| # Under OVPhysX ``clone_usd=True`` only env_0 carries USD prims (the | |
| # env_1..N bodies are physics-layer clones created by physx.clone()), | |
| # so a single discovered prim must be broadcast to ``self._view_count`` | |
| # offset rows. Same broadcast PhysX applies. | |
| # With ``clone_usd=True`` every env has its own authored USD prim, so | |
| # ``find_matching_prims`` returns one entry per env and the broadcast | |
| # branch below (``len == 1``) is only hit in edge cases where a single | |
| # sensor prim covers all envs (e.g. a global terrain marker). |
| view_count = int(view.shape[0]) | ||
| meshes_per_env = view_count | ||
| if view_count != 1: | ||
| meshes_per_env = view_count // self._num_envs |
There was a problem hiding this comment.
Integer floor-division without a divisibility check: if
view_count is not an exact multiple of self._num_envs, meshes_per_env is silently truncated and the wp.launch processes fewer transforms than expected — remaining mesh slots stay at stale values with no warning. An assertion here would surface misconfiguration immediately.
| view_count = int(view.shape[0]) | |
| meshes_per_env = view_count | |
| if view_count != 1: | |
| meshes_per_env = view_count // self._num_envs | |
| view_count = int(view.shape[0]) | |
| meshes_per_env = view_count | |
| if view_count != 1: | |
| assert view_count % self._num_envs == 0, ( | |
| f"OvPhysxRayCaster: target binding shape {view_count} is not divisible " | |
| f"by num_envs={self._num_envs}; mesh-transform kernel will process wrong count." | |
| ) | |
| meshes_per_env = view_count // self._num_envs |
| self._static_view_transforms_torch = torch.tensor(poses, dtype=torch.float32, device=self._device).contiguous() | ||
| self._static_view_transforms_wp = wp.from_torch(self._static_view_transforms_torch).view(wp.transformf) |
There was a problem hiding this comment.
The static-path calls
.view(wp.transformf) on a 2D (N, 7) float32 array, while the dynamic path uses the explicit wp.array(ptr=..., shape=(N,), dtype=wp.transformf) idiom. Aligning them avoids ambiguity in view() semantics on multi-dimensional arrays across Warp versions.
| self._static_view_transforms_torch = torch.tensor(poses, dtype=torch.float32, device=self._device).contiguous() | |
| self._static_view_transforms_wp = wp.from_torch(self._static_view_transforms_torch).view(wp.transformf) | |
| self._static_view_transforms_torch = torch.tensor(poses, dtype=torch.float32, device=self._device).contiguous() | |
| _static_buf = wp.from_torch(self._static_view_transforms_torch) | |
| self._static_view_transforms_wp = wp.array( | |
| ptr=_static_buf.ptr, | |
| shape=(len(prims),), | |
| dtype=wp.transformf, | |
| device=str(_static_buf.device), | |
| copy=False, | |
| ) |
a59b06d to
b8dffa2
Compare
There was a problem hiding this comment.
Superseded by the consolidated follow-up comment: #5691 (comment)
Reclassifying after a follow-up review: the multi-pattern OVPhysX limitation is real, but the cited Dexsuite path is not currently a supported/reached OVPhysX path, so this should not remain a request-changes blocker.
|
Consolidating my earlier notes on the OVPhysX multi-mesh ray-caster path. I do not think the documented multi-pattern limitation, by itself, should block the whole PR. The Anymal-D single-mesh height-scanner path is separate. The two concrete issues I would still address for the multi-mesh dynamic-target path are:
Please preserve the ClonePlan wildcard expression, or collapse cloned env paths back to one ovphysx wildcard before the pattern-dedup check. A targeted test with one env-wildcard, single-body dynamic target would cover this.
Please snapshot/destroy |
|
One more OVPhysX RayCaster pose-tracking issue: this path appears to assume that the
Other OVPhysX code that consumes |
Without an 'ovphysx' field on RoughPhysicsCfg, 'presets=ovphysx' falls back to the 'default' PhysxCfg for the physics stack while still picking the ovphysx ContactSensor (which we already wired into VelocityEnvContactSensorCfg). The OvPhysx ContactSensor's _initialize_impl then calls OvPhysxManager.get_physx_instance() and raises 'OvPhysxManager has not been initialized yet.' on PhysX-backed rough envs (e.g. Isaac-Velocity-Rough-Anymal-D-v0). Add OvPhysxCfg() to RoughPhysicsCfg so 'presets=ovphysx' selects the ovphysx physics stack for rough locomotion the same way it already does for the AnymalD flat env.
Add the ``ovphysx`` entry to the four core ``isaaclab.sensors.ray_caster.*`` factory classes so calls to ``RayCaster(cfg)`` (and the three siblings) under an OVPhysX ``SimulationContext`` return the corresponding class in ``isaaclab_ovphysx.sensors.ray_caster`` rather than raising ``ModuleNotFoundError``.
Mirror the per-backend RayCaster structure introduced by PR isaac-sim#5510 for the OVPhysX backend: a single ``_OvPhysxRayCasterMixin`` (~200 lines) in ``ray_caster.py`` carries the backend-specific pose-tracking surface, reading live body poses through the ovphysx wheel's ``create_tensor_binding(pattern=..., tensor_type=RIGID_BODY_POSE)`` API. Three 14-line sibling modules compose the mixin with the matching ``Base*`` class (RayCasterCamera, MultiMeshRayCaster, MultiMeshRayCasterCamera). Static (non-physics) sensor frames fall back to a one-time USD pose snapshot, matching PhysX's ``_initialize_static_pose_tracking``. Under OVPhysX ``clone_usd=True`` scenes where only env_0 carries USD prims, the env_0 offset is broadcast across the binding's row count (same broadcast PhysX applies). Multi-mesh dynamic targets create a second binding via the same ``create_tensor_binding`` call. v1 limitation: target paths must dedup to a single env-wildcard pattern; multi-pattern targets raise ``NotImplementedError`` (mirrors the OVPhysX ContactSensor ``track_pose`` single-body constraint). Unblocks ``Isaac-Velocity-Rough-Anymal-D-v0 presets=ovphysx`` (the height_scanner is a RayCaster).
Reuse the shared SensorBase rigid-body ancestor resolver so OVPhysX RayCaster pose bindings resolve from clone-plan sources instead of destination USD prims that may not exist under solver-side cloning. Add a focused regression covering the missing-destination-USD path with a mocked OVPhysX binding.
b8dffa2 to
f4b6d4f
Compare
Map sensor offsets by rigid-body prim path and build the Warp arrays in OVPhysX RIGID_BODY_POSE binding order. This keeps per-env offsets aligned when binding rows are not returned in USD discovery order and validates the binding prim_paths count and pattern.
This reverts commit 706b1da.
|
Follow-up on the OVPhysX RayCaster pose-tracking offset ordering concern: PhysX RayCaster does not currently support distinct per-env sensor-to-body offsets either. It resolves the source-side sensor offset and broadcasts that across the rigid-body view rows. Keeping OVPhysX aligned with that backend contract is the intended scope for this PR, so adding binding-row-specific/per-env-authored offsets is out of scope here. If we want that behavior later, it should be added consistently across RayCaster backends with shared contract coverage. |
Drop isaacsim_ci marks from OVPhysX tests because IsaacSim CI cannot run the OVPhysX backend.
Follow-up Review: Commits c5d2721..22886c5The branch has been updated with a merge from New Commits Reviewed
Notable Changes1. Sensor Base Fix (5124aa1) suffix = "/" + relative_path
if not target_expr.endswith(suffix):
raise RuntimeError(...)
rigid_parent_expr = target_expr[: -len(suffix)]This prevents silent misalignment when the target expression doesn't match expected structure. 2. Clone Template Helper (166f314)
Also improves 3. OVPhysX Asset Cleanup Previous Inline Comments StatusThe three P2 suggestions from the prior review have not been addressed in these commits:
These remain non-blocking suggestions for a follow-up. SummaryNo new issues introduced. The bug fixes in Recommendation remains: ready for merge. Reviewed at 22886c5 |
marcodiiga
left a comment
There was a problem hiding this comment.
Approving after re-review. Existing review comments still stand where applicable.
# Description Adds `isaaclab_ovphysx.sensors.ray_caster` so `RayCaster(cfg)`, `RayCasterCamera`, `MultiMeshRayCaster`, and `MultiMeshRayCasterCamera` dispatch correctly under an OVPhysX `SimulationContext`. Unblocks `Isaac-Velocity-Rough-Anymal-D-v0` under `presets=ovphysx` (the height_scanner is a `RayCaster`). Mirrors `isaaclab_physx.sensors.ray_caster` structure: a single `_OvPhysxRayCasterMixin` (~200 lines in `ray_caster.py`) carries the backend-specific pose-tracking surface, reading live body poses via the ovphysx wheel's `create_tensor_binding(pattern=..., tensor_type=RIGID_BODY_POSE)` API. Three 14-line sibling modules compose the mixin with the matching `Base*` class. Static (non-physics) sensor frames fall back to a one-time USD pose snapshot, matching PhysX's `_initialize_static_pose_tracking`. Multi-mesh dynamic targets create a second binding via the same `create_tensor_binding` call. v1 limitation: target paths must dedup to a single env-wildcard pattern; multi-pattern targets raise `NotImplementedError` (mirrors the OVPhysX `ContactSensor` `track_pose` single-body constraint). Also wires `isaaclab_ovphysx.sensors.ContactSensorCfg` and `isaaclab_ovphysx.physics.OvPhysxCfg` into the shared `LocomotionVelocityRoughEnvCfg.RoughPhysicsCfg` so `Isaac-Velocity-Rough-Anymal-D-v0` can pick the right preset under `presets=ovphysx`. Built on top of isaac-sim#5678 (FrameView, **now merged**). Anymal-D Rough at 4096 envs needs FrameView's `clone_usd=True` + env_0 USD stripping to avoid a wheel-side hang during init; with isaac-sim#5678 in develop, this PR is now a standalone three-commit diff: - `Wire OvPhysX preset into shared RoughPhysicsCfg` - `Route RayCaster dispatch to ovphysx backend` - `Add isaaclab_ovphysx.sensors.ray_caster package` Verified locally: - `./isaaclab.sh -p scripts/environments/random_agent.py --task Isaac-Velocity-Rough-Anymal-D-v0 --num_envs 64 --headless presets=ovphysx` reaches the agent loop cleanly. - `./isaaclab.sh -p scripts/reinforcement_learning/rsl_rl/train.py --task Isaac-Velocity-Rough-Anymal-D-v0 --num_envs 4096 --max_iterations 100 --headless presets=ovphysx` completes 100 iterations with non-degenerate mean reward. Fixes # (issue) ## Type of change - New feature (non-breaking change which adds functionality) ## Screenshots N/A — backend dispatch + sensor implementation, no UI surface. ## 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
isaaclab_ovphysx.sensors.ray_castersoRayCaster(cfg),RayCasterCamera,MultiMeshRayCaster, andMultiMeshRayCasterCameradispatch correctly under an OVPhysX
SimulationContext. UnblocksIsaac-Velocity-Rough-Anymal-D-v0underpresets=ovphysx(theheight_scanner is a
RayCaster).Mirrors
isaaclab_physx.sensors.ray_casterstructure: a single_OvPhysxRayCasterMixin(~200 lines inray_caster.py) carries thebackend-specific pose-tracking surface, reading live body poses via the
ovphysx wheel's
create_tensor_binding(pattern=..., tensor_type=RIGID_BODY_POSE)API.Three 14-line sibling modules compose the mixin with the matching
Base*class. Static (non-physics) sensor frames fall back to aone-time USD pose snapshot, matching PhysX's
_initialize_static_pose_tracking.Multi-mesh dynamic targets create a second binding via the same
create_tensor_bindingcall. v1 limitation: target paths must dedupto a single env-wildcard pattern; multi-pattern targets raise
NotImplementedError(mirrors the OVPhysXContactSensortrack_posesingle-body constraint).Also wires
isaaclab_ovphysx.sensors.ContactSensorCfgandisaaclab_ovphysx.physics.OvPhysxCfginto the sharedLocomotionVelocityRoughEnvCfg.RoughPhysicsCfgsoIsaac-Velocity-Rough-Anymal-D-v0can pick the right preset underpresets=ovphysx.Built on top of #5678 (FrameView, now merged). Anymal-D Rough at
4096 envs needs FrameView's
clone_usd=True+ env_0 USD stripping toavoid a wheel-side hang during init; with #5678 in develop, this PR is
now a standalone three-commit diff:
Wire OvPhysX preset into shared RoughPhysicsCfgRoute RayCaster dispatch to ovphysx backendAdd isaaclab_ovphysx.sensors.ray_caster packageVerified locally:
./isaaclab.sh -p scripts/environments/random_agent.py --task Isaac-Velocity-Rough-Anymal-D-v0 --num_envs 64 --headless presets=ovphysxreaches the agent loop cleanly../isaaclab.sh -p scripts/reinforcement_learning/rsl_rl/train.py --task Isaac-Velocity-Rough-Anymal-D-v0 --num_envs 4096 --max_iterations 100 --headless presets=ovphysxcompletes 100 iterations with non-degenerate mean reward.Fixes # (issue)
Type of change
Screenshots
N/A — backend dispatch + sensor implementation, no UI surface.
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