Ask Your Question
7

Dynamic reconfigure default parameters

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

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

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 imagedornhege ( 2012-02-23 09:18:36 -0600 )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 imageCrusty ( 2014-04-14 02:40:50 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted
11

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

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 imagePiotrOrzechowski ( 2014-01-21 05:33:34 -0600 )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 imagejoq ( 2014-01-21 06:13:43 -0600 )edit
5

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

joq gravatar image

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

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

Your Answer

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

Add Answer

Question Tools

5 followers

Stats

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

Seen: 5,852 times

Last updated: Feb 23 '12