Gazebo | Ignition | Community
Ask Your Question

Adding Contact Sensor to a Gazebo Plugin

asked 2019-06-14 03:45:54 -0500

namankumar gravatar image

updated 2019-06-14 03:46:19 -0500

Hey guys,

I am writing a Gazebo plugin which will go through a robot model (sdf file) and iterate through the links using the joints and add a contact sensor to all the collisions present in those links. Currently, I have all the links, joints and collisions in the custom plugin.

I am stuck at adding a contact sensor to all of those collisions. There is a function AddContact in


but it is deprecated. Any suggestions on how can I add a contact sensor to those collisions in the plugin code itself?

PS: I know I can just add it in the model file but I don't want that because the model will keep changing and I don't want to keep on updating it with the contact sensor tag.

Thanks in advance.

edit retag flag offensive close merge delete


I am just being curious. Can you tell me why would anybody tag their question on the Gazebo discussion server gazebo? What additional information do you wish to provide with this tag? Thank you.

kumpakri gravatar imagekumpakri ( 2019-06-20 08:29:16 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2019-06-20 08:45:25 -0500

kumpakri gravatar image

I went through the Gazebo API and searched a little on the forum and wiki. I would conclude that you cannot add sensors using plugins.

However, you can make some script that will go through your sdf file and add the <sensor> tags. Actually I am using similar approach in my project to dynamically load multiple sensors on a robot, so that I can use the same robot description when I want to launch it without sensors, with one specific sensor, or any combination of sensors. I am very happy with this approach.

I basically glue the descriptions of the robot and sensors at the launch, write it in a temporary file, which the ROS then loads and when I'm done with the simulation, I remove the temporary file. Maybe that gives you some ideas.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2019-06-14 03:45:54 -0500

Seen: 393 times

Last updated: Jun 20 '19