0
$\begingroup$

Rosanswers logo

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


Originally posted by Maya on ROS Answers with karma: 1172 on 2014-03-31

Post score: 0


Original comments

Comment by dornhege on 2014-03-31:
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.

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

Is this about each node accessing it's own parameters (not another node's)? In that case you should use 'private parameters' such that your code is agnostic about the actual node name and even additional layers of namespaces:

http://wiki.ros.org/roscpp/Overview/Parameter%20Server#Accessing_Private_Parameters


Originally posted by demmeln with karma: 4306 on 2014-03-31

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by Maya on 2014-03-31:
I used private parameters. This is exactly what I was searching for for. Thanks @demmeln and @dornhege

$\endgroup$
0
$\begingroup$

Rosanswers logo

Fix that:

my_node.param<std::string>("/source",source, "camera/rgb/image");

to (no "/"!)

my_node.param<std::string>("source",source, "camera/rgb/image");

If your my_node nodehandle is a private nodehandle, it will load the different private parameters.

Given that this looks like a parameter for a topic, there are probably better ways to do this that do not require loading parameters at all.


Originally posted by dornhege with karma: 31395 on 2014-03-31

This answer was NOT ACCEPTED on the original site

Post score: 2


Original comments

Comment by Maya on 2014-03-31:
I'll use the same syntax for other parameter like where to load a model. For the topic parameter I will change it to a default value that need to be remap in the launcher would it be better ?

Comment by dornhege on 2014-03-31:
That's usually the simpler way.

$\endgroup$

Your Answer

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