ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

In Roscpp, can I access parameters from different nodes?

asked 2015-06-24 15:49:32 -0600

thailor3 gravatar image

Example: I have always the same node type, lets say with a parameter named "shape"

I make one node (node A) with shape = "square"

I make a second node (node B) with shape = "circle"

in the console if i did rosparam list i would see /nodeA/shape /nodeB/shape

and if i did rosparam get /nodeA/shape i would see "Square", but is it possible in my test file, my cpp file, to use some form of get parameter when creating a node, so that I can see that node A shape is "Square"? pseudocode:

    if(&newNode/shape == &nodeA/shape)
              kill(newNode, SIGINT)

Overall, i want to be able to test and see if a value of the parameter exists, and then if it exists, i will do a kill(pid, SIGINT).

But i am having a hard time accessing the parameter value of the other nodes.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2015-06-24 20:31:38 -0600

joq gravatar image

ROScpp provides a getParam() interface on the nodeHandle. It accepts "global" (fully qualified) names beginning with a /, as well as "private" names relative to that node.

edit flag offensive delete link more



so in order to get any node's param on the rosparam server, then i can do getParam()? for instance if i have the list of params: /image1/cam1/1 /image1/cam1/2 /image2/cam2/1 /image2/cam2/2

and i am launching another node that will spawn the paramters /image3/cam3/1, i do getParam("/image1/cam1/1")?

thailor3 gravatar image thailor3  ( 2015-06-25 15:44:22 -0600 )edit

Correct! Every node has access to the gull parameter server. You just have to get the names correct.

mgruhler gravatar image mgruhler  ( 2015-06-26 02:13:14 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2015-06-24 15:49:32 -0600

Seen: 1,272 times

Last updated: Jun 24 '15