11 #ifndef __pid__PIDCONFIG_H__ 12 #define __pid__PIDCONFIG_H__ 38 virtual void toMessage(dynamic_reconfigure::Config& msg,
const PidConfig& config)
const = 0;
49 ParamDescription(std::string name, std::string type, uint32_t level, std::string description,
59 if (config.*field > max.*field)
60 config.*field = max.*field;
62 if (config.*field < min.*field)
63 config.*field = min.*field;
68 if (config1.*field != config2.*field)
84 return dynamic_reconfigure::ConfigTools::getParameter(msg, name, config.*field);
89 dynamic_reconfigure::ConfigTools::appendParameter(msg, name, config.*field);
113 virtual void toMessage(dynamic_reconfigure::Config& msg,
const boost::any& config)
const = 0;
114 virtual bool fromMessage(
const dynamic_reconfigure::Config& msg, boost::any& config)
const = 0;
115 virtual void updateParams(boost::any& cfg,
PidConfig& top)
const = 0;
116 virtual void setInitialState(boost::any& cfg)
const = 0;
120 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = abstract_parameters.begin();
121 i != abstract_parameters.end(); ++i)
123 parameters.push_back(dynamic_reconfigure::ParamDescription(**i));
131 template <
class T,
class PT>
143 parameters = g.parameters;
147 virtual bool fromMessage(
const dynamic_reconfigure::Config& msg, boost::any& cfg)
const 149 PT* config = boost::any_cast<PT*>(cfg);
150 if (!dynamic_reconfigure::ConfigTools::getGroupState(msg, name, (*config).*field))
153 for (std::vector<AbstractGroupDescriptionConstPtr>::const_iterator i =
groups.begin(); i !=
groups.end(); ++i)
155 boost::any n = &((*config).*field);
156 if (!(*i)->fromMessage(msg, n))
165 PT* config = boost::any_cast<PT*>(cfg);
166 T* group = &((*config).*field);
167 group->state =
state;
169 for (std::vector<AbstractGroupDescriptionConstPtr>::const_iterator i =
groups.begin(); i !=
groups.end(); ++i)
171 boost::any n = boost::any(&((*config).*field));
172 (*i)->setInitialState(n);
178 PT* config = boost::any_cast<PT*>(cfg);
180 T*
f = &((*config).*field);
181 f->setParams(top, abstract_parameters);
183 for (std::vector<AbstractGroupDescriptionConstPtr>::const_iterator i =
groups.begin(); i !=
groups.end(); ++i)
185 boost::any n = &((*config).*field);
186 (*i)->updateParams(n, top);
190 virtual void toMessage(dynamic_reconfigure::Config& msg,
const boost::any& cfg)
const 192 const PT config = boost::any_cast<PT>(cfg);
193 dynamic_reconfigure::ConfigTools::appendGroup<T>(msg, name, id, parent, config.*field);
195 for (std::vector<AbstractGroupDescriptionConstPtr>::const_iterator i =
groups.begin(); i !=
groups.end(); ++i)
197 (*i)->toMessage(msg, config.*field);
202 std::vector<PidConfig::AbstractGroupDescriptionConstPtr>
groups;
216 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator _i = params.begin(); _i != params.end(); ++_i)
219 (*_i)->getValue(config, val);
221 if (
"Kp_scale" == (*_i)->name)
223 Kp_scale = boost::any_cast<
double>(val);
225 if (
"Kp" == (*_i)->name)
227 Kp = boost::any_cast<
double>(val);
229 if (
"Ki_scale" == (*_i)->name)
231 Ki_scale = boost::any_cast<
double>(val);
233 if (
"Ki" == (*_i)->name)
235 Ki = boost::any_cast<
double>(val);
237 if (
"Kd_scale" == (*_i)->name)
239 Kd_scale = boost::any_cast<
double>(val);
241 if (
"Kd" == (*_i)->name)
243 Kd = boost::any_cast<
double>(val);
287 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin();
288 i != __param_descriptions__.end(); ++i)
289 if ((*i)->fromMessage(msg, *
this))
292 for (std::vector<AbstractGroupDescriptionConstPtr>::const_iterator i = __group_descriptions__.begin();
293 i != __group_descriptions__.end(); i++)
297 boost::any n = boost::any(
this);
298 (*i)->updateParams(n, *
this);
299 (*i)->fromMessage(msg, n);
303 if (count != dynamic_reconfigure::ConfigTools::size(msg))
305 ROS_ERROR(
"PidConfig::__fromMessage__ called with an unexpected parameter.");
307 for (
unsigned int i = 0; i < msg.bools.size(); i++)
308 ROS_ERROR(
" %s", msg.bools[i].name.c_str());
310 for (
unsigned int i = 0; i < msg.ints.size(); i++)
311 ROS_ERROR(
" %s", msg.ints[i].name.c_str());
313 for (
unsigned int i = 0; i < msg.doubles.size(); i++)
314 ROS_ERROR(
" %s", msg.doubles[i].name.c_str());
316 for (
unsigned int i = 0; i < msg.strs.size(); i++)
317 ROS_ERROR(
" %s", msg.strs[i].name.c_str());
328 const std::vector<AbstractParamDescriptionConstPtr>& __param_descriptions__,
329 const std::vector<AbstractGroupDescriptionConstPtr>& __group_descriptions__)
const 331 dynamic_reconfigure::ConfigTools::clear(msg);
332 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin();
333 i != __param_descriptions__.end(); ++i)
334 (*i)->toMessage(msg, *
this);
336 for (std::vector<AbstractGroupDescriptionConstPtr>::const_iterator i = __group_descriptions__.begin();
337 i != __group_descriptions__.end(); ++i)
341 (*i)->toMessage(msg, *
this);
350 __toMessage__(msg, __param_descriptions__, __group_descriptions__);
356 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin();
357 i != __param_descriptions__.end(); ++i)
358 (*i)->toServer(nh, *
this);
363 static bool setup =
false;
366 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin();
367 i != __param_descriptions__.end(); ++i)
368 (*i)->fromServer(nh, *
this);
371 for (std::vector<AbstractGroupDescriptionConstPtr>::const_iterator i = __group_descriptions__.begin();
372 i != __group_descriptions__.end(); i++)
374 if (!setup && (*i)->id == 0)
377 boost::any n = boost::any(
this);
378 (*i)->setInitialState(n);
388 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin();
389 i != __param_descriptions__.end(); ++i)
390 (*i)->clamp(*
this, __max__, __min__);
397 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin();
398 i != __param_descriptions__.end(); ++i)
399 (*i)->calcLevel(level, config, *
this);
430 __min__.Kp_scale = 0.1;
433 __max__.Kp_scale = 100.0;
436 __default__.Kp_scale = 10.0;
441 "{'enum_description': 'Scale factor for K setting', 'enum': " 442 "[{'srcline': 7, 'description': 'Scale by 0.1', 'srcfile': " 443 "'/home/andy/Desktop/catkin_ws/src/pid/cfg/Pid.cfg', " 444 "'cconsttype': 'const double', 'value': 0.1, 'ctype': " 445 "'double', 'type': 'double', 'name': 'scale_tenth'}, " 446 "{'srcline': 8, 'description': 'No scaling', 'srcfile': " 447 "'/home/andy/Desktop/catkin_ws/src/pid/cfg/Pid.cfg', " 448 "'cconsttype': 'const double', 'value': 1.0, 'ctype': " 449 "'double', 'type': 'double', 'name': 'scale_unity'}, " 450 "{'srcline': 9, 'description': 'Scale by 10', 'srcfile': " 451 "'/home/andy/Desktop/catkin_ws/src/pid/cfg/Pid.cfg', " 452 "'cconsttype': 'const double', 'value': 10.0, 'ctype': " 453 "'double', 'type': 'double', 'name': 'scale_ten'}, {'srcline': " 454 "10, 'description': 'Scale by 100', 'srcfile': " 455 "'/home/andy/Desktop/catkin_ws/src/pid/cfg/Pid.cfg', " 456 "'cconsttype': 'const double', 'value': 100.0, 'ctype': " 457 "'double', 'type': 'double', 'name': 'scale_hundred'}]}",
463 "{'enum_description': 'Scale factor for K setting', 'enum': " 464 "[{'srcline': 7, 'description': 'Scale by 0.1', 'srcfile': " 465 "'/home/andy/Desktop/catkin_ws/src/pid/cfg/Pid.cfg', " 466 "'cconsttype': 'const double', 'value': 0.1, 'ctype': " 467 "'double', 'type': 'double', 'name': 'scale_tenth'}, " 468 "{'srcline': 8, 'description': 'No scaling', 'srcfile': " 469 "'/home/andy/Desktop/catkin_ws/src/pid/cfg/Pid.cfg', " 470 "'cconsttype': 'const double', 'value': 1.0, 'ctype': " 471 "'double', 'type': 'double', 'name': 'scale_unity'}, " 472 "{'srcline': 9, 'description': 'Scale by 10', 'srcfile': " 473 "'/home/andy/Desktop/catkin_ws/src/pid/cfg/Pid.cfg', " 474 "'cconsttype': 'const double', 'value': 10.0, 'ctype': " 475 "'double', 'type': 'double', 'name': 'scale_ten'}, {'srcline': " 476 "10, 'description': 'Scale by 100', 'srcfile': " 477 "'/home/andy/Desktop/catkin_ws/src/pid/cfg/Pid.cfg', " 478 "'cconsttype': 'const double', 'value': 100.0, 'ctype': " 479 "'double', 'type': 'double', 'name': 'scale_hundred'}]}",
489 __default__.Kp = 0.1;
500 __min__.Ki_scale = 0.1;
503 __max__.Ki_scale = 100.0;
506 __default__.Ki_scale = 10.0;
511 "{'enum_description': 'Scale factor for K setting', 'enum': " 512 "[{'srcline': 7, 'description': 'Scale by 0.1', 'srcfile': " 513 "'/home/andy/Desktop/catkin_ws/src/pid/cfg/Pid.cfg', " 514 "'cconsttype': 'const double', 'value': 0.1, 'ctype': " 515 "'double', 'type': 'double', 'name': 'scale_tenth'}, " 516 "{'srcline': 8, 'description': 'No scaling', 'srcfile': " 517 "'/home/andy/Desktop/catkin_ws/src/pid/cfg/Pid.cfg', " 518 "'cconsttype': 'const double', 'value': 1.0, 'ctype': " 519 "'double', 'type': 'double', 'name': 'scale_unity'}, " 520 "{'srcline': 9, 'description': 'Scale by 10', 'srcfile': " 521 "'/home/andy/Desktop/catkin_ws/src/pid/cfg/Pid.cfg', " 522 "'cconsttype': 'const double', 'value': 10.0, 'ctype': " 523 "'double', 'type': 'double', 'name': 'scale_ten'}, {'srcline': " 524 "10, 'description': 'Scale by 100', 'srcfile': " 525 "'/home/andy/Desktop/catkin_ws/src/pid/cfg/Pid.cfg', " 526 "'cconsttype': 'const double', 'value': 100.0, 'ctype': " 527 "'double', 'type': 'double', 'name': 'scale_hundred'}]}",
533 "{'enum_description': 'Scale factor for K setting', 'enum': " 534 "[{'srcline': 7, 'description': 'Scale by 0.1', 'srcfile': " 535 "'/home/andy/Desktop/catkin_ws/src/pid/cfg/Pid.cfg', " 536 "'cconsttype': 'const double', 'value': 0.1, 'ctype': " 537 "'double', 'type': 'double', 'name': 'scale_tenth'}, " 538 "{'srcline': 8, 'description': 'No scaling', 'srcfile': " 539 "'/home/andy/Desktop/catkin_ws/src/pid/cfg/Pid.cfg', " 540 "'cconsttype': 'const double', 'value': 1.0, 'ctype': " 541 "'double', 'type': 'double', 'name': 'scale_unity'}, " 542 "{'srcline': 9, 'description': 'Scale by 10', 'srcfile': " 543 "'/home/andy/Desktop/catkin_ws/src/pid/cfg/Pid.cfg', " 544 "'cconsttype': 'const double', 'value': 10.0, 'ctype': " 545 "'double', 'type': 'double', 'name': 'scale_ten'}, {'srcline': " 546 "10, 'description': 'Scale by 100', 'srcfile': " 547 "'/home/andy/Desktop/catkin_ws/src/pid/cfg/Pid.cfg', " 548 "'cconsttype': 'const double', 'value': 100.0, 'ctype': " 549 "'double', 'type': 'double', 'name': 'scale_hundred'}]}",
559 __default__.Ki = 0.1;
570 __min__.Kd_scale = 0.1;
573 __max__.Kd_scale = 100.0;
576 __default__.Kd_scale = 10.0;
581 "{'enum_description': 'Scale factor for K setting', 'enum': " 582 "[{'srcline': 7, 'description': 'Scale by 0.1', 'srcfile': " 583 "'/home/andy/Desktop/catkin_ws/src/pid/cfg/Pid.cfg', " 584 "'cconsttype': 'const double', 'value': 0.1, 'ctype': " 585 "'double', 'type': 'double', 'name': 'scale_tenth'}, " 586 "{'srcline': 8, 'description': 'No scaling', 'srcfile': " 587 "'/home/andy/Desktop/catkin_ws/src/pid/cfg/Pid.cfg', " 588 "'cconsttype': 'const double', 'value': 1.0, 'ctype': " 589 "'double', 'type': 'double', 'name': 'scale_unity'}, " 590 "{'srcline': 9, 'description': 'Scale by 10', 'srcfile': " 591 "'/home/andy/Desktop/catkin_ws/src/pid/cfg/Pid.cfg', " 592 "'cconsttype': 'const double', 'value': 10.0, 'ctype': " 593 "'double', 'type': 'double', 'name': 'scale_ten'}, {'srcline': " 594 "10, 'description': 'Scale by 100', 'srcfile': " 595 "'/home/andy/Desktop/catkin_ws/src/pid/cfg/Pid.cfg', " 596 "'cconsttype': 'const double', 'value': 100.0, 'ctype': " 597 "'double', 'type': 'double', 'name': 'scale_hundred'}]}",
603 "{'enum_description': 'Scale factor for K setting', 'enum': " 604 "[{'srcline': 7, 'description': 'Scale by 0.1', 'srcfile': " 605 "'/home/andy/Desktop/catkin_ws/src/pid/cfg/Pid.cfg', " 606 "'cconsttype': 'const double', 'value': 0.1, 'ctype': " 607 "'double', 'type': 'double', 'name': 'scale_tenth'}, " 608 "{'srcline': 8, 'description': 'No scaling', 'srcfile': " 609 "'/home/andy/Desktop/catkin_ws/src/pid/cfg/Pid.cfg', " 610 "'cconsttype': 'const double', 'value': 1.0, 'ctype': " 611 "'double', 'type': 'double', 'name': 'scale_unity'}, " 612 "{'srcline': 9, 'description': 'Scale by 10', 'srcfile': " 613 "'/home/andy/Desktop/catkin_ws/src/pid/cfg/Pid.cfg', " 614 "'cconsttype': 'const double', 'value': 10.0, 'ctype': " 615 "'double', 'type': 'double', 'name': 'scale_ten'}, {'srcline': " 616 "10, 'description': 'Scale by 100', 'srcfile': " 617 "'/home/andy/Desktop/catkin_ws/src/pid/cfg/Pid.cfg', " 618 "'cconsttype': 'const double', 'value': 100.0, 'ctype': " 619 "'double', 'type': 'double', 'name': 'scale_hundred'}]}",
629 __default__.Kd = 0.1;
648 for (std::vector<PidConfig::AbstractGroupDescriptionConstPtr>::const_iterator i = __group_descriptions__.begin();
649 i != __group_descriptions__.end(); ++i)
651 __description_message__.groups.push_back(**i);
653 __max__.__toMessage__(__description_message__.max, __param_descriptions__, __group_descriptions__);
654 __min__.__toMessage__(__description_message__.min, __param_descriptions__, __group_descriptions__);
655 __default__.__toMessage__(__description_message__.dflt, __param_descriptions__, __group_descriptions__);
712 boost::mutex::scoped_lock lock(dynamic_reconfigure::__init_mutex__);
732 #endif // __PIDRECONFIGURATOR_H__ virtual void calcLevel(uint32_t &level, const PidConfig &config1, const PidConfig &config2) const =0
virtual void setInitialState(boost::any &cfg) const
void __toMessage__(dynamic_reconfigure::Config &msg) const
static const PidConfig & __getDefault__()
boost::shared_ptr< AbstractGroupDescription > AbstractGroupDescriptionPtr
void __toMessage__(dynamic_reconfigure::Config &msg, const std::vector< AbstractParamDescriptionConstPtr > &__param_descriptions__, const std::vector< AbstractGroupDescriptionConstPtr > &__group_descriptions__) const
static const std::vector< AbstractParamDescriptionConstPtr > & __getParamDescriptions__()
const double Pid_scale_hundred
static const PidConfigStatics * __get_statics__()
virtual void toServer(const ros::NodeHandle &nh, const PidConfig &config) const =0
static const std::vector< AbstractGroupDescriptionConstPtr > & __getGroupDescriptions__()
const double Pid_scale_tenth
virtual void getValue(const PidConfig &config, boost::any &val) const =0
AbstractParamDescription(std::string n, std::string t, uint32_t l, std::string d, std::string e)
GroupDescription(std::string name, std::string type, int parent, int id, bool s, T PT::*f)
virtual bool fromMessage(const dynamic_reconfigure::Config &msg, boost::any &cfg) const
virtual void getValue(const PidConfig &config, boost::any &val) const
static const PidConfig & __getMin__()
virtual bool fromMessage(const dynamic_reconfigure::Config &msg, PidConfig &config) const =0
boost::shared_ptr< const AbstractParamDescription > AbstractParamDescriptionConstPtr
dynamic_reconfigure::ConfigDescription __description_message__
std::vector< PidConfig::AbstractParamDescriptionConstPtr > __param_descriptions__
virtual bool fromMessage(const dynamic_reconfigure::Config &msg, PidConfig &config) const
void __toServer__(const ros::NodeHandle &nh) const
virtual void fromServer(const ros::NodeHandle &nh, PidConfig &config) const
AbstractGroupDescription(std::string n, std::string t, int p, int i, bool s)
virtual void toServer(const ros::NodeHandle &nh, const PidConfig &config) const
void setParams(PidConfig &config, const std::vector< AbstractParamDescriptionConstPtr > params)
static const PidConfigStatics * get_instance()
virtual void clamp(PidConfig &config, const PidConfig &max, const PidConfig &min) const
uint32_t __level__(const PidConfig &config) const
virtual void toMessage(dynamic_reconfigure::Config &msg, const PidConfig &config) const
const double Pid_scale_unity
static const PidConfig & __getMax__()
static const dynamic_reconfigure::ConfigDescription & __getDescriptionMessage__()
class pid::PidConfig::DEFAULT groups
bool getParam(const std::string &key, std::string &s) const
GroupDescription(const GroupDescription< T, PT > &g)
ParamDescription(std::string name, std::string type, uint32_t level, std::string description, std::string edit_method, T PidConfig::*f)
boost::shared_ptr< const AbstractGroupDescription > AbstractGroupDescriptionConstPtr
std::vector< AbstractParamDescriptionConstPtr > abstract_parameters
virtual void toMessage(dynamic_reconfigure::Config &msg, const PidConfig &config) const =0
void __fromServer__(const ros::NodeHandle &nh)
bool __fromMessage__(dynamic_reconfigure::Config &msg)
std::vector< PidConfig::AbstractGroupDescriptionConstPtr > groups
void setParam(const std::string &key, const XmlRpc::XmlRpcValue &v) const
virtual void toMessage(dynamic_reconfigure::Config &msg, const boost::any &cfg) const
virtual void updateParams(boost::any &cfg, PidConfig &top) const
boost::shared_ptr< AbstractParamDescription > AbstractParamDescriptionPtr
std::vector< PidConfig::AbstractGroupDescriptionConstPtr > __group_descriptions__
virtual void clamp(PidConfig &config, const PidConfig &max, const PidConfig &min) const =0
virtual void fromServer(const ros::NodeHandle &nh, PidConfig &config) const =0
virtual void calcLevel(uint32_t &comb_level, const PidConfig &config1, const PidConfig &config2) const
const double Pid_scale_ten