Repository navigation
Conversation
A tracked multi-mesh target with several bodies per environment, such as the links of a robot, is read through one rigid-body view over one pattern per body. PhysX lists such a view pattern by pattern, but the copy into the mesh table read it environment by environment, so most meshes were placed at other environments' body poses. Group the view rows by the environment of their prim path once at initialization, keeping the pattern order within an environment, and copy each table entry from its own row. Entries of environments with fewer bodies keep their placeholder poses.
[Medium impact] The PR appears safe to merge; both previous findings are addressed and no new actionable issues were found. SummaryThis PR matches tracked meshes to PhysX bodies by prim path rather than by view order.
Both previous findings are addressed. No new actionable issues were found. Diagram%%{init: {'theme': 'neutral'}}%%
flowchart LR
A[Build each environment's mesh records] --> B[Record each mesh's body path]
C[PhysX body paths] --> D[Match paths to view rows]
B --> D
D --> E[Copy matching body poses]
D --> F[Leave unmatched entries unchanged]
Reviews (2) · Last reviewed commit: "Merge branch 'develop' of https://github..." · Reviewed by Greptile |
| for row, path in enumerate(view.prim_paths): | ||
| matched = None if plan is None else cloner.path.match(path, plan.env_template) | ||
| env_id = row // meshes_per_env if matched is None else int(matched.instance) | ||
| if env_id < self._num_envs: | ||
| rows_per_env[env_id].append(row) |
There was a problem hiding this comment.
Meshes get another body's pose
_build_mesh_records builds each environment's mesh list from its own prototype's child order, but this mapping keeps the body-pattern order chosen from one prototype. If another prototype lists the same bodies in the opposite order, its meshes receive each other's poses and return wrong ray hits.
Match each mesh entry to its body path rather than relying on the order within an environment. Add coverage for differently ordered prototypes.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| matched = None if plan is None else cloner.path.match(path, plan.env_template) | ||
| env_id = row // meshes_per_env if matched is None else int(matched.instance) |
There was a problem hiding this comment.
Shared targets prevent startup
A tracked target under /World/envs/env_shared now crashes initialization when its view contains multiple bodies. Shared assets use env_template.format("shared"), so cloner.path.match succeeds and int(matched.instance) becomes int("shared"), raising ValueError.
For example, a single-environment scene targeting two shared rigid bodies reaches this branch through the supported USD fallback. Treat shared-world paths as outside the numbered environments and preserve the previous view-order assignment.
There was a problem hiding this comment.
Isaac Lab Review Bot
Needs attention: Scope and over-engineering (1), Implementation (1), Style consistency (1). Other reviewed categories look good.
- PR description: The body matches the fix and validation, but “any row order PhysX returns” overstates code that still relies on within-environment pattern order; narrow that claim.
- Design and architecture: Architecture looks good.
- Scope and over-engineering: Minimal implementation: keep row mapping in
ray_caster.py; merge the addedray_caster/kernels.pykernel into existingsensors/kernels.pyand delete the new module; retain the indexed-copy flow, regression test, and changelogs. Replace with one smaller PR: modify those two source files plus the focused integration test and changelog fragments; validate homogeneous and heterogeneous multi-body targets. - API: API changes look good.
- Compatibility and deprecation: No breaking changes identified.
- Implementation:
_mesh_view_rowsis always initialized, so its guard cannot protect the subsequent optional_mesh_viewsaccess; guard the actual state or return when the mapping is empty. - Style consistency: The
getattrdefault hides known optional_mesh_viewsstate; initialize that state explicitly in its owner and use direct access. - Test quality: Test quality looks good.
Minor fixes needed. Posted 3 inline findings.
Automated review; human maintainers own approval decisions.
|
|
||
|
|
||
| @wp.kernel(enable_backward=False) | ||
| def copy_view_rows_to_mesh_table_kernel( |
There was a problem hiding this comment.
🟡 Warning · Scope Complexity — Fold kernel into existing PhysX kernels module
isaaclab_physx/sensors/kernels.py already owns shared PhysX sensor kernels. A new module for one kernel adds a second owner; move copy_view_rows_to_mesh_table_kernel there and delete this file.
| super()._initialize_warp_meshes() | ||
| # only multi-mesh ray casters have mesh views | ||
| self._mesh_view_rows = [ | ||
| None if view is None else self._map_view_rows(view) for view in getattr(self, "_mesh_views", []) |
There was a problem hiding this comment.
🟡 Warning · Style Consistency — Avoid getattr default for optional state
The guide forbids getattr defaults for known attributes, and this class guards the same state with hasattr. Give _mesh_views an explicit default in its owner and access it directly here.
| def _update_mesh_transforms(self: Any) -> None: | ||
| """Refresh dynamic multi-mesh targets directly from PhysX views.""" | ||
| if not hasattr(self, "_mesh_views"): | ||
| if not hasattr(self, "_mesh_view_rows"): |
There was a problem hiding this comment.
🟡 Warning · Implementation — Guard no longer protects _mesh_views access
_initialize_warp_meshes always sets _mesh_view_rows, so this early return never fires; line 181 then dereferences _mesh_views, which line 135 treats as optional. Guard on _mesh_views, or return when the mapping is empty.
The mapping applied one prototype's body order to every environment, so a prototype that authors the same bodies in another order swapped their poses, and a multi-body target in the shared world failed to parse its environment id. The base now records the tracked body path of each mesh entry, and each entry reads the view row of its own body.
Guard the mesh-table refresh on the mesh views again and read them without defaults.
…fix/ray-caster-multi-body-targets # Conflicts: # source/isaaclab_physx/isaaclab_physx/sensors/ray_caster/ray_caster.py
…#8681) # Description A multi-mesh ray-cast target inside the environments with `track_mesh_transforms=False` was looked up on the USD stage, while tracked targets resolve through the clone plan. Without Kit (Newton, OVPhysX), the stage holds only the clone sources, so every environment got environment 0's copy at environment 0's pose, and a target with several prototypes failed the even-partition check (#8680). Untracked targets now resolve through the clone plan like tracked ones: each environment takes its prototype's source geometry. Where the stage authors the environment's clone, as with Kit, the record is read from that clone, so those mesh tables are unchanged. Otherwise the source is shifted by the difference of the environment origins (`ClonePlan.positions`), which is how the Newton and OVPhysX cloners place the clones and how the OVPhysX frame view places sites that exist only in the source. Targets outside the environments and scenes without a clone plan still resolve from the stage. Behavior changes beyond the kitless placement: - In a heterogeneous scene, each environment holds only its own prototype's copy of the target, or none. With Kit, a target that some prototypes lack used to fail the partition check. - A target that names one environment's prim, such as `/World/envs/env_0/Crate`, now belongs to that environment only, as a tracked target already does. It used to be given to every environment. Fixes #8680 ## 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 `develop` `release/3.0.0` has the same `base_multi_mesh_ray_caster.py`, clone plan helpers and Newton test file, and the change applies there without conflicts. Both new tests fail there without the fix and pass with it. ## Screenshots One ray per environment straight down onto an untracked target, four environments: | | Before | After | | --- | --- | --- | | Newton (MJWarp) and OVPhysX, a crate in every environment | environment 0 hits its crate, environments 1-3 miss | every environment hits its own crate | | OVPhysX, a target with two variants (environments 0-1 and 2-3) | `RuntimeError: Target expression '/World/envs/env_[^/]+/Target' matched 2 mesh records, which cannot be evenly partitioned across 4 environments.` | each environment's mesh table holds its own variant; with #8676, the hits match Isaac Sim PhysX | | OVPhysX, a box only in environments 0-1 | environment 0's box in all four mesh tables | the box in the tables of environments 0-1 only; with #8676, hits in environments 0-1, none in 2-3 | | Isaac Sim PhysX, a box only in environments 0-1 | the same partition error | hits in environments 0-1, none in 2-3 | | Isaac Sim PhysX, a crate in every environment, or the two variants | each environment's own copy | the same mesh tables | ## Tests - New `test_legacy_multi_mesh_hits_static_target_of_each_env` in `source/isaaclab_newton/test/sensors/test_newton_raycast_sensor.py` (Newton, MJWarp) and new `source/isaaclab_ov/test/sensors/test_multi_mesh_ray_caster.py` (OVPhysX): four environments, one ray per environment straight down onto a box or crate that is an untracked target; every hit must be on the top of the environment's own copy. On `develop`, both fail with 9 of 12 values different: environments 1-3 miss. - On `release/3.0.0` (Newton 1.6.1), both new tests fail without the fix and pass with it. - With the fix on `develop` 9b6d2d8 (Newton 1.8.0.dev0, MuJoCo Warp 3.15.0, OVPhysX 0.6.4): `test_newton_raycast_sensor.py` 8 passed; on OVPhysX `test_multi_mesh_ray_caster.py` 1 passed and `test_ray_caster.py` 1 passed; on Isaac Sim PhysX `source/isaaclab/test/sensors/test_multi_mesh_ray_caster_camera.py` 7 passed (including the heterogeneous scene with an untracked `{ENV_REGEX_NS}/Object` target) and `test_ray_caster_integration.py` 6 passed. - The repository's pre-commit hooks pass on the changed files (`pre-commit run --files`), as does `tools/changelog/cli.py check`. ## Related - #3298 Adds Raycaster with tracking for dynamic meshes: introduced the multi-mesh ray caster and its untracked targets. - #8676 Bind OVPhysX ray-caster rows in environment order (open): with several prototypes, OVPhysX lists the ray-caster rows in clone order, so the OVPhysX hits of the heterogeneous cases above also need it; the two merge without conflicts. - #8678 Map PhysX multi-body ray-cast targets to their environments (open): edits `_build_mesh_records` for tracked targets; the two merge without conflicts. - #8655 Reject sensors whose asset exists in only some environments (open): rejects tracked targets that some environments lack, since their body view needs a row in every environment; an untracked record carries its own pose, so such environments hold no copy here. The two merge without conflicts. ## Checklist Docker and GPU tests run on demand. Push the commits you want tested, then comment `run-ci` on the pull request. - [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 --------- Co-authored-by: Octi Zhang <[email protected]>
## Description Specialized consumers rediscovered scene bodies or assumed every cloned environment had USD geometry. Sensor reads could also retain articulation poses from before a state write, or bind different sites after a Newton hard reset. This change uses existing scene ownership and repairs those lifecycle boundaries. - **Ray casters:** bind tracked meshes and OVPhysX sensor frames to exact native body paths. The shared ray-caster initializer resolves the scene-data provider once; leaf consumers use that bound dependency. Persistent `int32` index arrays use `-1` for static and padded slots, with one per-slot check in Warp and a separate all-static fast path. Missing native target bodies produce an error naming the target and body. - **Pose writes and environment coverage:** refresh pending articulation kinematics before PhysX ray-caster frame reads and TacSL force-field reads. Require one ray-caster mount per environment before allocating ray output buffers; preserve heterogeneous target counts and padded target slots. - **Newton hard resets:** retain builder-owned sites, replace native IMU/frame-transform sensor objects with the model, and expand frame names from configuration on each initialization. Remove the duplicated target-name field. - **TacSL:** resolve the authored contact mesh and destination expression from clone sources, including custom namespaces, and require exactly one SDF mesh. - **cuRobo:** import the selected world's source geometry when its native copy has no USD prims. A temporary USD projection feeds the existing importer and is discarded after initialization; asset data supplies dynamic poses. Remove six private wrappers and duplicate pose-buffer fields. Newton keeps one sensor-site label, and PhysX allocates pose buffers directly in Warp. No new public configuration fields, production modules, or runtime resource owners. **Size:** production **+244 / −737** (net **−493**); whole PR **+801 / −910** (net **−109**), including regression coverage, documentation, and changelogs. No new test files. ## Related fixes and scope - Covers the exact body/environment mapping problems in #8678 and #8676 through the shared provider, with consolidated heterogeneous-link and native-clone regression scenes. - Incorporates the site/reset lifecycle fixes from #8674. - Includes the ray-caster and TacSL read paths from #8663, and the ray-caster mount validation from #8655. Their changes to other sensor families remain separate. Missing target meshes remain supported by padded slots. - The output reshapes proposed by #7034 are already corrected in this base. Its remaining stricter input-layout policy stays in that utility PR. - No unmerged PR dependency is required. Fixes #8677. Fixes #8675. Fixes #8673. ## Validation at `9db57d446` GPU0 / RTX 5090, **62 focused tests passed**: - PhysX ray-caster integration: 9; standard ray-caster graph tests: 5. - OVPhysX ray casters: 2, including 16 interleaved articulation environments and rejection of partial native mounts. - Newton ray casters: 8; site/index/lifecycle tests: 12, including three hard resets at both one and two environments with ray caster, IMU, PVA and frame transformer. - TacSL: 10, including custom clone namespaces and tactile points immediately after an articulation root write. - Ray-caster kernel and ownership gates: 16. The new pose-write, mount-count, tactile-write and hard-reset regressions fail on the previous head `338d3161` and pass with this change. The consolidated PhysX scene also rejects a deliberate mutation that lets `-1` slots consume a body transform: its missing-target ray incorrectly hits at 1 m instead of the static ground. A central existence/ownership audit checked all 13 changed production modules: the existing file tree is retained, old target-view hooks remain absent, leaf consumers do not rediscover the provider, and Newton STOP callbacks do not register sites again. `uv run isaaclab -f`, the changelog gate against `73f275291`, and `git diff --check` passed. Tests stay in the existing suites. Exact SDF-count assertions reject a broken-discovery mutation that passed the former loose assertion. The Newton reset and OV ray-caster cases honor the runtime GPU mask and passed on `cuda:1`. **Broader suite limitation from the expansion validation:** the broader Newton frame-transformer file has 1 passing case and 2 failures compiling MuJoCo Warp's tiled Cholesky kernel (`nvJitLink` error 6 / NVVM container error). The same two cases fail on unchanged `338d3161`, before this expansion; the focused hard-reset/name regression passes. These compiler failures remain visible rather than being skipped. The unchanged cuRobo implementation retains the previously recorded five native-Newton obstacle-planning cases and PhysX pick-and-stack validation. ## Simplification performance check Compared `3808d2361` → `9db57d446` on GPU0 / RTX 5090 at 1,024 environments and 441 rays per environment, with the same workload and sampling method recorded below. Three alternating fresh-process pairs measured median paired refresh / full-step changes of **−7.3% / −3.0% for PhysX** and **−3.2% / +0.2% for Newton**. PhysX varied between processes: refresh changes ranged from −17.8% to +17.4%, and full-step changes from −12.3% to +5.4%. One additional native-Newton control pair measured +0.6% / +0.3%. **All seven paired hit buffers matched bit-for-bit.** Training FPS was not measured. <details> <summary>Earlier performance measurements, startup costs, and pinned methodology</summary> ## Expansion performance check Compared `338d3161` → `3808d2361` on GPU0 / RTX 5090, using the same four-cube, 441-ray workload as below at 1,024 environments. Three fresh process pairs alternated revision order; each used 30 warm-up steps, 100 synchronized refresh samples, and five batches of 100 complete steps. These are **median paired changes**: - Newton, four targets: refresh **+0.6%**, full step **0.0%**. - OVPhysX, four targets: refresh **−2.6%**, full step **−2.8%**. - PhysX, four targets: refresh **−1.6%**, full step **+8.4%** in the short runs. - PhysX, one tracked target: refresh **−5.7%**, full step **+1.5%**. The short PhysX full-step increase did not persist at that size in a longer confirmation: three new alternating pairs, 200 warm-up steps, 500 refresh samples, and 20 batches of 500 complete steps measured median paired changes of **+0.5% refresh and +1.6% full step**. Full-step changes ranged from **−5.2% to +2.9%**. All 12 initial paired hit buffers and all three confirmation pairs matched bit-for-bit. These checks do not establish a new training/FPS claim. ## Original scene-binding performance **Four-target sensor refresh took 18–52% less time.** The full physics-and-sensor loop ranged from 16.5% less time to 0.7% more time. Startup did not uniformly improve: Newton at 1,024 environments added 0.26 s, and OVPhysX added 0.10–0.45 s. Before (`73f275291`) → PR (`c893dd599`), on GPU0 / RTX 5090. Lower is better. This is a synthetic ray-caster workload with four rigid cubes and one 441-ray grid per environment; task/training FPS was not measured. | Physics | Environments | Initialization (s) | Sensor refresh (ms) | Physics + sensor step (ms) | |---|---:|---:|---:|---:| | Newton MJWarp | 1,024 | 3.31 → 3.57 | 0.359 → 0.172 | 0.356 → 0.320 | | Newton MJWarp | 4,096 | 4.03 → 4.02 | 0.543 → 0.391 | 0.714 → 0.719 | | OVPhysX | 1,024 | 2.48 → 2.58 | 0.372 → 0.284 | 1.392 → 1.394 | | OVPhysX | 4,096 | 6.28 → 6.73 | 0.623 → 0.513 | 1.776 → 1.590 | | PhysX (Kit) | 1,024 | 1.75 → 1.72 | 0.471 → 0.328 | 1.186 → 0.990 | | PhysX (Kit) | 4,096 | 3.29 → 3.25 | 0.721 → 0.572 | 1.462 → 1.379 | The multi-target gain comes from replacing separate target views/updates with one gather. OVPhysX now initializes its shared body table when the ray caster first requests it, which adds startup work when no earlier consumer has created that table. The benefit depends on target count: the longer one-target PhysX / 4,096 check measured median paired changes of **+5.4% for refresh (about 0.020 ms) and +1.2% for the full loop**. <details> <summary>One-target and native ray-caster controls</summary> The one-target cases retain all four bodies in the scene but track only one. Native cases use Newton’s BVH ray caster, with and without its query CUDA graph. | Control | Environments | Sensor refresh (ms) | Physics + sensor step (ms) | |---|---:|---:|---:| | Newton native / query graph | 1,024 | 0.082 → 0.082 | 0.282 → 0.280 | | Newton native / query graph | 4,096 | 0.241 → 0.238 | 0.551 → 0.553 | | Newton MJWarp / one target | 1,024 | 0.157 → 0.123 | 0.272 → 0.266 | | Newton MJWarp / one target | 4,096 | 0.211 → 0.210 | 0.480 → 0.482 | | OVPhysX / one target | 1,024 | 0.219 → 0.226 | 1.323 → 1.343 | | OVPhysX / one target | 4,096 | 0.320 → 0.322 | 1.540 → 1.518 | | PhysX (Kit) / one target | 1,024 | 0.266 → 0.275 | 1.024 → 1.009 | | PhysX (Kit) / one target | 4,096 | 0.365 → 0.368 | 1.152 → 1.239 | | Newton native / eager query | 1,024 | 2.884 → 2.874 | 3.008 → 3.065 | | Newton native / eager query | 4,096 | 2.945 → 2.910 | 3.024 → 3.001 | The initial one-target PhysX / 4,096 loop median was 1.152 → 1.239 ms (+7.6%). A longer confirmation used three fresh pairs, 200 warm-up steps, 500 refresh samples, and 20 batches of 500 steps. Paired refresh changes ranged from −3.6% to +8.0% (median +5.4%); paired loop changes ranged from −5.4% to +1.6% (median +1.2%). The initial 7.6% full-loop slowdown did not persist. </details> **Method:** Median of three fresh processes per revision, alternating base/head order, with the same locked dependencies and warm caches. Each process used 30 warm-up steps, 100 GPU-synchronized sensor-refresh samples, and five batches of 100 physics + scene-update + sensor-read steps (dt=0.01 s, zero gravity, no rendering). Newton physics used CUDA graphs; multi-mesh reads were eager. Initialization covers simulation/scene construction, reset, and the first sensor read; launcher startup and deferred first-physics-step graph capture are excluded. All 48 measured before/after hit-buffer pairs, plus the three longer confirmation pairs, matched bit-for-bit. **Additional consumer initialization:** in the existing PhysX cube-stack fixture, cuRobo collision-world import took **4.94 → 42.67 ms** (median of five alternating warm samples, GPU-synchronized). All three obstacle geometries and poses matched. The temporary source projection adds about **38 ms once per planner**; it adds no per-step work. This is import time, not full planner startup or training FPS. The original ray-caster measurements above are pinned to `c893dd599`. </details> ## Type of change - Bug fixes and internal refactoring; existing supported configurations retain their fields and construction API. ## Checklist - [x] Read the contribution guidelines. - [x] Ran formatting and changelog checks. - [x] Extended or consolidated existing regressions using the test-audit criteria. - [x] Audited the production file tree and ownership boundaries. - [x] Recorded numerical/performance evidence and the pre-existing compiler limitation.
|
Superseded by #8765, which binds each tracked mesh to its exact body path; this PR's test (same, fewer and reordered links) passes on main, so I'm closing this. |
Description
A tracked multi-mesh target with several bodies per environment, such as the links of a robot, is read on PhysX
through one rigid-body view over one pattern per body. PhysX lists such a view one pattern after another, but the
copy into the per-environment mesh table read it environment by environment, so most meshes were placed at other
environments' body poses (#8677). This affects the documented
MultiMeshRayCasterexample and the Kuka-Allegrolift
raycaster_depth*camera presets.This PR records the prim path of the tracked body of each mesh-table entry while the table is built, from the clone
plan or, without one, from the stage. At initialization, each entry is matched to the view row with that prim path,
and the copy then reads each entry from its own row, whatever the order of the patterns in the view and of the
bodies in each prototype. A single body is still shared by all environments. Table entries without a matching view
row, such as the padding of environments with fewer tracked bodies than others (heterogeneous prototypes), keep
their placeholder poses instead of other environments' poses.
Fixes #8677
Type of change
Release backport
developrelease/3.0.0has the same PhysXray_caster.pyandsensors/kernels.py,base_multi_mesh_ray_caster.pyand testfile; the new test fails there without the fix and passes with it.
Screenshots
Not applicable.
Tests
test_multi_mesh_tracks_articulation_links_per_envinsource/isaaclab/test/sensors/test_ray_caster_integration.py: three environments, each with a fixed-basearticulation whose links
link_a(a 0.1 m cube) andlink_b(a 0.2 m cube, so that the hit height tells the twoapart) are scanned by one downward ray each, tracked as
{ENV_REGEX_NS}/Chain/link_[^/]*; every hit is compared,unmasked, with the top of its own link. Environment 1 is its own prototype, with the same links, without
link_b,or with
link_bauthored beforelink_a. Ondevelop, the three cases fail with 4, 2 and 4 of the 6 rays wrong.source/isaaclab/test/sensors/test_ray_caster_integration.py(9),source/isaaclab/test/sensors/test_multi_mesh_ray_caster.py(5),source/isaaclab/test/sensors/test_multi_mesh_ray_caster_camera.py(7, including the heterogeneous Spot/ANYmalscene),
source/isaaclab/test/sensors/test_ray_caster_camera.py(10),source/isaaclab/test/sensors/test_ray_caster_sensor.py(4) andsource/isaaclab_physx/test/sensors/test_ray_caster_graph.py(5).raycaster_depth64base camera (four identical environments, targetsreduced to the ground plane and the tracked robot links), each environment's robot slots hold its own eight links,
and the robot covers 322 of the 4096 pixels in every environment, instead of 64, 194, 225 and 0 on
develop.pre-commit run --files), as dotools/changelog/cli.py checkandgit diff --check.Related
function and appends a test to the same test file, in other hunks; the two merge without conflicts.
Checklist
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