How to add contact sensor attached to prim?

@rgasoto I’ve tried

result, sensor = omni.kit.commands.execute( "IsaacSensorCreateContactSensor", path="/sensor", parent=prim_path, min_threshold=0, max_threshold=10000000, radius=radius, sensor_period=-1, offset=Gf.Vec3d(offset[0], offset[1], offset[2]), visualize=True, )

but IsaacSim crashed, the log shows

2022-08-03 13:47:47 [46,369ms] [Error] [carb.crashreporter-breakpad.plugin] crash detected           
2022-08-03 13:47:47 [46,369ms] [Warning] [carb.crashreporter-breakpad.plugin] A crash has occurred.  
If a debugger should be attached, please set the '/crashreporter/debuggerAttachTimeoutMs' setting to 
a timeout in milliseconds.  This can be used to allow the crash reporter to wait for up to that long 
for a debugger to attach before processing or sending the crash report.                              
2022-08-03 13:47:47 [46,370ms] [Warning] [carb.crashreporter-breakpad.plugin] Uploading minidump: fil
e:'/root/.local/share/ov/data/Kit/Isaac-Sim/2022.1/dbb6114a-4228-48a9-81d5759b-33bc4275.dmp' svr:'htt
ps://services.nvidia.com/submit'                                                                     
2022-08-03 13:47:47 [46,370ms] [Warning] [carb.crashreporter-breakpad.plugin] Crash metadata for uplo
ad:                                                                                                  
2022-08-03 13:47:47 [46,370ms] [Warning] [carb.crashreporter-breakpad.plugin]   DumpId = 'dbb6114a-42
28-48a9-81d5759b-33bc4275'                                                                           
2022-08-03 13:47:47 [46,370ms] [Warning] [carb.crashreporter-breakpad.plugin]   ProductName = 'Omnive
rseKit'                                                                                              
2022-08-03 13:47:47 [46,370ms] [Warning] [carb.crashreporter-breakpad.plugin]   StartupTime = '165953
4420'                                                                                                
2022-08-03 13:47:47 [46,370ms] [Warning] [carb.crashreporter-breakpad.plugin]   UptimeSeconds = '47' 
2022-08-03 13:47:47 [46,370ms] [Warning] [carb.crashreporter-breakpad.plugin]   Version = '103.1+rele
ase.12610.6e2a27c0.tc'                                                                               
2022-08-03 13:47:47 [46,370ms] [Warning] [carb.crashreporter-breakpad.plugin]   appName = 'Isaac-Sim'
2022-08-03 13:47:47 [46,370ms] [Warning] [carb.crashreporter-breakpad.plugin]   appState = 'started' 
2022-08-03 13:47:47 [46,370ms] [Warning] [carb.crashreporter-breakpad.plugin]   appVersion = '2022.1.
0'                                                                                                   
2022-08-03 13:47:47 [46,370ms] [Warning] [carb.crashreporter-breakpad.plugin]   autoloadExts = ''    
2022-08-03 13:47:47 [46,370ms] [Warning] [carb.crashreporter-breakpad.plugin]   buildBranch = 'releas
e'                                                                                                   
2022-08-03 13:47:47 [46,370ms] [Warning] [carb.crashreporter-breakpad.plugin]   buildCi = 'tc'       
2022-08-03 13:47:47 [46,370ms] [Warning] [carb.crashreporter-breakpad.plugin]   buildCiNumber = '1039
9879'
2022-08-03 13:47:47 [46,370ms] [Warning] [carb.crashreporter-breakpad.plugin]   buildHash = '6e2a27c0
'
2022-08-03 13:47:47 [46,370ms] [Warning] [carb.crashreporter-breakpad.plugin]   buildMajor = '103'
2022-08-03 13:47:47 [46,370ms] [Warning] [carb.crashreporter-breakpad.plugin]   buildMinor = '1'
2022-08-03 13:47:47 [46,370ms] [Warning] [carb.crashreporter-breakpad.plugin]   buildMr = '0'
2022-08-03 13:47:47 [46,370ms] [Warning] [carb.crashreporter-breakpad.plugin]   buildNumber = '12610'
2022-08-03 13:47:47 [46,370ms] [Warning] [carb.crashreporter-breakpad.plugin]   buildPatch = '0'
2022-08-03 13:47:47 [46,370ms] [Warning] [carb.crashreporter-breakpad.plugin]   buildVersion = '103.1
.0'
2022-08-03 13:47:47 [46,370ms] [Warning] [carb.crashreporter-breakpad.plugin]   environmentName = 'de
fault'
2022-08-03 13:47:47 [46,370ms] [Warning] [carb.crashreporter-breakpad.plugin]   experience = 'Isaac S
im'
2022-08-03 13:47:47 [46,370ms] [Warning] [carb.crashreporter-breakpad.plugin]   kitRendererDriverVers
ion = '470.129'
2022-08-03 13:47:47 [46,370ms] [Warning] [carb.crashreporter-breakpad.plugin]   lastCommand = 'IsaacS
ensorCreatePrim(path=/sensor,parent=/World/Flexiv_0/panda_leftfinger,schema_type=?,position=?,visuali
ze=True)'
2022-08-03 13:47:47 [46,370ms] [Warning] [carb.crashreporter-breakpad.plugin]   lastCommands = 'Group
,CreatePrimCommand(prim_path=/OmniverseKit_Front,prim_type=Camera,select_new_prim=False,context_name=
),Group,CreatePrimCommand(prim_path=/OmniverseKit_Top,prim_type=Camera,select_new_prim=False,context_
name=),Group,CreatePrimCommand(prim_path=/OmniverseKit_Right,prim_type=Camera,select_new_prim=False,c
ontext_name=),IsaacSensorCreateContactSensor(path=/sensor,parent=/World/Flexiv_0/panda_rightfinger,mi
n_threshold=0,max_threshold=10000000,radius=0.1,sensor_period=-1,offset=?,visualize=True),IsaacSensor
CreatePrim(path=/sensor,parent=/World/Flexiv_0/panda_rightfinger,schema_type=?,position=?,visualize=T
rue),IsaacSensorCreateContactSensor(path=/sensor,parent=/World/Flexiv_0/panda_leftfinger,min_threshol
d=0,max_threshold=10000000,radius=0.1,sensor_period=-1,offset=?,visualize=True),IsaacSensorCreatePrim
(path=/sensor,parent=/World/Flexiv_0/panda_leftfinger,schema_type=?,position=?,visualize=True)'
2022-08-03 13:47:47 [46,370ms] [Warning] [carb.crashreporter-breakpad.plugin]   memoryStats = '(avail
/total) RAM: 50.4817/62.8118GB, Swap: 0.443474/0.957027GB, VM: 1.71799e+10/1.71799e+10GB'
2022-08-03 13:47:47 [46,370ms] [Warning] [carb.crashreporter-breakpad.plugin]   portableMode = '0'
2022-08-03 13:47:47 [46,370ms] [Warning] [carb.crashreporter-breakpad.plugin]   stageUrl = ''
2022-08-03 13:47:47 [46,370ms] [Warning] [carb.crashreporter-breakpad.plugin]   systemInfo = '
|---------------------------------------------------------------------------------------------|
| Driver Version: 470.129.6     | Graphics API: Vulkan
|=============================================================================================|
| GPU | Name                             | Active | LDA | GPU Memory | Vendor-ID | LUID       |
|     |                                  |        |     |            | Device-ID | UUID       |
|---------------------------------------------------------------------------------------------|
| 0   | Quadro RTX 8000                  | Yes: 0 |     | 49398   MB | 10de      | 0          |
|     |                                  |        |     |            | 1e30      | 6a3bd068.. |
|=============================================================================================|
| OS: Linux isaac, Version: 5.4.0-107-generic
| Processor: Intel(R) Xeon(R) Gold 6226R CPU @ 2.90GHz | Cores: Unknown | Logical: 12
|---------------------------------------------------------------------------------------------|
| Total Memory (MB): 64319 | Free Memory: 56313
| Total Page/Swap (MB): 979 | Free Page/Swap: 979
|---------------------------------------------------------------------------------------------|
'
2022-08-03 13:47:47 [46,370ms] [Warning] [carb.crashreporter-breakpad.plugin]   telemetrySessionId = 
'0'
2022-08-03 13:47:47 [46,372ms] [Error] [carb.crashreporter-breakpad.plugin] failed to upload minidump
: file: '/root/.local/share/ov/data/Kit/Isaac-Sim/2022.1/dbb6114a-4228-48a9-81d5759b-33bc4275.dmp', c
ode: 0, error: 'libcurl.so: cannot open shared object file: No such file or directory', response:
2022-08-03 13:47:47 [46,372ms] [Error] [carb.crashreporter-breakpad.plugin]      {status = InitFailed
 (2)}
2022-08-03 13:47:47 [46,372ms] [Error] [carb.crashreporter-breakpad.plugin] Wrote dump file '/root/.l
ocal/share/ov/data/Kit/Isaac-Sim/2022.1/dbb6114a-4228-48a9-81d5759b-33bc4275.dmp'
2022-08-03 13:47:47 [46,372ms] [Error] [carb.crashreporter-breakpad.plugin]     dump file size is 274
8368 bytes, file is readable.
2022-08-03 13:47:47 [46,373ms] [Fatal] [carb.crashreporter-breakpad.plugin] Crash detected in pid 318
8 thread 3188
2022-08-03 13:47:47 [46,373ms] [Warning] [carb.crashreporter-breakpad.plugin] Crash metadata:        
2022-08-03 13:47:47 [46,373ms] [Warning] [carb.crashreporter-breakpad.plugin]   DumpId = 'dbb6114a-42
28-48a9-81d5759b-33bc4275'                                                                           
2022-08-03 13:47:47 [46,373ms] [Warning] [carb.crashreporter-breakpad.plugin]   ProductName = 'Omnive
rseKit'
2022-08-03 13:47:47 [46,373ms] [Warning] [carb.crashreporter-breakpad.plugin]   StartupTime = '165953
4420'
2022-08-03 13:47:47 [46,373ms] [Warning] [carb.crashreporter-breakpad.plugin]   UptimeSeconds = '47'
2022-08-03 13:47:47 [46,373ms] [Warning] [carb.crashreporter-breakpad.plugin]   Version = '103.1+rele
ase.12610.6e2a27c0.tc'
2022-08-03 13:47:47 [46,373ms] [Warning] [carb.crashreporter-breakpad.plugin]   appName = 'Isaac-Sim'
2022-08-03 13:47:47 [46,373ms] [Warning] [carb.crashreporter-breakpad.plugin]   appState = 'started'
2022-08-03 13:47:47 [46,373ms] [Warning] [carb.crashreporter-breakpad.plugin]   appVersion = '2022.1.
0'
2022-08-03 13:47:47 [46,373ms] [Warning] [carb.crashreporter-breakpad.plugin]   autoloadExts = ''
2022-08-03 13:47:47 [46,373ms] [Warning] [carb.crashreporter-breakpad.plugin]   buildBranch = 'releas
e'
2022-08-03 13:47:47 [46,373ms] [Warning] [carb.crashreporter-breakpad.plugin]   buildCi = 'tc'
2022-08-03 13:47:47 [46,373ms] [Warning] [carb.crashreporter-breakpad.plugin]   buildCiNumber = '1039
9879'
2022-08-03 13:47:47 [46,373ms] [Warning] [carb.crashreporter-breakpad.plugin]   buildHash = '6e2a27c0
'
2022-08-03 13:47:47 [46,373ms] [Warning] [carb.crashreporter-breakpad.plugin]   buildMajor = '103'
2022-08-03 13:47:47 [46,373ms] [Warning] [carb.crashreporter-breakpad.plugin]   buildMinor = '1'
2022-08-03 13:47:47 [46,373ms] [Warning] [carb.crashreporter-breakpad.plugin]   buildMr = '0'
2022-08-03 13:47:47 [46,373ms] [Warning] [carb.crashreporter-breakpad.plugin]   buildNumber = '12610'
2022-08-03 13:47:47 [46,373ms] [Warning] [carb.crashreporter-breakpad.plugin]   buildPatch = '0'
2022-08-03 13:47:47 [46,373ms] [Warning] [carb.crashreporter-breakpad.plugin]   buildVersion = '103.1
.0'
2022-08-03 13:47:47 [46,373ms] [Warning] [carb.crashreporter-breakpad.plugin]   environmentName = 'de
fault'
2022-08-03 13:47:47 [46,373ms] [Warning] [carb.crashreporter-breakpad.plugin]   experience = 'Isaac S
im'
2022-08-03 13:47:47 [46,373ms] [Warning] [carb.crashreporter-breakpad.plugin]   kitRendererDriverVers
ion = '470.129'
2022-08-03 13:47:47 [46,373ms] [Warning] [carb.crashreporter-breakpad.plugin]   lastCommand = 'IsaacS
ensorCreatePrim(path=/sensor,parent=/World/Flexiv_0/panda_leftfinger,schema_type=?,position=?,visuali
ze=True)'
2022-08-03 13:47:47 [46,373ms] [Warning] [carb.crashreporter-breakpad.plugin]   lastCommands = 'Group
,CreatePrimCommand(prim_path=/OmniverseKit_Front,prim_type=Camera,select_new_prim=False,context_name=
),Group,CreatePrimCommand(prim_path=/OmniverseKit_Top,prim_type=Camera,select_new_prim=False,context_
name=),Group,CreatePrimCommand(prim_path=/OmniverseKit_Right,prim_type=Camera,select_new_prim=False,c
ontext_name=),IsaacSensorCreateContactSensor(path=/sensor,parent=/World/Flexiv_0/panda_rightfinger,mi
n_threshold=0,max_threshold=10000000,radius=0.1,sensor_period=-1,offset=?,visualize=True),IsaacSensor
CreatePrim(path=/sensor,parent=/World/Flexiv_0/panda_rightfinger,schema_type=?,position=?,visualize=T
rue),IsaacSensorCreateContactSensor(path=/sensor,parent=/World/Flexiv_0/panda_leftfinger,min_threshol
d=0,max_threshold=10000000,radius=0.1,sensor_period=-1,offset=?,visualize=True),IsaacSensorCreatePrim
(path=/sensor,parent=/World/Flexiv_0/panda_leftfinger,schema_type=?,position=?,visualize=True)'
2022-08-03 13:47:47 [46,373ms] [Warning] [carb.crashreporter-breakpad.plugin]   memoryStats = '(avail
/total) RAM: 50.4817/62.8118GB, Swap: 0.443474/0.957027GB, VM: 1.71799e+10/1.71799e+10GB'
2022-08-03 13:47:47 [46,373ms] [Warning] [carb.crashreporter-breakpad.plugin]   portableMode = '0'
2022-08-03 13:47:47 [46,373ms] [Warning] [carb.crashreporter-breakpad.plugin]   stageUrl = ''
2022-08-03 13:47:47 [46,373ms] [Warning] [carb.crashreporter-breakpad.plugin]   systemInfo = '
|---------------------------------------------------------------------------------------------|
| Driver Version: 470.129.6     | Graphics API: Vulkan
|=============================================================================================|
| GPU | Name                             | Active | LDA | GPU Memory | Vendor-ID | LUID       |
|     |                                  |        |     |            | Device-ID | UUID       |
|---------------------------------------------------------------------------------------------|
| 0   | Quadro RTX 8000                  | Yes: 0 |     | 49398   MB | 10de      | 0          |
|     |                                  |        |     |            | 1e30      | 6a3bd068.. |
|=============================================================================================|
| OS: Linux isaac, Version: 5.4.0-107-generic
| Processor: Intel(R) Xeon(R) Gold 6226R CPU @ 2.90GHz | Cores: Unknown | Logical: 12
|---------------------------------------------------------------------------------------------|
| Total Memory (MB): 64319 | Free Memory: 56313
| Total Page/Swap (MB): 979 | Free Page/Swap: 979
|---------------------------------------------------------------------------------------------|
'
2022-08-03 13:47:47 [46,374ms] [Warning] [carb.crashreporter-breakpad.plugin]   telemetrySessionId = 
'0'
2022-08-03 13:47:47 [46,374ms] [Fatal] [carb.crashreporter-breakpad.plugin] Thread 3188 backtrace fol
lows:
2022-08-03 13:47:47 [46,615ms] [Fatal] [carb.crashreporter-breakpad.plugin] 000: libcarb.events.plugi
n.so!std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()+0xde4
2022-08-03 13:47:47 [46,883ms] [Fatal] [carb.crashreporter-breakpad.plugin] 001: libcarb.assets.plugi
n.so!std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string
 const&, unsigned long, unsigned long)+0x8e54
2022-08-03 13:47:48 [47,158ms] [Fatal] [carb.crashreporter-breakpad.plugin] 002: libcarb.datasource-f
ile.plugin.so!std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()
+0x424
2022-08-03 13:47:48 [47,434ms] [Fatal] [carb.crashreporter-breakpad.plugin] 003: libgpu.foundation.pl
ugin.so!std::fill(std::_Bit_iterator, std::_Bit_iterator, bool const&)+0x374
2022-08-03 13:47:48 [47,676ms] [Fatal] [carb.crashreporter-breakpad.plugin] 004: libcarb.datasource-o
mniclient.plugin.so!std::_V2::condition_variable_any::~condition_variable_any()+0x1044
2022-08-03 13:47:48 [47,918ms] [Fatal] [carb.crashreporter-breakpad.plugin] 005: libomni.kit.renderer
.plugin.so!std::call_once<void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<s
td::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__fut
ure_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__futu
re_base::_Result_base::_Deleter> ()>*, bool*>(std::once_flag&, void (std::__future_base::_State_baseV
2::*&&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_b
ase::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*&&, std::function<std::unique_ptr<std:
:__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*&&, bool*&&)::{lambda()
#2}::_FUN()+0x3114
2022-08-03 13:47:49 [48,154ms] [Fatal] [carb.crashreporter-breakpad.plugin] 006: librtx.materialdb.pl
ugin.so!std::_Sp_counted_deleter<std::atomic<bool>*, std::__shared_ptr<std::atomic<bool>, (__gnu_cxx:
:_Lock_policy)2>::_Deleter<std::allocator<std::atomic<bool> > >, std::allocator<std::atomic<bool> >, 
(__gnu_cxx::_Lock_policy)2>::~_Sp_counted_deleter()+0x554
2022-08-03 13:47:49 [48,399ms] [Fatal] [carb.crashreporter-breakpad.plugin] 007: libpthread.so.0!funl
ockfile+0x50
2022-08-03 13:47:49 [48,642ms] [Fatal] [carb.crashreporter-breakpad.plugin] 008: libsdf.so!pxrInternal_v0_20__pxrReserved__::SdfPath::IsAbsolutePath() const+0x1f
2022-08-03 13:47:49 [48,882ms] [Fatal] [carb.crashreporter-breakpad.plugin] 009: libusd.so!pxrInternal_v0_20__pxrReserved__::UsdStage::GetPrimAtPath(pxrInternal_v0_20__pxrReserved__::SdfPath const&) const+0x19
2022-08-03 13:47:50 [49,113ms] [Fatal] [carb.crashreporter-breakpad.plugin] 010: libomni.flowusd.plugin.so!void std::vector<double, std::allocator<double> >::emplace_back<double>(double&&)+0x15914
2022-08-03 13:47:50 [49,347ms] [Fatal] [carb.crashreporter-breakpad.plugin] 011: libomni.stageupdate.plugin.so!carbOnPluginShutdown+0x1d83
2022-08-03 13:47:50 [49,602ms] [Fatal] [carb.crashreporter-breakpad.plugin] 012: libomni.usd.so!std::_Hashtable<unsigned long, unsigned long, std::allocator<unsigned long>, std::__detail::_Identity, std::equal_to<unsigned long>, std::hash<unsigned long>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, true, true> >::_M_insert_unique_node(unsigned long, unsigned long, std::__detail::_Hash_node<unsigned long, false>*)+0x4a12
2022-08-03 13:47:50 [49,878ms] [Fatal] [carb.crashreporter-breakpad.plugin] 013: libomni.usd.so!std::_Hashtable<unsigned long, unsigned long, std::allocator<unsigned long>, std::__detail::_Identity, std::equal_to<unsigned long>, std::hash<unsigned long>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, true, true> >::_M_insert_unique_node(unsigned long, unsigned long, std::__detail::_Hash_node<unsigned long, false>*)+0x590d
2022-08-03 13:47:51 [50,140ms] [Fatal] [carb.crashreporter-breakpad.plugin] 014: libomni.usd.so!std::string __gnu_cxx::__to_xstring<std::string, char>(int (*)(char*, unsigned long, char const*, __va_list_tag*), unsigned long, char const*, ...)+0x1f6f
2022-08-03 13:47:51 [50,374ms] [Fatal] [carb.crashreporter-breakpad.plugin] 015: libcarb.events.plugin.so!std::_Hashtable<unsigned long, unsigned long, std::allocator<unsigned long>, std::__detail::_Identity, std::equal_to<unsigned long>, std::hash<unsigned long>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, true, true> >::_M_insert_unique_node(unsigned long, unsigned long, std::__detail::_Hash_node<unsigned long, false>*)+0x19a3
2022-08-03 13:47:51 [50,646ms] [Fatal] [carb.crashreporter-breakpad.plugin] 016: libomni.kit.loop-default.plugin.so!std::thread::_State_impl<std::thread::_Invoker<std::tuple<omni::kit::RunLoopThread::run()::{lambda()#1}> > >::~_State_impl()+0x66c
2022-08-03 13:47:51 [50,881ms] [Fatal] [carb.crashreporter-breakpad.plugin] 017: libomni.kit.loop-default.plugin.so!std::thread::_State_impl<std::thread::_Invoker<std::tuple<omni::kit::RunLoopThread::run()::{lambda()#1}> > >::~_State_impl()+0xd6c3
2022-08-03 13:47:52 [51,124ms] [Fatal] [carb.crashreporter-breakpad.plugin] 018: libomni.kit.app.plugin.so!_init+0x285b
2022-08-03 13:47:52 [51,378ms] [Fatal] [carb.crashreporter-breakpad.plugin] 019: libomni.kit.app.plugin.so!carbOnPluginPostShutdown+0x7e7
2022-08-03 13:47:52 [51,628ms] [Fatal] [carb.crashreporter-breakpad.plugin] 020: kit!_init+0x5e7
2022-08-03 13:47:52 [51,857ms] [Fatal] [carb.crashreporter-breakpad.plugin] 021: libc.so.6!__libc_start_main+0xe7
2022-08-03 13:47:52 [52,081ms] [Fatal] [carb.crashreporter-breakpad.plugin] 022: kit!_init+0x93b
Segmentation fault (core dumped)

1 Like

Can anybody answer me ?

Hi newuhe, the following code I have tried and can work.

from omni.isaac.contact_sensor import _contact_sensor

cs = _contact_sensor.acquire_contact_sensor_interface()
props = _contact_sensor.SensorProperties()
props.radius = -1 # Cover the entire leg tip
props.minThreshold = 0
props.maxThreshold = 20
props.sensorPeriod = 1 / 100.0

cs.add_sensor_on_body(‘/your_prim_path’, props)

Hope can help you!

Thanks for replying. But my IsaacSim version is 2022.1 and the _contact_sensor api is deprecated.

The contact sensor is not deprecated, but it was moved to the isaac_sensor extension

The main change you have to make is:

from omni.isaac.isaac_sensor import _isaac_sensor
_cs = _isaac_sensor.acquire_contact_sensor_interface()

https://docs.omniverse.nvidia.com/py/isaacsim/source/extensions/omni.isaac.isaac_sensor/docs/index.html#contact-sensor

1 Like

Thanks for replying. However, as I mentioned above, I created contact sensor using omni.kit.commands.execute("IsaacSensorCreateContactSensor" but it crashed. How to solve the problem.

Can you share a bit more of your script?
Is this an extension or a standalone python sample?

Here is code snippet, it’s used in an extension

def set_force_sensor(self, prim_path, radius=-1, offset=[0, 0, 0]):
        """Set force sensor.

        Args:
            prim_path: path of prim where contact sensor is attached
            radius: radius of contact sensor
            offset: offset attached position
        """
        result, sensor = omni.kit.commands.execute(
            "IsaacSensorCreateContactSensor",
            path="/sensor",
            parent=prim_path,
            min_threshold=0,
            max_threshold=10000000,
            radius=radius,
            sensor_period=-1,
            offset=Gf.Vec3d(offset[0], offset[1], offset[2]),
            visualize=True,
        )
        return

Between creating the prim at prim_path and calling set_force_sensor, can you add a single frame delay, basically wait for the next frame after creating the prim and the contact sensor. It takes a frame for a prim to exist and be used as a parent by the sensor.

Another option is to create the sensor via the create->isaac->sensors->contact sensor with the prim you want as the parent selected. Then you can save the usd and the sensor will be available when that usd is loaded.

Can you change offset to translation when calling IsaacSensorCreateContactSensor, as the command parameters were refactored?