Isaac Sim: Check which object collided with obstacle

Hello there,
I have multiple robots moving around in my scene and there is one obstacle (mesh). I now want to check at each physic step if there was a collision with the obstacle. If so, then I want to know which robot collided with the obstacle.

What is the best way to add some kind of collision checker to my obstacle to find out if/which of my robots collided with it? I am using the python API, any help is highly appreciated!

Thank you in advance!

Take a look at the Isaac Contact Sensor Isaac Sensor — Omniverse Robotics documentation

If there is another way I would be happy to hear about it.

Usage example:

class ContactForceSensor:
    def __init__(self, sensor_prim_path, stage, robot_view: ArticulationView):
        # TODO(review): remove useless arguments from init (do not know why by **kwargs did not work)
        self. sensor_prim_path = sensor_prim_path
        self._cs = _isaac_sensor.acquire_contact_sensor_interface()
        color = (np.random.rand(), np.random.rand(), np.random.rand(), 1)
        # Note: When calling directly the function IsaacSensorCreateContactSensor the force generated seems to be zero
        omni.kit.commands.execute(
                "IsaacSensorCreateContactSensor",
                path="/sensor",
                parent=os.path.dirname(sensor_prim_path),
                min_threshold=0,
                max_threshold=10000000,
                color=color,
                radius=0.12,
                visualize=True,
            )

    def get_body_paths_in_contact(self) -> Set[str]:
        # Return a set of body paths in contact with the current sensor
        body_paths = set()
        raw_sensor_data = self._cs.get_contact_sensor_raw_data(self.sensor_prim_path)
        # Return a void set if there is no contact
        if len(raw_sensor_data) == 0:
            return body_paths
        # Loop of the contact body names (encoded)
        for body_raw in raw_sensor_data["body0"]:
            # Decode the body in contact to get the path
            full_body_path = self._cs.decode_body_name(body_raw)
            # Get the path of the object but not its child link
            # e.g. Get /World/envs/env_*/block02_0 rather than
            # /World/envs/env_*/block02_0/block_2_base_link
            body_path = "/".join(full_body_path.split("/")[:5])
            body_paths.add(body_path)
        return body_paths

Thank you very much for your reply @loic.sacre ! I will take a look into the contact sensor, but intuitively it seems like more overhead than necessary to simulate a sensor. And especially with complex shaped robots, it could be rather difficult to get accurate collision feedback like this, without having to add dozens of sensors.
I looked into some other methods such as overlap_mesh from omni.physx.get_physx_scene_query_interface but they only seem to work for cubes and spheres. If anybody has used these methods for more than a cube, I would really like to hear about it.

Hi - Sorry for the delay in the response. Let us know if you still having this issue with the latest Isaac Sim 2022.2.1 release.

Hello! you don’t need to necessarily use the entire contact sensor. It also provides raw data from the physx engine (contact pairs with all the contact impulses being generated), so you can parse that however you prefer. The only overhead this would cause is the same as you’d have when adding your own callback for contact reports - filtering through the data to have your body contact only.

If you want to take a look at the vanilla contact reporting, check the physx demos at Window->Simulation->Demo Scenes, then check for the Contact samples, and check Contact Report Callback