Deduplicate ovphysx contact-sensor bodies from mid-path wildcards - #7526
Deduplicate ovphysx contact-sensor bodies from mid-path wildcards#7526diegoferigo-rai wants to merge 1 commit into
Conversation
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.
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 |
Description
The
isaaclab_ovContactSensordiscovers bodies withresolve_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 exampleRobot/.*/left_ankle_roll_link) the same leaf body is returned once per matching ancestor, with no dedup by prim identity. That inflates the sensor and filter counts and makes the physics-cloned init guardsensor_count % num_sensorsfire, breaking any reward reading a self-collision force off the sensor. The classicisaaclab.sensors.contact_sensordoes not resolve discovery this way and is unaffected.The fix deduplicates the resolved matches by prim path before they are consumed — the minimal change that keeps the natural mid-path wildcard prim path working on both the Newton and the ovphysx backends. A regression test authors a nested link chain (
pelvis/left_hip/left_knee) and resolves the singleleft_kneeleaf through aRobot/.*/left_kneewildcard, asserting the body is registered exactly once (it fails without the fix withRuntimeError: Failed to initialize contact bindingand passes with it).Type of change
Release backport
developScreenshots
N/A — this is a body-count bug, not a visual change. The evidence is behavioral (regression test).
Checklist
Docker and GPU tests run on demand. Push the commits you want tested, then
comment
run-cion the pull request.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