Repository navigation
Fix duplicate source-prim resolution for overlapping wildcard subtrees - #7526
Conversation
There was a problem hiding this comment.
Isaac Lab Review Bot
The change deduplicates OVPhysX contact-sensor discovery results by concrete prim path while preserving first-match order. It directly addresses duplicate leaf registration from mid-path wildcards and includes focused regression coverage plus the required package changelog fragment.
- Design and architecture: Deduplication occurs at the discovery boundary before body names, sensor counts, sensor patterns, and filter patterns are derived. This keeps all downstream consumers consistent and limits the change to the OVPhysX contact-sensor path without affecting the classic backend.
- API: No public symbols or configuration fields change. The observable correction is that num_sensors, body_names, and force-buffer dimensions now represent unique resolved bodies for mid-path wildcard expressions. Existing ordering is preserved by retaining the first occurrence, and the behavior change is documented in the isaaclab_ov changelog.
- Implementation: The implementation keys uniqueness on prim.GetPath().pathString and retains the corresponding expression used to construct each sensor glob. The regression test exercises one and multiple cloned environments on CPU and CUDA, checking the unique sensor count, body name, initialization path, and resulting force-buffer shape. The broad object annotation for the retained prim is less precise than the concrete USD type but does not create a material correctness or API issue.
No blocking issues. No inline issue met the actionable-evidence threshold; the assessment above records the review feedback.
Automated review; human maintainers own approval decisions.
Greptile SummaryThis PR fixes duplicate OVPhysX contact-sensor body discovery for mid-path wildcards by preserving only the first match for each USD prim path.
Confidence Score: 5/5The PR appears safe to merge, with no actionable correctness, security, or maintainability issues identified. The deduplication collapses only repeated references to the same uniquely identified USD prim, preserves the valid traversal order, and is covered across CPU, CUDA, and cloned-environment configurations. Important Files Changed
Reviews (1): Last reviewed commit: "Deduplicate ovphysx contact-sensor bodie..." | Re-trigger Greptile |
The isaaclab_ov ContactSensor discovers bodies with resolve_matching_prims_from_source, which matches every ancestor in phase one and then collects the leaf as a descendant of each match in phase two. With a mid-path wildcard prim path (for example Robot/.*/left_ankle_roll_link) the same ankle body is returned once per link in the chain, with no dedup by prim identity. That inflates the sensor and filter counts and makes the physics-cloned init guard sensor_count % num_sensors fire, breaking any reward reading a self-collision force off the sensor. The classic isaaclab.sensors.contact_sensor does not resolve discovery this way and is unaffected. Deduplicate the resolved matches by prim path before they are consumed, the minimal fix that keeps the natural mid-path wildcard prim path working on both the Newton and the ovphysx backends. Add a regression test that authors a nested link chain and resolves a single leaf through a mid-path wildcard, asserting the body is registered exactly once.
e15647d to
2f05dc0
Compare
|
I rebased this PR onto the latest |
|
run-ci |
#7526) # Description Nested body paths such as `Robot/.*/left_knee` can resolve the same physical body several times. This inflates the OVPhysX contact sensor's per-environment body count: one environment fails initialization, while three environments can pass the divisibility guard with an incorrect body count. The shared resolver now returns each source prim once before validating `expected_num_matches`. It preserves first-match order, the first destination expression, and distinct bodies with the same leaf name. Assets and sensors consume that guarantee directly; no contact-sensor-specific deduplication is needed. ## Root cause #6841 made prim queries consistently use whole-path regular expressions. This correctly allows `.*` to cross `/`, but `resolve_matching_prims_from_source` still concatenated descendant results as though its matched roots were disjoint. For `Robot/pelvis/left_hip/left_knee`, the contact sensor resolves the parent expression `Robot/.*` and filters descendants named `left_knee`. The matching roots include `pelvis`, `left_hip`, and `left_knee` itself. Expanding all three produces the same leaf three times. Flat hierarchies and expressions selecting disjoint roots do not expose that assumption. The resolver owns this correction because other callers, including articulation discovery, validate match counts there. Fixing only the contact sensor leaves those callers exposed. The existing resolver test checked regex discovery without descendant filtering; it now exercises the composition with and without a clone plan. ## Validation - Before the shared fix, both resolver cases fail with `Expected 2 prims ... found 4`, even with the original sensor-local patch present. - With the sensor-local patch removed and the shared resolver still unfixed, the consolidated contact test reproduces the CPU initialization failure with one environment and the incorrect CUDA body count with three environments. - After the shared fix: 19 cloner tests, 11 query tests, and 4 nested-contact cases pass (34 total). - The contact regression extends the existing nested-hierarchy test, sharing scene setup and retaining CPU/CUDA binding coverage, single/cloned environments, body names, counts, and force-buffer shapes. - `uv run isaaclab -f` and the package changelog gate pass. Documentation builds are left to CI. ## 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` ## 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 formatting and lint checks with `uv run isaaclab -f` - [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 --------- Co-authored-by: Kelly Guo <[email protected]> Co-authored-by: Octi Zhang <[email protected]> (cherry picked from commit c59f95d)
|
Backported to |
|
run-ci |
Description
Nested body paths such as
Robot/.*/left_kneecan resolve the same physical body several times. This inflates the OVPhysX contact sensor's per-environment body count: one environment fails initialization, while three environments can pass the divisibility guard with an incorrect body count.The shared resolver now returns each source prim once before validating
expected_num_matches. It preserves first-match order, the first destination expression, and distinct bodies with the same leaf name. Assets and sensors consume that guarantee directly; no contact-sensor-specific deduplication is needed.Root cause
#6841 made prim queries consistently use whole-path regular expressions. This correctly allows
.*to cross/, butresolve_matching_prims_from_sourcestill concatenated descendant results as though its matched roots were disjoint.For
Robot/pelvis/left_hip/left_knee, the contact sensor resolves the parent expressionRobot/.*and filters descendants namedleft_knee. The matching roots includepelvis,left_hip, andleft_kneeitself. Expanding all three produces the same leaf three times. Flat hierarchies and expressions selecting disjoint roots do not expose that assumption.The resolver owns this correction because other callers, including articulation discovery, validate match counts there. Fixing only the contact sensor leaves those callers exposed. The existing resolver test checked regex discovery without descendant filtering; it now exercises the composition with and without a clone plan.
Validation
Expected 2 prims ... found 4, even with the original sensor-local patch present.uv run isaaclab -fand the package changelog gate pass. Documentation builds are left to CI.Type 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.uv run isaaclab -fsource/<pkg>/changelog.d/for every touched package (do not editCHANGELOG.rstor bumpextension.toml— CI handles that)CONTRIBUTORS.mdor my name already exists there