Skip to content

Commit 7e8ebe6

Browse files
Fixes contact threshold when activating contact sensor (#3498)
# Description We were incorrectly passing in the activate contact sensor boolean as the threshold when setting up the contact sensor API, which caused the sensor threshold to always be 1 when the sensor is activated. The desired behavior should be defaulting to 0 threshold. ## Type of change - Bug fix (non-breaking change which fixes an issue) - Breaking change (existing functionality will not work without user modification) ## Checklist - [x] I have read and understood the [contribution guidelines](https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html) - [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with `./isaaclab.sh --format` - [x] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [ ] I have updated the changelog and the corresponding version in the extension's `config/extension.toml` file - [ ] I have added my name to the `CONTRIBUTORS.md` or my name already exists there <!-- As you go through the checklist above, you can mark something as done by putting an x character in it For example, - [x] I have done this task - [ ] I have not done this task --> --------- Signed-off-by: Mayank Mittal <[email protected]> Signed-off-by: Kelly Guo <[email protected]> Co-authored-by: Mayank Mittal <[email protected]>
1 parent 23e935c commit 7e8ebe6

File tree

4 files changed

+65
-4
lines changed

4 files changed

+65
-4
lines changed

source/isaaclab/config/extension.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22

33
# Note: Semantic Versioning is used: https://semver.org/
4-
version = "0.47.11"
4+
version = "0.48.0"
55

66
# Description
77
title = "Isaac Lab framework for Robot Learning"

source/isaaclab/docs/CHANGELOG.rst

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
11
Changelog
22
---------
33

4+
0.48.0 (2025-11-03)
5+
~~~~~~~~~~~~~~~~~~~
6+
7+
Changed
8+
^^^^^^^
9+
10+
* Detected contacts are reported with the threshold of 0.0 (instead of 1.0). This increases the sensitivity of contact
11+
detection.
12+
13+
Fixed
14+
^^^^^
15+
16+
* Removed passing the boolean flag to :meth:`isaaclab.sim.schemas.activate_contact_sensors` when activating contact
17+
sensors. This was incorrectly modifying the threshold attribute to 1.0 when contact sensors were activated.
18+
19+
420
0.47.11 (2025-11-03)
521
~~~~~~~~~~~~~~~~~~~~
622

@@ -95,8 +111,8 @@ Changed
95111
0.47.3 (2025-10-22)
96112
~~~~~~~~~~~~~~~~~~~
97113

98-
Changed
99-
^^^^^^^
114+
Fixed
115+
^^^^^
100116

101117
* Fixed the data type conversion in :class:`~isaaclab.sensors.tiled_camera.TiledCamera` to
102118
support the correct data type when converting from numpy arrays to warp arrays on the CPU.

source/isaaclab/isaaclab/sim/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ def wrapper(prim_path: str | Sdf.Path, cfg: SpawnerCfg, *args, **kwargs):
288288
sem.GetSemanticDataAttr().Set(semantic_value)
289289
# activate rigid body contact sensors
290290
if hasattr(cfg, "activate_contact_sensors") and cfg.activate_contact_sensors:
291-
schemas.activate_contact_sensors(prim_paths[0], cfg.activate_contact_sensors)
291+
schemas.activate_contact_sensors(prim_paths[0])
292292
# clone asset using cloner API
293293
if len(prim_paths) > 1:
294294
cloner = Cloner(stage=stage)

source/isaaclab/test/sensors/test_contact_sensor.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import carb
2222
import pytest
2323
from flaky import flaky
24+
from pxr import PhysxSchema
2425

2526
import isaaclab.sim as sim_utils
2627
from isaaclab.assets import RigidObject, RigidObjectCfg
@@ -395,6 +396,50 @@ def test_sensor_print(setup_simulation):
395396
print(scene.sensors["contact_sensor"])
396397

397398

399+
@pytest.mark.parametrize("device", ["cuda:0", "cpu"])
400+
def test_contact_sensor_threshold(setup_simulation, device):
401+
"""Test that the contact sensor USD threshold attribute is set to 0.0."""
402+
sim_dt, durations, terrains, devices, carb_settings_iface = setup_simulation
403+
with build_simulation_context(device=device, dt=sim_dt, add_lighting=False) as sim:
404+
sim._app_control_on_stop_handle = None
405+
# Spawn things into stage
406+
scene_cfg = ContactSensorSceneCfg(num_envs=1, env_spacing=1.0, lazy_sensor_update=False)
407+
scene_cfg.terrain = FLAT_TERRAIN_CFG.replace(prim_path="/World/ground")
408+
scene_cfg.shape = CUBE_CFG
409+
scene_cfg.contact_sensor = ContactSensorCfg(
410+
prim_path=scene_cfg.shape.prim_path,
411+
track_pose=True,
412+
debug_vis=False,
413+
update_period=0.0,
414+
track_air_time=True,
415+
history_length=3,
416+
)
417+
scene = InteractiveScene(scene_cfg)
418+
# Play the simulator
419+
sim.reset()
420+
421+
# Get the stage and check the USD threshold attribute on the rigid body prim
422+
from isaacsim.core.utils.stage import get_current_stage
423+
424+
stage = get_current_stage()
425+
prim_path = scene_cfg.shape.prim_path
426+
prim = stage.GetPrimAtPath(prim_path)
427+
428+
# Ensure the contact sensor was created properly
429+
contact_sensor = scene["contact_sensor"]
430+
assert contact_sensor is not None, "Contact sensor was not created"
431+
432+
# Check if the prim has contact report API and verify threshold is close to 0.0
433+
if prim.HasAPI(PhysxSchema.PhysxContactReportAPI):
434+
cr_api = PhysxSchema.PhysxContactReportAPI.Get(stage, prim.GetPrimPath())
435+
threshold_attr = cr_api.GetThresholdAttr()
436+
if threshold_attr.IsValid():
437+
threshold_value = threshold_attr.Get()
438+
assert (
439+
pytest.approx(threshold_value, abs=1e-6) == 0.0
440+
), f"Expected USD threshold to be close to 0.0, but got {threshold_value}"
441+
442+
398443
"""
399444
Internal helpers.
400445
"""

0 commit comments

Comments
 (0)