0
$\begingroup$

Rosanswers logo

Hi,

Please pardon me if this is a stupid question. It has been a while since I have used ROS. I have a talker/listener framework setup, but ideally, I would like to have one talker communicate with multiple listeners using the same codebase (by changing the name of the listener node with an argument). When I try to run multiple listeners now, the listener that was active shutdowns because "a new node registered with the same name".

I see here: http://answers.ros.org/question/33358/node-name-collision-with-multiple-talker-node-instances/ that it was a similar problem and the answer was to set the name using a node configuration.

I am trying to write this in C++ and I searched through all of my header files, but I do not see that function anywhere. I see that function mentioned in rosjava (http://www.roschina.net/ros/www.ros.org/wiki/doc/api/rosjava/html/classorg_1_1ros_1_1node_1_1NodeConfiguration.html).

Thank you very much.

Shawn


Originally posted by sthunt on ROS Answers with karma: 1 on 2012-09-04

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

A few ways to do it, one of the better ones is to anonymize the node name as mentioned by Dan in the link you provided. See http://www.ros.org/wiki/roscpp/Overview/Initialization%20and%20Shutdown#Initialization_Options

You could also hardcode different names for each listener (not good idea since you'll have multiple source code doing essentially the same thing), or remap the node name at runtime. See http://www.ros.org/wiki/roscpp/Overview/Initialization%20and%20Shutdown#Initializing_the_roscpp_Node


Originally posted by weiin with karma: 2268 on 2012-09-04

This answer was ACCEPTED on the original site

Post score: 2

$\endgroup$

Your Answer

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