ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

How to change g_initialized in ros::init

asked 2015-11-04 09:02:23 -0500

VenusRobot gravatar image


I'm developing a QT interface to manage two or more robots, each having its own ros master (this is mandatory). My QT interface consists of a qtalker, and I'd like to switch it runtime from a robot to another (i.e. from a ros master to another). To do so, I shutdown the current qtalker node, and then I restart it (runtime) calling again ros::init after passing it new master IP/port in remappings. The problem I find is that new parameters are not received, so that old master is again linked to qtalker.

I found, in init.cpp, the static variable "g_initialized", which is set to "true" the first time ros::init is called, and than doesn't allow new remappings are read the second time ros::init is called. I think this is the reason for which the new master cannot be linked.

Two questions:

1) Am I right?

2) There is any workaround?

Thanks very much


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2015-11-04 10:41:18 -0500

dornhege gravatar image

Someone correct me if I'm wrong, but as far as I know switching the master context in code is not supported, although it would be nice.

edit flag offensive delete link more


You're probably right, I'm quite new in Ros. Nevertheless it would be interesting to know if it would be possible to edit init.cpp (in order to modify g_initialized behaviour) or if it is strictly forbidden (e. g. due to known/unknown side effects).

VenusRobot gravatar image VenusRobot  ( 2015-11-05 02:46:10 -0500 )edit

My feeling would be that that is not safe, because otherwise the feature might have been exposed. However, that is something to be answered by the ROS developers.

dornhege gravatar image dornhege  ( 2015-11-05 04:13:25 -0500 )edit

I agree with you, I look forward to a ROS developers answer. Thank you

VenusRobot gravatar image VenusRobot  ( 2015-11-05 04:41:06 -0500 )edit

Question Tools


Asked: 2015-11-04 09:02:23 -0500

Seen: 124 times

Last updated: Nov 04 '15