Using the same node twice
Hellows,
Another designing question under ROS. I have a node that I programmed, it used param from the Param Server and subscribe to a topic and publish two topics.
I wish to launch to node twice using a launch file. All my parameters arr in yaml file. But I can't find any way for the code in C++ to go search the parameters in two different namespace without compiling two executable with just the namespace of difference in the getParam()
function and it really is not optimal.
For now my function look like :
my_node.param<std::string>("/namespace1/source",source, "camera/rgb/image");
Is there any way to not need the name space hard coded ?
[EDIT]
I'll try to be more precise :).
For example I use the <remap> tag to remap the topic that are given by the two nodes. So I have "topic1" and "topic2". That is ok.
But now I want to publish parameters which have the same name but associated to each node. Let's say a parameter name /source for each of the node but under the namespace Node1/source, Node/source. This can be done with the launch file, I just need to load two yaml file or so. But now for now, my code to get in the param in my C++ code is like this
my_node.param<std::string>("/Node1/source",source, "camera/rgb/image");
for the first one
my_node.param<std::string>("/Node2/source",source, "camera/rgb/image");
for the second one.
I'm wondering if there is a way to right
my_node.param<std::string>("/source",source, "camera/rgb/image");
And the node would understand by itself that it's either Node1/source or Node2/source that they need.
Hope I have been clearer. Thanks a lot =)
It's definitely possible. Can you be more concrete on what your resulting setup should look like, i.e. which topics would you like to have for each node and where should the names come from? It looks to me as if you might not need any parameters and can do everything from launch files.