Collision detection of a manipulator

Hello.

I am trying to implement a function to detect collisions of my manipulator, below (Doosan M1013).

The manipulator consists of several mesh parts, and the collision should be detected when the each part are overlapped (self collision detection).

I referenced these links, but they are quite difficult to customize on my python script.

https://docs.omniverse.nvidia.com/app_isaacsim/app_isaacsim/reference_python_snippets.html?#do-overlap-test

Would you let me know how I can implement the collision detection functions in my python script.

I attached the python file and M1013 usd file.

# Copyright (c) 2021, NVIDIA CORPORATION.  All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto.  Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.

import carb
import omni.kit.commands
import omni.ext
import omni.appwindow
import weakref
import omni.kit.settings
import gc
import asyncio

from omni.kit.menu.utils import add_menu_items, remove_menu_items, MenuItemDescription

from pxr import Gf

from omni.isaac.core import PhysicsContext
from omni.isaac.core.utils.nucleus import find_nucleus_server
from omni.isaac.core.utils.prims import create_prim


############################
#### ContactRepoertDemo ####
############################
from omni.physx.scripts.physicsUtils import *
from pxr import Usd, UsdLux, UsdGeom, UsdShade, Sdf, Gf, Tf, Vt, UsdPhysics, PhysxSchema
from omni.physx import get_physx_interface
from omni.physx.bindings._physx import SimulationEvent
from random import seed
from random import random
import omni.physxdemos as demo

MENU_NAME = "M1013 Collision detection"


class Extension(omni.ext.IExt):
    def on_startup(self):
        """Initialize extension and UI elements"""
        self._timeline = omni.timeline.get_timeline_interface()
        self._viewport = omni.kit.viewport.get_default_viewport_window()
        self._usd_context = omni.usd.get_context()
        self._stage = self._usd_context.get_stage()
        self._window = None

        menu_items = [MenuItemDescription(name=MENU_NAME, onclick_fn=lambda a=weakref.proxy(self): a._menu_callback())]
        self._menu_items = [MenuItemDescription(name="Demo", sub_menu=menu_items)]
        add_menu_items(self._menu_items, "Isaac Examples")

        events = get_physx_interface().get_simulation_event_stream()
        self._simulation_event_sub = events.create_subscription_to_pop(self._on_simulation_event)


    def _menu_callback(self):
        self._on_environment_setup()
        pass

    async def _create_moveit_sample(self):
        await omni.usd.get_context().new_stage_async()
        await omni.kit.app.get_app().next_update_async()
        
        self._viewport.set_camera_position("/OmniverseKit_Persp", 200, 500, 200, True)
        self._viewport.set_camera_target("/OmniverseKit_Persp", 0, 0, 50, True)
        self._stage = self._usd_context.get_stage()

        await omni.kit.app.get_app().next_update_async()
        create_prim(
            prim_path="/background", usd_path=self._nucleus_path + "/Isaac/Environments/Grid/gridroom_black.usd"
        )
        create_prim(
            prim_path="/M1013",
            usd_path=self._nucleus_path + "/Projects/K-CLOUD/DigitalTwin_Workshop/Robot/m1013_d415_vgc10_ver2.usd"
        )
        await omni.kit.app.get_app().next_update_async()

        ###########################
        #### ContactReportDemo ####
        ###########################      
        RobotPrim = self._stage.GetPrimAtPath("/M1013")
        print("RobotPrim = ", RobotPrim)
        contactReportAPI = PhysxSchema.PhysxContactReportAPI.Apply(RobotPrim)
        contactReportAPI.CreateThresholdAttr().Set(1)
        ########################### 

        PhysicsContext(physics_dt=1.0 / 60.0)
        
        
        await omni.kit.app.get_app().next_update_async()
        # num_hit = self.check_overlap_box()
        # print("Numhit = ",num_hit )        
  
    
        await omni.kit.app.get_app().next_update_async()

        self._timeline.play()

    def _on_environment_setup(self):

        result, nucleus_server = find_nucleus_server()
        if result is False:
            carb.log_error("Could not find nucleus server with /Isaac folder")
            return
        self._nucleus_path = nucleus_server

        asyncio.ensure_future(self._create_moveit_sample())

    def on_shutdown(self):  
        """Cleanup objects on extension shutdown"""
        self._timeline.stop()
        remove_menu_items(self._menu_items, "Isaac Examples")
        self._window = None
        gc.collect()
    
    def _on_simulation_event(self, event):
        if event.type == int(SimulationEvent.CONTACT_FOUND):
            print("Contact found:!!!!!!!")

m1013_d415_vgc10_ver2.usd (49.0 MB)

Thank you !

@swimpark This is currently not easy to do at the Python level. This is something we are aiming to support in an upcoming release.