ROS Resources: Documentation | Support | Discussion Forum | Service Status | Q&A answers.ros.org
Ask Your Question
0

roscpp relative vs global parameter (tutorial)

asked 2016-09-01 10:10:58 -0600

ROSfc gravatar image

updated 2016-09-05 03:33:03 -0600

Hello,

I thought I understood the concept of global and relative. But apparently while doing the tutorial

ros::NodeHandle nh;
std::string global_name, relative_name, default_param;
if (nh.getParam("/global_name", global_name))
{
  ...
}

 if (nh.getParam("relative_name", relative_name))
{
 ... 
}

I expect that if my global name is /bla and my param is /bla/param1. I could simply use the second if loop with getParam("param1",relative_name), But this doesn't work.

here is the solution which requires you to instantiate a private node handle.

My question now is what does the tutorial mean then by relative name ? and relative to what ? because it doesn't work relative to my node name.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-09-05 06:38:24 -0600

dornhege gravatar image

I don't know what tutorial you are referring to, but relative names are relative to ROS namespaces, i.e., if the node has been pushed into a namespace /bla. For parameters that are in the namespace of a node, using a private node handle is the right way to go.

edit flag offensive delete link more

Comments

I still didn't understand sorry. Could you explain it with example names maybe. It would be a big big help Here is the link to the tutorial

ROSfc gravatar imageROSfc ( 2016-09-05 07:43:05 -0600 )edit

I have also tried to look at this link on resolving names but they all look the same. In this example /wg/node3/foo/bar where wg is the namespace could you explain what is relative name ?

ROSfc gravatar imageROSfc ( 2016-09-05 07:53:02 -0600 )edit

If your node is named foo and pushed in a namespace bar, the parameter '/baz' (global) should resolve to '/baz'. The parameter 'baz' (relative) should resolve to '/bar/baz' and the lookup for 'baz' in a private nh should give '/bar/foo/baz'.

dornhege gravatar imagedornhege ( 2016-09-05 08:28:03 -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

3 followers

Stats

Asked: 2016-09-01 10:10:58 -0600

Seen: 86 times

Last updated: Sep 05 '16