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

roscpp relative vs global parameter (tutorial)

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

ROSfc gravatar image

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

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
1

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

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 image ROSfc  ( 2016-09-05 07:43:05 -0500 )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 image ROSfc  ( 2016-09-05 07:53:02 -0500 )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 image dornhege  ( 2016-09-05 08:28:03 -0500 )edit

Question Tools

3 followers

Stats

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

Seen: 569 times

Last updated: Sep 05 '16