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

dynamic_reconfigure group defaults

asked 2015-07-09 14:38:33 -0600

thebyohazard gravatar image

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

Comments

any update on this?

ffurrer gravatar image ffurrer  ( 2016-06-07 06:22:33 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2016-06-07 08:24:37 -0600

ffurrer gravatar image

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

edit flag offensive delete link more

Question Tools

5 followers

Stats

Asked: 2015-07-09 14:38:33 -0600

Seen: 1,952 times

Last updated: Jun 07 '16