Gazebo | Ignition | Community
Ask Your Question

How to add Gazebo Plugin to Simulation?

asked 2016-06-13 14:38:22 -0500

icepaka89 gravatar image

updated 2016-06-14 13:16:49 -0500

Hello! So I am writing a program that will, in theory, ask the user for a (variable) number of robots and spawn the correct number of pioneer2DX models in an empty gazebo world, all done through ROS. I want to add Gazebo plugins that will allow the ROS node to communicate with each pioneer spawned in the simulation. So I would like to write a plugin that can be linked to each of the pioneers I spawned in the empty world. Is there a way to accomplish this through ROS? Since the models are spawned during run time, I need the ROS node to be able to do the linking. Is there a way to do this? Or perhaps an alternative method that will still allow my ROS node to communicate with the dynamic number of robots spawned? I've been looking through the tutorials but I can't seem to find much that helps here. Thanks!!

To be more specific, I would like to create a plugin that can be attached to ANY pioneer2DX model I add (i.e. each model runs the plugin). I would like the plugin to have control functions (i.e. moving forward, backward, turning; retrieve sensor values, etc.) that can directly manipulate the robot in the simulation. I would like these functions to be accessible by my ROS node. For example, if my ROS node wants to move a model, it can call these functions from the plugin to do so.

Additionally, since there are going to be a variable number of robots each time the simulation is run (this number will be given by the user), I would like the ROS node to have the ability to link the said plugin to each robot in the simulation (which will be named pionner1, ... , pioneer[n]). This will happen when the simulation starts. And when the plugin is linked to the model, the ROS node should be able to communicate with it and call its functions to command the robot to move and give its sensor values as needed.

I hope this clears things up a bit. Sorry for being a bit vague before.

edit retag flag offensive close merge delete


First off, cool project! There's a been a lot of work on swarm robot simulations in gazebo, so maybe do some googling for that. This is definitely doable. The question is what level of control do you want? There are probably already gazebo plugins written for controlling the Pioneer robots. Although maybe not from ros. You'll need to update your question with more details on *exactly* what things you want, and what technical issues you're having.

Peter Mitrano gravatar imagePeter Mitrano ( 2016-06-14 11:07:32 -0500 )edit

Hi Peter, I have updated my question. I hope this clears things up. With the information added in the edit, I would like to know: 1. How to use c++ code in my ROS node to link the plugin to the models. 2. If it is possible to access code from a gazebo plugin in a ROS node

icepaka89 gravatar imageicepaka89 ( 2016-06-14 13:19:23 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2016-06-14 18:02:34 -0500

Ok, so in order for a gazebo plugin to communicate with a ros node, you need to either have the gazebo plugin publish messages with ros, or have a ros node publish messages on gazebo transport. The first is a the default approach, and many other plugins already do this. You should read all of these tutorials to get a firm grasp on how to communicate between ros and gazebo.

When you add multiple models of the same name into gazebo, their names will be appended with numbers. This gives you the ability to address an individual model. in other words, it changes the topic name or contents of the messages to gazebo. My guess is that you'll have gazebo plugins, one per robot, that drive around when they receive messages from your ROS node, and also publish back sensor information to ros topics. Again, read all of these tutorials and you'll know more about it then I do.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2016-06-13 14:38:22 -0500

Seen: 471 times

Last updated: Jun 14 '16