Home | Tutorials | Wiki | Issues
Ask Your Question

ros::init() needed for ROS Gazebo plugin?

asked 2013-02-22 02:51:46 -0500

bit-pirate gravatar image

After reading this thread on the Gazebo-list about plugins residing inside the Gazebo ROS node, I found out that my plugin is running fine without the ros::init() call.

The tutorials (e.g. here for 1.3) however make use of this initialisation. So now I wonder, if it is necessary or not?

Since, the plugin is loaded into the Gazebo node, it would make sense to me, that ros::init is not needed (similar to nodelets in ROS).

edit retag flag offensive close merge delete

3 Answers

Sort by » oldest newest most voted

answered 2013-03-07 22:38:27 -0500

nkoenig gravatar image

Gazebo does not call ros:init. It's up to one of your plugins (or a plugin that you load) to call ros::init.

edit flag offensive delete link more


Right, but the question is, if it is needed. My plugin for example has subs & pubs, but since it is loaded into gazebo, which is also acting as a ROS node, it works fine without calling ros::init(). So, I wonder in which case it is actually needed.

bit-pirate gravatar imagebit-pirate ( 2013-03-08 04:04:13 -0500 )edit

Gazebo is acting as a ROS node because someone inside the process called ros::init(). If it wasn't your plugin, some other plugin must have done it, as standalone Gazebo does not do it. So yes, it is needed to make your plugin robust to the case when it's the only ROS-enabled component inside the Gazebo process.

Adolfo Rodríguez T gravatar imageAdolfo Rodríguez T ( 2013-03-08 04:16:18 -0500 )edit

You should have posted this as an answer. :-) Anyway, if I remove all plugins I am using, Gazebo is still showing up as a ROS node and is publishing/subscribing to topics. AFAIK this requires a ros::init(). Am I missing something?

bit-pirate gravatar imagebit-pirate ( 2013-03-08 04:44:03 -0500 )edit

ROS wraps gazebo. So when you say you run gazebo, you're probably running a special gazebo script that loads in a plugin that in turn calls ros::init. Take a look in the simulator_gazebo package.

nkoenig gravatar imagenkoenig ( 2013-03-15 18:23:11 -0500 )edit

answered 2013-02-22 04:03:52 -0500

Boris gravatar image

I think in some cases it may fail. Most of the gazebo_ros_* plugins in ROS have the following code:

if (!ros::isInitialized())
  int argc = 0;
  char** argv = NULL;
  ros::init(argc, argv, "gazebo", ros::init_options::NoSigintHandler |

So, probably in your case ROS is just initialized already. Though, I am not sure what "initialized" means in this case.


edit flag offensive delete link more


This is no longer true, we have removed the fallback init() function from all gazebo plugins.

davetcoleman gravatar imagedavetcoleman ( 2013-07-29 11:52:36 -0500 )edit

answered 2013-07-26 18:10:00 -0500

davetcoleman gravatar image

updated 2017-02-20 18:46:39 -0500

The recommended way to check for ROS being initialized for all Gazebo plugins has been documented in this tutorial.

edit flag offensive delete link more


This contains useful background information. Thanks!

bit-pirate gravatar imagebit-pirate ( 2013-07-28 19:44:36 -0500 )edit

link is dead. Replace with http://gazebosim.org/tutorials?tut=ros_gzplugins probably

Peter Mitrano gravatar imagePeter Mitrano ( 2016-09-11 14:07:52 -0500 )edit

ive updated the link, thanks

davetcoleman gravatar imagedavetcoleman ( 2017-02-20 18:47:04 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2013-02-22 02:51:46 -0500

Seen: 2,572 times

Last updated: Feb 20