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

Dynamic reconfigure default parameters

asked 2012-02-23 09:01:43 -0500

updated 2013-04-05 01:42:17 -0500

Philip gravatar image

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()?
edit retag flag offensive close merge delete

Comments

1

Doesn't dynamic_reconfigure initialize the values from the param server automatically?

dornhege gravatar image dornhege  ( 2012-02-23 09:18:36 -0500 )edit

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.

Crusty gravatar image Crusty  ( 2014-04-14 02:40:50 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
14

answered 2012-02-23 09:37:10 -0500

Patrick Mihelich gravatar image

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.
edit flag offensive delete link more

Comments

1

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

PiotrOrzechowski gravatar image PiotrOrzechowski  ( 2014-01-21 05:33:34 -0500 )edit

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.

joq gravatar image joq  ( 2014-01-21 06:13:43 -0500 )edit
5

answered 2012-02-23 09:33:03 -0500

joq gravatar image

updated 2012-02-23 09:33:57 -0500

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

edit flag offensive delete link more

Question Tools

5 followers

Stats

Asked: 2012-02-23 09:01:43 -0500

Seen: 8,485 times

Last updated: Feb 23 '12