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

How can i acess my parameters from the dynamic reconfigure server ?

asked 2013-06-18 23:41:40 -0500

Stiebi gravatar image

updated 2014-01-28 17:16:58 -0500

ngrennan gravatar image

So I already read the tutorials about the dynamic reconfiguration, my problem now is that the tutorials use ros.spin() therefor as long as i dont change a value in the gui i dont get a callback and as a result my code just got stuck than.

I change the code now a bit to

int main(int argc, char **argv) {
 ros::init(argc, argv, "dynamic_tutorials");
  dynamic_reconfigure::Server<dynamic_tutorials::TutorialsConfig> server;
  dynamic_reconfigure::Server<dynamic_tutorials::TutorialsConfig>::CallbackType f;
  f = boost::bind(&callback, _1, _2);

  ROS_INFO("Spinning node");

 return 0;

well now i get the values each loop. but the problem is that at each loop the gui gets updated this makes it now imposible in the gui to change any value in a textbox like strings. changing sliders/checkboxes is working fine.

as I think its a problem with the server.setCallback function I wana know if there is an other way to get my parameters.


void callback(dynamic_tutorials::TutorialsConfig &config, uint32_t level) {
  ROS_INFO("Reconfigure Request: %d %f %s %s %d", 
            config.int_param, config.double_param, 
edit retag flag offensive close merge delete


Could you post your callback code too?

Dan Lazewatsky gravatar image Dan Lazewatsky  ( 2013-06-19 10:42:06 -0500 )edit

2 Answers

Sort by » oldest newest most voted

answered 2013-06-20 22:00:31 -0500

Why would you want to get a callback when nothing changes? Your dynamic reconfigure callback will be called:

  • once, when your node is loaded, to pass the initial parameter settings
  • after that only when something changes, e.g. through the GUI

I guess what you mean by "my code is stuck then" is that you put some other code into the callback that you want to have executed regularly (independent from whether a dynamic reconfigure setting changes). The solution is to simply put that code into your while (true) loop. And move the setCallback() call out of that loop, it should only be called once.

If you need to access the dynamic reconfigure config from your main code (you probably do), just save the config to a member variable in your callback and read that variable from your main loop.

edit flag offensive delete link more

answered 2021-12-27 05:21:00 -0500

Laura gravatar image

The callback function won't work if nothing changes. But if you want to get the params, you can also use ros::param in your code, the dynamic params can also be accessed on the param server with the same param name in dynamic_param server. Hope this helps you

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2013-06-18 23:41:40 -0500

Seen: 1,732 times

Last updated: Dec 27 '21