Ask Your Question
0

Do I always have to declare parameters?

asked 2019-06-17 02:45:13 -0500

xhuan28 gravatar image

declare_parameter() is a new API in dashing release. Per my understanding from parameter demos,

// Declare parameters that may be set on this node
node->declare_parameter("bar");
node->declare_parameter("foo");

we have to declare a parameter if we want to set this parameter in a node. But when I develop a node in which only get_parameter() function is invoked, but it seems that I still need to declare_parameter(). Do I always have to declare parameters whatever get or set parameters?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-06-17 11:33:32 -0500

sloretz gravatar image

By default yes you must declare parameters, but there is an option to opt out. To opt out, set allow_undeclared_parameters to true. Here is an example.

In many cases you know all the parameters that your node can use. In these cases you should use the default behavior and declare your parameters.

edit flag offensive delete link more

Comments

https://index.ros.org/doc/ros2/Releas... also covers this. Also, the example you link to also sets the automatically_declare_parameters_from_overrides which is needed if you want the pre-Dashing behavior.

William gravatar imageWilliam ( 2019-06-17 13:15:49 -0500 )edit

Thanks for your answers.@sloretz@William

xhuan28 gravatar imagexhuan28 ( 2019-06-23 23:44:17 -0500 )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

2 followers

Stats

Asked: 2019-06-17 02:45:13 -0500

Seen: 115 times

Last updated: Jun 17