2 #include <boost/make_unique.hpp>
6 : node_handle_(nh), advertised_(false), auto_update_(auto_update), new_config_avail_(false)
23 "parameter_descriptions", 1,
true);
28 for (
const auto &g : config_description.groups)
71 const std::string &description, T min, T max,
72 const std::string &group)
79 const std::string &description,
80 std::map<std::string, T> enum_dict,
81 const std::string &enum_description,
82 const std::string &group)
89 const boost::function<
void(T value)> &callback,
90 const std::string &description, T min, T max,
91 const std::string &group)
95 name, description,
min, max, variable, callback, std::map<std::string, T>(),
"", group));
100 const boost::function<
void(T value)> &callback,
101 const std::string &description,
102 std::map<std::string, T> enum_dict,
103 const std::string &enum_description,
104 const std::string &group)
110 name, description,
min, max, variable, callback, enum_dict, enum_description, group));
113 template <
typename T>
115 const boost::function<
void(T value)> &callback,
116 const std::string &description, T min, T max,
117 const std::string &group)
121 name, description,
min, max, current_value, callback, std::map<std::string, T>(),
"", group));
125 template <
typename T>
127 const boost::function<
void(T)> &callback,
128 const std::string &description,
129 std::map<std::string, T> enum_dict,
130 const std::string &enum_description,
131 const std::string &group)
137 name, description,
min, max, current_value, callback, enum_dict, enum_description, group));
140 template <
typename ParamType>
143 return (a.name == b.name) && (a.value == b.value);
148 const dynamic_reconfigure::DoubleParameter &b)
150 return (a.name == b.name) &&
151 (std::fabs(a.value - b.value) < std::numeric_limits<double>::epsilon());
158 bool has_changed =
false;
159 has_changed = has_changed || config_msg.ints.size() !=
last_config_.ints.size();
160 has_changed = has_changed || config_msg.doubles.size() !=
last_config_.doubles.size();
161 has_changed = has_changed || config_msg.bools.size() !=
last_config_.bools.size();
163 has_changed = has_changed ||
164 !std::equal(config_msg.ints.begin(), config_msg.ints.end(),
166 confCompare<dynamic_reconfigure::IntParameter>);
167 has_changed = has_changed ||
168 !std::equal(config_msg.doubles.begin(), config_msg.doubles.end(),
170 confCompare<dynamic_reconfigure::DoubleParameter>);
171 has_changed = has_changed ||
172 !std::equal(config_msg.bools.begin(), config_msg.bools.end(),
174 confCompare<dynamic_reconfigure::BoolParameter>);
185 dynamic_reconfigure::Reconfigure::Response &rsp)
208 "Timeout waiting to update the registered variable data! Registered Variable data update failed!");
246 catch (std::exception &e)
248 ROS_WARN(
"Reconfigure callback failed with exception %s: ", e.what());
252 ROS_WARN(
"Reconfigure callback failed with unprintable exception.");
258 rsp.config = config_msg;
266 for (
unsigned int i = 0; i < config.ints.size(); ++i)
273 for (
unsigned int i = 0; i < config.doubles.size(); ++i)
277 ROS_ERROR_STREAM(
"Variable :" << config.doubles[i].name <<
" not registered");
280 for (
unsigned int i = 0; i < config.bools.size(); ++i)
284 ROS_ERROR_STREAM(
"Variable :" << config.bools[i].name <<
" not registered");
287 for (
unsigned int i = 0; i < config.strs.size(); ++i)
323 dynamic_reconfigure::ConfigDescription config_description;
325 std::map<std::string, dynamic_reconfigure::Group> groups;
332 auto &gp = groups[ri.
group_];
333 gp.parameters.push_back(p);
336 dynamic_reconfigure::IntParameter ip;
339 config_description.dflt.ints.push_back(ip);
341 config_description.max.ints.push_back(ip);
343 config_description.min.ints.push_back(ip);
351 auto &gp = groups[rd.
group_];
352 gp.parameters.push_back(p);
354 dynamic_reconfigure::DoubleParameter dp;
357 config_description.dflt.doubles.push_back(dp);
359 config_description.max.doubles.push_back(dp);
361 config_description.min.doubles.push_back(dp);
369 auto &gp = groups[rb.
group_];
370 gp.parameters.push_back(p);
373 dynamic_reconfigure::BoolParameter bp;
376 config_description.dflt.bools.push_back(bp);
378 config_description.max.bools.push_back(bp);
380 config_description.min.bools.push_back(bp);
387 auto &gp = groups[rs.
group_];
388 gp.parameters.push_back(p);
391 dynamic_reconfigure::StrParameter sp;
394 config_description.dflt.strs.push_back(sp);
396 config_description.max.strs.push_back(sp);
398 config_description.min.strs.push_back(sp);
401 auto default_group = groups[
"Default"];
402 default_group.name =
"Default";
403 config_description.groups.push_back(default_group);
405 dynamic_reconfigure::GroupState default_gs;
406 default_gs.name =
"Default";
407 default_gs.state =
true;
408 config_description.dflt.groups.push_back(default_gs);
409 config_description.min.groups.push_back(default_gs);
410 config_description.max.groups.push_back(default_gs);
413 for (
auto &group : groups)
415 if (group.first ==
"Default")
419 group.second.name = group.first;
420 group.second.type =
"tab";
421 group.second.id = i++;
422 config_description.groups.push_back(group.second);
424 dynamic_reconfigure::GroupState gs;
425 gs.id = group.second.id;
426 gs.name = group.second.name;
428 config_description.dflt.groups.push_back(gs);
429 config_description.min.groups.push_back(gs);
430 config_description.max.groups.push_back(gs);
432 return config_description;
438 dynamic_reconfigure::Config c;
442 dynamic_reconfigure::IntParameter ip;
445 c.ints.push_back(ip);
450 dynamic_reconfigure::DoubleParameter dp;
453 c.doubles.push_back(dp);
458 dynamic_reconfigure::BoolParameter bp;
461 c.bools.push_back(bp);
466 dynamic_reconfigure::StrParameter bs;
469 c.strs.push_back(bs);
474 dynamic_reconfigure::GroupState gs;
478 c.groups.push_back(gs);
502 const std::string &description,
int min,
503 int max,
const std::string &group);
507 const std::string &description,
508 std::map<std::string, int> enum_dict,
509 const std::string &enum_description,
510 const std::string &group);
512 const boost::function<
void(
int value)> &callback,
513 const std::string &description,
int min,
514 int max,
const std::string &group);
517 const std::string &name,
int current_value,
const boost::function<
void(
int)> &callback,
518 const std::string &description, std::map<std::string, int> enum_dict,
519 const std::string &enum_description,
const std::string &group);
524 const std::string &description,
double min,
525 double max,
const std::string &group);
529 const std::string &description,
530 std::map<std::string, double> enum_dict,
531 const std::string &enum_description,
532 const std::string &group);
534 const std::string &name,
double current_value,
535 const boost::function<
void(
double value)> &callback,
const std::string &description,
536 double min,
double max,
const std::string &group);
539 const std::string &name,
double current_value,
const boost::function<
void(
double)> &callback,
540 const std::string &description, std::map<std::string, double> enum_dict,
541 const std::string &enum_description,
const std::string &group);
547 const std::string &description,
bool min,
548 bool max,
const std::string &group);
552 const std::string &description,
553 std::map<std::string, bool> enum_dict,
554 const std::string &enum_description,
555 const std::string &group);
557 const boost::function<
void(
bool value)> &callback,
558 const std::string &description,
bool min,
559 bool max,
const std::string &group);
562 const std::string &name,
bool current_value,
const boost::function<
void(
bool)> &callback,
563 const std::string &description, std::map<std::string, bool> enum_dict,
564 const std::string &enum_description,
const std::string &group);
569 const std::string &description,
570 std::string min, std::string max,
571 const std::string &group);
575 const std::string &name, std::string *variable,
const std::string &description,
576 std::map<std::string, std::string> enum_dict,
const std::string &enum_description,
577 const std::string &group);
579 const std::string &name, std::string current_value,
580 const boost::function<
void(std::string value)> &callback,
const std::string &description,
581 std::string min, std::string max,
const std::string &group);
584 const std::string &name, std::string current_value,
585 const boost::function<
void(std::string)> &callback,
const std::string &description,
586 std::map<std::string, std::string> enum_dict,
const std::string &enum_description,
587 const std::string &group);