Robotics StackExchange | Archived questions

How to extract the entity name from contact sensor data?

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!

Asked by Tudala on 2021-08-30 02:43:03 UTC

Comments

Answers