Skip to content

Deduplicate ovphysx contact-sensor bodies from mid-path wildcards - #7526

Open
diegoferigo-rai wants to merge 1 commit into
isaac-sim:developfrom
diegoferigo-rai:diegoferigo/ovphysx-contact-sensor-dedup
Open

Deduplicate ovphysx contact-sensor bodies from mid-path wildcards#7526
diegoferigo-rai wants to merge 1 commit into
isaac-sim:developfrom
diegoferigo-rai:diegoferigo/ovphysx-contact-sensor-dedup

Conversation

@diegoferigo-rai

Copy link
Copy Markdown

Description

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 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 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.

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 single left_knee leaf through a Robot/.*/left_knee wildcard, asserting the body is registered exactly once (it fails without the fix with RuntimeError: Failed to initialize contact binding and passes with it).

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Release backport

  • Backport this pull request to the active release branch after it merges into develop

Screenshots

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-ci on the pull request.

  • I have read and understood the contribution guidelines
  • I have run the pre-commit checks with ./isaaclab.sh --format
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • 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)
  • I have added my name to the CONTRIBUTORS.md or my name already exists there

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.
@diegoferigo-rai
diegoferigo-rai requested a review from a team September 3, 2026 08:40
@github-actions github-actions Bot added the isaac-lab Related to Isaac Lab team label Sep 3, 2026

@isaaclab-review-bot isaaclab-review-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-apps

greptile-apps Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes duplicate OVPhysX contact-sensor body discovery for mid-path wildcards by preserving only the first match for each USD prim path.

  • Deduplicates resolved contact bodies before sensor patterns and counts are constructed.
  • Adds CPU and CUDA regression coverage for nested bodies across one and multiple cloned environments.
  • Documents the correction in an isaaclab_ov changelog fragment.

Confidence Score: 5/5

The 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

Filename Overview
source/isaaclab_ov/isaaclab_ov/sensors/contact_sensor/contact_sensor.py Deduplicates repeated resolver results by unique USD prim path while preserving traversal order and the valid first expression.
source/isaaclab_ov/test/sensors/test_contact_sensor.py Adds focused regression coverage proving a nested wildcard leaf produces one sensor and the expected batched force shape.
source/isaaclab_ov/changelog.d/ovphysx-contact-sensor-dedup.rst Accurately documents the duplicate-discovery failure and its correction.

Reviews (1): Last reviewed commit: "Deduplicate ovphysx contact-sensor bodie..." | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

isaac-lab Related to Isaac Lab team

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

4 participants