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

setNodeName in C++

asked 2012-09-04 15:14:19 -0600

sthunt gravatar image

updated 2012-09-04 15:25:58 -0600

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

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2012-09-04 22:00:57 -0600

weiin gravatar image

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

edit flag offensive delete link more
0

answered 2012-09-05 11:37:49 -0600

sthunt gravatar image

It was staring me right in the face. That worked perfectly - thank you very much!

edit flag offensive delete link more

Comments

1

@sthunt Please use the comment feature, not the Answer section for comments. And also please accept the above answer so others know it's solved.

tfoote gravatar image tfoote  ( 2012-09-05 11:51:58 -0600 )edit

Question Tools

Stats

Asked: 2012-09-04 15:14:19 -0600

Seen: 165 times

Last updated: Sep 05 '12