Do I always have to declare parameters?
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->declareparameter("bar");
node->declareparameter("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 getparameter() function is invoked, but it seems that I still need to declareparameter(). Do I always have to declare parameters whatever get or set parameters?
Asked by xhuan28 on 2019-06-17 02:45:13 UTC
Answers
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.
Asked by sloretz on 2019-06-17 11:33:32 UTC
Comments
https://index.ros.org/doc/ros2/Releases/Release-Dashing-Diademata/#declaring-parameters 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.
Asked by William on 2019-06-17 13:15:49 UTC
Thanks for your answers.@sloretz @William
Asked by xhuan28 on 2019-06-23 23:44:17 UTC
Comments