Ask Your Question

nodehandle parameter

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

zhonghao gravatar image

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

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

Hamid Didari gravatar image

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

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

Your Answer

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

Add Answer

Question Tools

1 follower


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

Seen: 2,054 times

Last updated: Dec 05 '18