Wrong contact information being returned by contact sensor interface - false positives and incorrect primitives

Isaac Sim Version

X 5.0.0
4.5.0
4.2.0
4.1.0
4.0.0
4.5.0
2023.1.1
2023.1.0-hotfix.1
Other (please specify):

Operating System

X Ubuntu 22.04
Ubuntu 20.04
Windows 11
Windows 10
Other (please specify):

GPU Information

  • Model: Ada 4000

Topic Description

I am working on a project where I have mounted a contact sensor on the gripper body of a robotic system. I am trying to segment the gripper and any bodies in contact using the contact sensor interface. After getting the contact sensor raw data using get_contact_sensor_raw_data(…), I can iterate over the raw contact data and extract then contact for “body1” (which I assume is always the antagonistic contact body). This comes in an integer numeric code which can be decoded into its primitive path using decode_body_name(…). I am writing this string to a new USD attribute which I have created and am recording it in real-time using the USD Stage Recorder extension to replay this as an baked animation. This all works fine until I try to segment the primitive contact primitives using the written string where I have noticed that sometimes, not always, the wrong primitive is being detected as in contact.

To debug I have created a function which collects all prims from all contact sensors mounted on my grippers to turn bright neon pink and as you can see from the screenshots the correct gripper primitive is being highlighted however the target object is most of the time the incorrect one. After playing around with it I have noticed that it seems to be some sort of sticking behavior where after interacting with a certain primitive the contact sensor will continue to return that same contact even after moving away from it. The only way to prevent this is by setting a non-zero lower threshold for the sensor, however I still get the problem of when contacting other objects the previous prim path is still returned.

I have included screenshots showing how with a lower threshold contacts are correctly being detected however more often than not it is with the wrong primitive. The only time the contact sensor works correctly is in the beginning of the simulation until, seemingly at random, the contact sensor will stick to a primitive and will continue detecting contact even when touching another object. This behavior is worse still if the threshold is left at zero where the sticking will continue even if the gripper is nowhere near another object as shown in the lower set of screenshots.

I hope this report is descriptive enough and the developers can promptly address this unorthodox behavior.

Screenshots or Videos

Contact sticking behavior with lower threshold 1e-6:

Correct contact

Then sticking (not touching base just peg)

Contact sticking with lower threshold = 0

Correct initial contact

then sticking …

Thank you for the detailed write-up and the screenshots – they make the problem clear.

There are two things going on here, one by design and one a real usability rough edge.


Why the sensor “sticks” to a primitive (by design)

The Contact Sensor API deliberately provides persistent contact data, continuing to report the last known contact even after PhysX stops streaming contact events for that pair. From the docs:

“The Contact Sensor API also provides persistent contact data, even when the PhysX engine stops streaming contacts to preserve compute time.”
– Isaac Sim Contact Sensor documentation

PhysX optimizes by not re-reporting contact pairs every step if the geometry hasn’t changed – it only fires events on contact begin/end. When the gripper lifts away slowly, or when contact force drops below the threshold, the Contact Sensor can hold onto the last reported body1 path until a discrete “contact lost” event arrives. This is intentional behavior to smooth out sensor readings (like a real pressure cell that holds its last value briefly), but it produces exactly the “sticking” you observed.

The fix: rather than reading the most recent body1 from the raw data and treating it as the current contact body, filter contacts by checking whether a contact event is active in the current physics step (use the time field in each raw contact record and compare it to the current simulation time). Contacts that were last updated more than one or two physics steps ago are stale carry-overs.

import omni.timeline

def get_active_contacts(sensor, tolerance_steps=2):
    """Return only contacts that are fresh (updated within the last N physics steps)."""
    current_time = omni.timeline.get_timeline_interface().get_current_time()
    physics_dt = 1.0 / 60.0  # or read from your physics scene
    raw = sensor.get_current_frame().get("contacts", [])
    active = []
    for c in raw:
        age_steps = (current_time - c["time"]) / physics_dt
        if age_steps <= tolerance_steps:
            active.append(c)
    return active

The time field in each raw contact record is the simulation time at which that contact was last reported by PhysX. Filtering on it gives you the equivalent of checking for a live contact event.


API deprecation note for Isaac Sim 5.0+ users

The get_contact_sensor_raw_data() / decode_body_name() pattern from the older omni.isaac.sensor extension is deprecated as of Isaac Sim 6.0. The current extension is isaacsim.sensors.experimental.physics, which exposes the same underlying data through ContactSensor.get_raw_data() and converts body integer IDs to USD paths via PhysicsSchemaTools.intToSdfPath() internally. The deprecated extension is still present in 5.x but the new API resolves body paths more reliably.

If you have an opportunity to migrate to Isaac Sim 6.x, the new API is:

from isaacsim.sensors.experimental.physics import Contact, ContactSensor

sensor = ContactSensor(
    Contact.create(
        "/World/gripper/contact_sensor",
        min_threshold=1e-6,   # set a small non-zero threshold
        max_threshold=1e6,
        radius=-1,
    )
)

sensor.add_raw_contact_data_to_frame()

# In your step callback:
frame = sensor.get_data()
for contact in frame.get("contacts", []):
    print(contact["body0"], contact["body1"])

Practical recommendations

  1. Set a non-zero min_threshold (you already found this helps) – it prevents contacts below the noise floor from being treated as valid touch events.
  2. Filter by contact time as shown above to discard carry-over contacts from prior touches.
  3. Do not rely on body1 always being the “antagonist” – the assignment of body0/body1 is determined by PhysX contact pair ordering, which is not guaranteed to be consistent across steps or configurations. Check both body0 and body1 against your known gripper path to identify which is the gripper and which is the target.

If the sticking persists even after filtering by contact time and with a non-zero threshold, please create a new topic referencing this one and share a minimal scene file – it would help narrow down whether there is an additional issue with the contact report API on the specific geometry involved.

Hope this helps clarify what is happening. Let us know how it goes.