0
$\begingroup$

Rosanswers logo

I am writing a node which accepts certain parameters. I would like to be able to pass them through a launch file, as well as make them dynamically reconfigurable.

What are the best practices regarding this? In particular:

  • What happens if the value in the launch file is not the same as the default value in the .cfg file?
  • Does it matter whether I register the dynamic reconfigure services before or after getting the parameters from the nodehandle using getParam()?

Originally posted by Ivan Dryanovski on ROS Answers with karma: 4954 on 2012-02-23

Post score: 9


Original comments

Comment by dornhege on 2012-02-23:
Doesn't dynamic_reconfigure initialize the values from the param server automatically?

Comment by Crusty on 2014-04-14:
It would, but in configurations with "use_sim_time" and "rosbag play foo.bag --clock --pause" and then stepping through the bag file for debugging you potentially run into problems because no spinning seems to take place on sim_time, so no ros::spin()-based callbacks are called.

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

You should already get the desired behavior for free. When you create the dynamic_reconfigure server in your node, it initializes the configuration in these steps:

  • Load default values as defined in the .cfg.
  • Query parameter server for each parameter, overwriting the default value if it's set.
  • Clamp all parameters to the ranges defined in the .cfg.

Originally posted by Patrick Mihelich with karma: 4336 on 2012-02-23

This answer was ACCEPTED on the original site

Post score: 14


Original comments

Comment by PiotrOrzechowski on 2014-01-21:
You're right! Unfortunately the ROSNodeTutorialC++ (http://wiki.ros.org/ROSNodeTutorialC%2B%2B) is misleading: It reads the parameters "a", "b" and "message" explicitly from the parameter server even though they are included in the dynamic reconfigure callback...

Comment by joq on 2014-01-21:
That tutorial may very well be in error. Please open a separate question explaining the problem, so we can get it resolved, as explained in the note at the top of each tutorial page.

$\endgroup$
0
$\begingroup$

Rosanswers logo

Dynamic reconfiguration works fine for your use case.

When you register your callback, it gets invoked immediately with the values currently defined in the parameter server and a level of 0xffffffff. Those initial values will include anything set in your launch file. You don't need to read the parameters yourself using getParam().


Originally posted by joq with karma: 25443 on 2012-02-23

This answer was NOT ACCEPTED on the original site

Post score: 5

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.