Skip to content

[Bug Report] PhysX GPU contact sensor keeps reporting the last in-contact force after contact is lost when history_length=0 and data is read lazily #7613

Closed

Description

@AntoineRichard

Describe the bug

On the PhysX backend on GPU, a ContactSensor with the default history_length=0 and the default InteractiveSceneCfg.lazy_sensor_update=True keeps reporting the last in-contact force after the body has left contact, indefinitely, whenever its data is read less often than every physics step (for example once per policy step with decimation=4).

Root cause (verified). RigidContactView.get_net_contact_forces() on GPU zeroes a body's entry only on the exact physics step where that body's contact is lost. If the getter is not called on that step, the entry is never zeroed and keeps the last in-contact value until the next touchdown. With history_length=0 the sensor only calls the getter when .data is accessed, so a policy-rate reader skips most contact-lost steps.

The Isaac Lab side is not at fault: the raw getter output, the cached Warp view over it, and the sensor's net_forces_w agree at every read, and disabling the CUDA-graph replay (_use_graph = False) changes nothing. CPU is not affected. history_length > 0 is not affected because BaseContactSensor.update() then refreshes (and therefore calls the getter) on every physics step.

Experiments (cube settled on flat terrain, then held in the air; sim_dt = 0.0025, data read once per 4 physics steps, cuda:0):

getter call cadence force reported in the air
only on data access (every 4th step) 1226 N, stuck for all subsequent steps
every physics step 0.0
once on the exact lift-off step, then every 4th step 0.0
once one step after lift-off, then every 4th step 1226 N, stuck

Teleporting the body is not the trigger: a single teleport into the air followed by free fall sticks as well.

Steps to reproduce

Minimal pytest reproduction, built on the scaffolding of source/isaaclab_physx/test/sensors/test_contact_sensor.py (place it next to that file):

import torch
import warp as wp
from test_contact_sensor import CUBE_CFG, FLAT_TERRAIN_CFG, ContactSensorSceneCfg, _perform_sim_step

from isaaclab.scene import InteractiveScene
from isaaclab.sensors import ContactSensorCfg
from isaaclab.sim import build_simulation_context

SIM_DT = 0.0025


def test_lazy_sensor_reports_contact_loss():
    with build_simulation_context(device="cuda:0", dt=SIM_DT, add_lighting=True) as sim:
        sim._app_control_on_stop_handle = None
        scene_cfg = ContactSensorSceneCfg(num_envs=1, env_spacing=1.0, lazy_sensor_update=True)
        scene_cfg.terrain = FLAT_TERRAIN_CFG
        scene_cfg.shape = CUBE_CFG
        scene_cfg.contact_sensor = ContactSensorCfg(
            prim_path=CUBE_CFG.prim_path, track_pose=True, update_period=0.0, track_air_time=True, history_length=0
        )
        scene = InteractiveScene(scene_cfg)
        sim.reset()
        sensor, shape = scene["contact_sensor"], scene["shape"]
        contact_pose = CUBE_CFG.contact_pose.to(device=shape.device).unsqueeze(0)
        air_pose = CUBE_CFG.non_contact_pose.to(device=shape.device).unsqueeze(0)

        trace = []
        for tag, pose in (("contact", contact_pose), ("air", air_pose)):
            for _ in range(6):
                for _ in range(4):  # policy step of 4 physics steps, data untouched in between
                    shape.write_root_pose_to_sim_index(root_pose=pose)
                    _perform_sim_step(sim, scene, SIM_DT)
                trace.append((tag, round(torch.norm(sensor.data.net_forces_w.torch, dim=-1).max().item(), 1)))
        print(trace)
        assert max(f for tag, f in trace[7:] if tag == "air") < 0.1, trace

Output on cuda:0:

[('contact', 613.7), ('contact', 1226.5), ('contact', 1226.3), ('contact', 1226.2), ('contact', 1226.2), ('contact', 1226.2),
 ('air', 1226.2), ('air', 1226.2), ('air', 1226.2), ('air', 1226.2), ('air', 1226.2), ('air', 1226.2)]

Passes on cpu, and passes on cuda:0 with history_length=1 or with the data read every physics step.

System Info

  • Commit: 3fbbd15 (develop, 2026-09-04)
  • Isaac Sim 6.0.1, PhysX backend (isaaclab_physx)
  • OS: Ubuntu 22.04, RTX 5090 D, CUDA 12.9, driver 580

Additional context

Exposure. Every shipped velocity task sets history_length=3 and is unaffected. The Kuka Allegro and Franka lift tasks configure fingertip contact sensors with the default history_length=0 and feed normal_force_matrix_w into observations, so on PhysX GPU those observations can hold a stale contact force after the finger releases the object. Any user config with the defaults is exposed.

Fix direction. The PhysX contact sensor should call its (cheap, eager, non-capturable) PhysX getters on every physics step inside update() regardless of history_length; the Warp kernels that consume the fetched buffers can stay lazy. OVPhysX wraps the same tensor API and probably needs the same treatment, but has not been checked. Newton is not affected.

Found while working on #7283 / #7574.

Checklist

  • I have checked that there is no similar issue in the repo (required)
  • I have checked that the issue is not in running Isaac Sim itself and is related to the repo

Activity

  1. StafaH commented on Sep 24, 2026

    @StafaH
    Collaborator

    The following issue is now fixed on develop and release 3.0, it was fixed by #7614 and #7416.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions