0
$\begingroup$

Gazebo Answers logo

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).


Originally posted by bit-pirate on Gazebo Answers with karma: 129 on 2013-02-22

Post score: 1

$\endgroup$

3 Answers 3

0
$\begingroup$

Gazebo Answers logo

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


Originally posted by nkoenig with karma: 7676 on 2013-03-07

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by bit-pirate on 2013-03-08:
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.

Comment by Adolfo Rodríguez T on 2013-03-08:
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.

Comment by bit-pirate on 2013-03-08:
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?

Comment by nkoenig on 2013-03-15:
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.

$\endgroup$
0
$\begingroup$

Gazebo Answers logo

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 |
                                  ros::init_options::AnonymousName);
}

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

Boris


Originally posted by Boris with karma: 330 on 2013-02-22

This answer was NOT ACCEPTED on the original site

Post score: 2


Original comments

Comment by davetcoleman on 2013-07-29:
This is no longer true, we have removed the fallback init() function from all gazebo plugins.

$\endgroup$
0
$\begingroup$

Gazebo Answers logo

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


Originally posted by davetcoleman with karma: 369 on 2013-07-26

This answer was NOT ACCEPTED on the original site

Post score: 2


Original comments

Comment by bit-pirate on 2013-07-28:
This contains useful background information. Thanks!

Comment by Peter Mitrano on 2016-09-11:
link is dead. Replace with http://gazebosim.org/tutorials?tut=ros_gzplugins probably

Comment by davetcoleman on 2017-02-20:
ive updated the link, thanks

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.