0
$\begingroup$

Rosanswers logo

I stumbled upon the not-quite-as-well-documented feature of dynamic_reconfigure groups.

As I understand, whenever you set up a server, it should call the callback and initialize the config parameter with the values found in the cfg file. However, my groups are not being set to defaults, only my "bare" parameters are. If I change one of the group parameters, then the change takes effect.

Is there something I'm missing, or should I file a ticket?

(btw this ticket mentions inconsistent behavior, but it's talking about states rather than defaults, so I'm not sure it's related.)

void dynamic_cb(pkgConfig &config, uint32_t){
        a = Duration(config.a);
        b1 = config.groups.b.part1;
        b2 = config.groups.b.part2;
}

cfg file:

gen.add("a", double_t, 0, "a_description", 1, 0, 10000)
group = gen.add_group("b")
group.add("part1", double_t, 0, "b1", 3.0, 0.0, 10.0)
group.add("part2", double_t, 0, "b2", 3.0, 0.0, 10.0)

Originally posted by thebyohazard on ROS Answers with karma: 3562 on 2015-07-09

Post score: 4


Original comments

Comment by ffurrer on 2016-06-07:
any update on this?

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Ok, I figured it out :).

In the current implementation the generated <name>Config class contains the variables of all groups as members directly. The ones under the corresponding group (class), the ones you (and I as well) accessed, never get assigned the default values.

So what you should do instead (at least until this code gets cleaned up):

void dynamic_cb(pkgConfig &config, uint32_t){
  a = Duration(config.a);
  b1 = config.part1;
  b2 = config.part2;
}

You can take a look at the implementation of the code generator here.

Just adding this small note here: you can also not add parameters with the same name to different groups, as they would get the same variable name in the main <name>Config class.

Cheers


Originally posted by ffurrer with karma: 115 on 2016-06-07

This answer was ACCEPTED on the original site

Post score: 2

$\endgroup$

Your Answer

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