The different between contact sensor and effort sensor and one contact sensor problem

Hi, I’m trying to build up an environment that equips sensor on the fingertip, and I found that the force sensor was canceled in 2023.1, the contact sensor and effort sensor are supported. If I just need to know the force from on direction, what’s different between there two sensors?

And 2), I’m trying to build up the env with contact sensor, I build the simple code for testing:

from omni.isaac.sensor import ContactSensor
import numpy as np
from omni.isaac.sensor import _sensor

class ContactSensorView:
    """the isaac sim extensions have no contact sensor view for tactile sensor"""
    def __init__(self):
        self._spawn_prim_path: str = None
        self._contact_sensor_interface = _sensor.acquire_contact_sensor_interface()
    
    def spawn_single(
        self, 
        prim_path: str, 
        sensor_name: str,
        name: str, 
        translation: np.ndarray = np.array([0, 0, 0]), 
        radius: float = 0.001,
    ):
        self.sensor = ContactSensor(
            prim_path=prim_path+sensor_name,
            name=name,
            frequency=60,
            translation=translation,
            radius=radius,
        )
        print("[INFO] spawn on single contact sensor successful.")
    
    def get_sensor_data(
        self,
        prim_path,
    ):
        print("------")
        print("[INFO] sensor value:", self.sensor.get_current_frame())
        print("[INFO] sensor validation:", self.sensor.is_valid())
        print("[INFO] sensor radius:", self.sensor.get_radius())
        # print("[INFO] sensor frequency:", self.sensor.get_frequency())
        # return value
        # return self._contact_sensor_interface.get_sensor_reading(
        #     prim_path, 
        #     use_latest_data = True,
        # ).value

The get_frequency() function can not work (sensor period = 0) and I can not get the contact value:

------
[INFO] sensor value: {'time': 0, 'physics_step': 0}
[INFO] sensor validation: True
[INFO] sensor radius: -1.0
Traceback (most recent call last):
  File "/Orbit/source/standalone/demo/play_arms.py", line 207, in <module>
    main()
  File "/Orbit/source/standalone/demo/play_arms.py", line 192, in main
    tac_sensor.get_sensor_data(prim_path=test_pos+sensor_name)
  File "/Orbit/source/standalone/demo/contactsensor.py", line 44, in get_sensor_data
    print("[INFO] sensor frequency:", self.sensor.get_frequency())
  File "/.local/share/ov/pkg/isaac_sim-2023.1.0/exts/omni.isaac.sensor/omni/isaac/sensor/scripts/contact_sensor.py", line 173, in get_frequency
    return int(1.0 / self._isaac_sensor_prim.GetSensorPeriodAttr().Get())
ZeroDivisionError: float division by zero

Thanks!

Hello Yiyiliu.liu

thanks for contacting us!

Q1:
A contact sensor measures the contact forces between two rigid bodies, and an effort sensor measures the torque (for a revolute joint) or force (for a prismatic joint) that pass through the joint.

Q2:
Frequency = 1/sensor period, so when your sensor period is 0, you get a undefined (div by zero) frequency. So it is not recommended to call get frequency for sensor period of 0.

Q3:
there are many reasons why you might not be getting a proper reading, here are a few of the top of my head:

  1. Is the sensor attached to a rigid body?
  2. Do you have collision turned on between the rigid body parent and the thing it’s colliding with? You can debug this by clicking the eye icon beside RTX-Real-Time on the top left corner of your viewport, go to Show By Type > Physics > Colliders > All.
    There is a chance that you might not have the correct collider setting enabled
  3. Have you run the contact sensor for multiple physics steps? The physics engine needs a few steps on start to initialize properly.

Hope that helps!

Steven