Problem of Contact Sensor without contact

I am now learning to use Contact Sensor from “from omni.isaac.sensor import ContactSensor”. However, I find a weird situation that even though there is no “actual” contact, the data from contact sensor still get updated like this:

2024-01-07 19:28:12  [Info] [omni.kit.app._impl] [py stdout]: {'in_contact': True, 'force': 0.0, 'time': 4.116666793823242, 'number_of_contacts': 1, 'contacts': [{'body0': '/panda/panda_rightfinger', 'body1': '/World/pick_cube', 'position': [0.446928, 0.028464135, 0.06670742], 'normal': [0.7892201, 0.12467989, 0.60132074], 'impulse': [0.0, 0.0, 0.0]}]}

The code to print

_contact_sensor_interface = _sensor.acquire_contact_sensor_interface()
cs_sensor_reading = _contact_sensor_interface.get_sensor_reading("/panda/panda_rightfinger/Contact_Sensor")
cs_raw_data = _contact_sensor_interface.get_contact_sensor_raw_data("/panda/panda_rightfinger/Contact_Sensor")
_current_frame = dict()
if cs_sensor_reading.is_valid:
  _current_frame["in_contact"] = bool(cs_sensor_reading.in_contact)
  _current_frame["force"] = float(cs_sensor_reading.value)
  _current_frame["time"] = float(cs_sensor_reading.time)
  # self._current_frame["physics_step"] = float(self._number_of_physics_steps)
  _current_frame["number_of_contacts"] = len(cs_raw_data)
  
  _current_frame["contacts"] = []
  for i in range(len(cs_raw_data)):
      contact_frame = dict()
      contact_frame["body0"] = _contact_sensor_interface.decode_body_name(
          int(cs_raw_data["body0"][i])
      )
      contact_frame["body1"] = _contact_sensor_interface.decode_body_name(
          int(cs_raw_data["body1"][i])
      )
      contact_frame["position"] = [
          cs_raw_data["position"][i][0],
          cs_raw_data["position"][i][1],
          cs_raw_data["position"][i][2]
      ]
      contact_frame["normal"] = [
          cs_raw_data["normal"][i][0], 
          cs_raw_data["normal"][i][1], 
          cs_raw_data["normal"][i][2]
      ]
      contact_frame["impulse"] = [
          cs_raw_data["impulse"][i][0],
          cs_raw_data["impulse"][i][1],
          cs_raw_data["impulse"][i][2]
      ]
      _current_frame["contacts"].append(contact_frame)
print(_current_frame) 

And the viewport of the exact time step:


And how the sensor is added:

I have a same problem,The ‘force’ always is zero and ‘is_vaild’ is False

Can someone help solve it

if your is_valid flag is false, can you double check that you are using the correct prim path or is the sensor properly created? (If the contact sensor is not a child of a rigid body parent, then even though it may show up on the stage, it will not function, hence give you 0 value and is_valid is False

Regarding the original question, that is very weird. What’s the sensor radius, is it 0 or a negative number? I suspect for some reason it’s picking up a contact between the parent and the cube, maybe the collider is inaccurate.

can you visualize the collider for the finger? By clicking the “Eye icon” on the view port, select Show By Type > Physics > Colliders > All, and if possible, provide repro steps?

I could try it later. By the way, I just notice this code:

if "contacts" in self._current_frame:

However, the variable member isn’t initialized with “contacts” key

self._current_frame = dict()
self._current_frame["time"] = 0
self._current_frame["physics_step"] = 0

I don’t think this branch will be executed.