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

nodehandle parameter

asked 2018-12-05 13:43:40 -0600

zhonghao gravatar image

updated 2018-12-05 13:52:42 -0600

I am reading the tutorial on the website But I am not sure understand the following the _Default value version_.

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

// Default value version  
nh.param<std::string>("default_param", default_param, "default_value");

So in the _defalut value version_, nh.param does the same function as get parameter? What is the "default_param", default_param, "default_value"? The first "default_param" with double quotation means the name of parameter right? And the default_param without double quotation means: if the nodehandle "default_param" has a value ,then we pass the value to default_param? Otherwise we set the value of default_param to be "default_value" ?

Am I understand this correctly?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2018-12-05 23:29:47 -0600

Hamid Didari gravatar image

updated 2018-12-05 23:30:30 -0600

yes simply this command

nh.param<std::string>("param_name", variable, "value");

checks if param_name is exist the the command pass the value of param in variable but if the param doesn't exist then the command pass "value" to variable

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2018-12-05 13:43:40 -0600

Seen: 4,066 times

Last updated: Dec 05 '18