IsaacLab: [Question] Filtering contacts between bodies
Question
Currently, the contact sensor works well for checking the contact forces on various links using a prim path expression in the form of regex. For example,
ContactSensorCfg(prim_path="{ENV_REGEX_NS}/Robot/.*", history_length=3, track_air_time=True)
Is it possible to filter out the collision/contacts of the robot with only certain objects in the environment? Currently, there exists an argument for the ContactSensorCfg called filter_prim_paths_expr which is supposed to do this, but when I pass expressions such as /World/envs/env_.*/Object/link_.*, it throws out the error:
[Error] [omni.physx.tensors.plugin] Filter pattern '/World/envs/env_.*/Object/link_.*' did not match the correct number of entries.
The Contact Sensor uses the RigidContactView class from omni.isaac.core but the example in the documentation only shows contact filtering with one environment. Using a regex expression instead in the same example doesn’t seem to work and returns a similar error as above.
Since the documentation is lacking for this use case, can the authors provide any guide to perform filtering contacts using regex expressions?
Thanks in advance 😃
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 19 (10 by maintainers)
Commits related to this issue
- Adds approximate torque calculation for implicit actuator (#364) # Description Adds torque computation to implicit actuators. Previously the reported torque was always zero. ## Type of change ... — committed to wangyan-hlab/IsaacLab by nikitardn 3 years ago
- Fixes parsing of filter prim path expressions in ContactSensor (#385) # Description PhysX view classes expect the expressions to be in "Glob" format instead of "Regex". While we did this conversi... — committed to isaac-sim/IsaacLab by Mayankm96 3 years ago
- Adds approximate torque calculation for implicit actuator (#364) # Description Adds torque computation to implicit actuators. Previously the reported torque was always zero. ## Type of change ... — committed to fatimaanes/omniperf by nikitardn 3 years ago
- Fixes parsing of filter prim path expressions in ContactSensor (#385) PhysX view classes expect the expressions to be in "Glob" format instead of "Regex". While we did this conversion for the body vi... — committed to fatimaanes/omniperf by Mayankm96 3 years ago
- Adds approximate torque calculation for implicit actuator (#364) # Description Adds torque computation to implicit actuators. Previously the reported torque was always zero. ## Type of change ... — committed to iamdrfly/IsaacLab by nikitardn 3 years ago
- Fixes parsing of filter prim path expressions in ContactSensor (#385) PhysX view classes expect the expressions to be in "Glob" format instead of "Regex". While we did this conversion for the body vi... — committed to iamdrfly/IsaacLab by Mayankm96 3 years ago
- Fixes parsing of filter prim path expressions in ContactSensor (#385) PhysX view classes expect the expressions to be in "Glob" format instead of "Regex". While we did this conversion for the body vi... — committed to Albertzhangfq/IsaacLab by Mayankm96 3 years ago
@AravindhPadmanabhan Based on this and this, using
filter_prim_paths_expr=["/World/defaultGroundPlane/terrain/mesh"]should work.I had the same issue when I was working with the rough terrain ground mesh, but when I tried a flat environment using the ground plane:
/World/ground/GroundPlane/CollisionPlaneI did not get this issue, this collision plane didnt show up as a mesh, which leads me to believe that the mesh might calculate collisions in a different way? I’m really not sure thought, I’ll let you know once I find out more!
@xliu0105 For the ground plane, you may configure the ContactSensor as:
However, I still have similar issues as @shafeef901 when I try to filter multiple prims for a franka arm.
When using the the first expression, an error will pop out
@Mayankm96 It seems to me that each expression can only correspond to one prim, is it correct?
Hello @Mayankm96 ,
I think I found a mistake in the newly added contact force assertions used in the unit test for the contact sensor.
I tried running test_contact_sensor.py and printed out the tensors being used in the assertions in line 292 and 295 and they turn out to be all 0s. Looks like the assertion passes only because they are all zero tensors.
I came across this when I was trying to find the contact forces and contact points of a robot with the ground. I tried this out using the example in
source/standalone/tutorials/04_sensors/add_sensors_on_robot.py. I was able to get the contact forces usingContactSensor.data.net_forces_w. But to get contact points, I specified filters inContactSensorCfg.filter_prim_paths_exprand usedContactSensor.contact_physx_view.get_contact_data(). Hence, I modified theContactSensorCfgto look like this:I printed out
Contact_sensor.data.net_forces_w,ContactSensor.data.force_matrix_wandContactSensor.contact_physx_view.get_contact_data(). While net_forces_w had non-zero values which seemed reasonably correct,force_matrix_wandget_contact_data()were filled with 0s, as shown in the image below. I also got a warning that saidGPU contact filter for collider '/World/defaultGroundPlane' is not supported. Could you please look into this and let me know how I can get the contact points between two prims? Thanks in advance!P.S.: Also had to make
max_contact_data_counta non-zero value in thecreate_rigid_contact_view()function in line 258 ofsource/extensions/omni.isaac.orbit/omni/isaac/orbit/sensors/contact_sensor/contact_sensor.pyforget_contact_data()to workIt seems to me that filtering doesn’t work with regex expressions. So
filter_prim_paths_exprshould probably be renamed tofilter_prim_paths. Furthermore, since we definecontact_sensorin the config file, it’s not straightforward to infernum_envs. In my case, I hardcoded it to test it. Is there a better way to do so?