How to extract the entity name from contact sensor data?

asked 2021-08-30 02:43:03 -0500

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

Hello all: I'm using the contact sensor plugin in the ignition, now I want to get the name of the entity which is touched by the sensor. While I am running the example "contact_example.sdf", I noticed that in the sensor topic, the contact data contains a "collision id", shown below: ---------------------------------------------contact sensor data------------------------------------------ header { stamp { sec: 1 nsec: 68000000 } } contact { header { stamp { sec: 1 nsec: 68000000 } } collision1 { id: 11 } collision2 { id: 7 } position { x: 0.025054910040978484 y: 5.4563571229493012e-24 z: -0.01368755973817315 } } ---------------------------------------------contact sensor data------------------------------------------- According to the sdf, I suppose that the collision1 and collision2 must refer to the ball and slope separately, but how do I know which is the ball exactly? Or is there any way to get the entity object contacted by the sensor directly? Many thanks!

edit retag flag offensive close merge delete