Skip to content

Fix stale OVPhysX and PhysX contact sensor data after reset - #8608

Merged
hujc7 merged 2 commits into
isaac-sim:developfrom
NeoZng:fix/contact-sensor-stale-after-reset
Oct 17, 2026
Merged

hujc7 merged 2 commits into
isaac-sim:developfrom
NeoZng:fix/contact-sensor-stale-after-reset

Conversation

@NeoZng

@NeoZng NeoZng commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Description

Reading ContactSensor data after scene.reset(env_ids) and before the next physics step, as the observation right
after ManagerBasedRLEnv._reset_idx does, refilled the reset environments from the pre-reset contact buffers on the
paths #5782 did not guard:

  • OVPhysX: update_net_forces_ovphysx_kernel received the timestamp but never checked it, and
    unpack_contact_buffer_data had none, so forces, force histories and contact points came from the previous episode.
  • Isaac Sim PhysX: unpack_contact_buffer_data was not guarded, so contact points and, on Isaac Sim 6.1, the filtered
    friction forces and their history came from the previous episode.

These kernels now also skip environments whose timestamp is 0, so the reset values (zero forces and histories, NaN
contact points) stay until the sensor's next update. The PhysX kernel stays in the captured CUDA graph: the timestamp is
the sensor's device array.

Fixes #8607

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

Repro script from the issue, env 0 read right after scene.reset(env_ids) (Isaac Sim 6.1, OVPhysX 0.6.4):

Backend Before After
Isaac Sim PhysX friction 4.906 N, friction history [4.906, 0, 0], contact point (-0.107, 0, 0) 0 N, [0, 0, 0], NaN
OVPhysX normal 9.793 N, friction 4.895 N, friction history [4.896, 0, 0], contact point (-0.102, 0.001, 0) 0 N, 0 N, [0, 0, 0], NaN

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 uv run isaaclab --format
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have validated the changed behavior with focused coverage and applied the test-audit criteria to any test changes
  • 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)
  • I have added my name to the CONTRIBUTORS.md or my name already exists there

Tests

The existing reset tests of both backends now cover the missed buffers (Isaac Sim 6.1, OVPhysX 0.6.4):

  • isaaclab_physx/test/sensors/test_contact_sensor.py::test_contact_sensor_no_stale_data_after_reset slides the cube
    and also tracks contact points and filtered friction. It fails on develop (stale contact point) and passes with the
    fix on cuda:0, where the read replays the captured graph, and on cpu.
  • isaaclab_ov/test/sensors/test_contact_sensor.py::test_friction_reporting reads data after its partial reset, as
    an observation does. It fails on develop in all four cases and passes with the fix.
  • isaaclab_ov/test/sensors/test_contact_sensor_kernels.py passes the new timestamp argument.

With the fix: PhysX test_contact_sensor.py 23 passed, 1 skipped (needs Isaac Sim 6.2); OVPhysX
test_contact_sensor.py 36 passed; test_contact_sensor_kernels.py 2 passed.

Reading ContactSensor data after scene.reset(env_ids) and before the next
physics step, as the observation after ManagerBasedRLEnv._reset_idx does,
refilled the reset envs from the pre-reset contact buffers on two paths
that isaac-sim#5782 did not guard:

- OVPhysX: update_net_forces_ovphysx_kernel received the timestamp but
  never checked it, and unpack_contact_buffer_data had none, so forces,
  force histories and contact points came from the previous episode.
- PhysX: unpack_contact_buffer_data was not guarded, so contact points
  and, on Isaac Sim 6.1, the filtered friction forces and their history
  came from the previous episode.

Skip envs whose timestamp is 0 in these kernels too, so they keep their
reset values until the sensor's next update. The PhysX kernel stays in
the captured CUDA graph: the timestamp is the sensor's device array.
@NeoZng
NeoZng requested a review from a team October 15, 2026 16:23
@github-actions github-actions Bot added bug Something isn't working isaac-lab Related to Isaac Lab team labels Oct 15, 2026
@greptile-apps

greptile-apps Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Prevents contact sensors from copying pre-reset physics data back into reset environments.

  • OVPhysX contact readings keep reset values until the next step.
  • PhysX contact readings keep reset values until the next step.

No actionable issues found. Simulation tests were not run during this review.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["Reset selected environments"] --> B["Clear forces and histories; set contact points to NaN"]
    B --> C["Read sensor data"]
    C --> D{"Environment timestamp is zero?"}
    D -- Yes --> E["Keep reset values"]
    D -- No --> F["Copy current physics contact data"]
    E --> G["Physics step and sensor update advance timestamp"]
    G --> C
Loading

Reviews (1) · Last reviewed commit: "Fix stale OVPhysX and PhysX contact sens..." · Reviewed by Greptile

@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

All reviewed code categories look good.

  • PR description: The body accurately matches the changed kernels, affected buffers, backend differences, CUDA graph constraint, test scope, and reported baseline-versus-fix validation.
  • Design and architecture: Architecture looks good.
  • Scope and over-engineering: No over-engineering issues.
  • API: API changes look good.
  • Compatibility and deprecation: No breaking changes identified.
  • Implementation: Implementation looks good.
  • Style consistency: Style consistency looks good.
  • Test quality: Test quality looks good.

No blocking issues. No inline findings.

Automated review; human maintainers own approval decisions.

@AntoineRichard AntoineRichard left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the fix @NeoZng!

@AntoineRichard

Copy link
Copy Markdown
Collaborator

run-ci

@isaaclab-bot isaaclab-bot Bot added ci:run-docker Trigger the on-demand Docker and GPU CI workflow and removed ci:run-docker Trigger the on-demand Docker and GPU CI workflow labels Oct 16, 2026
@hujc7

hujc7 commented Oct 17, 2026

Copy link
Copy Markdown
Collaborator

run-ci

@isaaclab-bot isaaclab-bot Bot added ci:run-docker Trigger the on-demand Docker and GPU CI workflow and removed ci:run-docker Trigger the on-demand Docker and GPU CI workflow labels Oct 17, 2026
@hujc7
hujc7 enabled auto-merge (squash) October 17, 2026 07:47
@hujc7
hujc7 merged commit 0ab97e9 into isaac-sim:develop Oct 17, 2026
59 checks passed
@NeoZng
NeoZng deleted the fix/contact-sensor-stale-after-reset branch November 3, 2026 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug Report] OVPhysX and Isaac Sim PhysX ContactSensor return pre-reset contact data right after a reset

4 participants