46 #ifndef __ompl_interface_ros__OMPLDYNAMICRECONFIGURECONFIG_H__ 47 #define __ompl_interface_ros__OMPLDYNAMICRECONFIGURECONFIG_H__ 49 #include <dynamic_reconfigure/config_tools.h> 53 #include <dynamic_reconfigure/ConfigDescription.h> 54 #include <dynamic_reconfigure/ParamDescription.h> 55 #include <dynamic_reconfigure/Group.h> 56 #include <dynamic_reconfigure/config_init_mutex.h> 57 #include <boost/any.hpp> 94 ParamDescription(std::string name, std::string type, uint32_t level, std::string description,
105 if (config.*field > max.*field)
106 config.*field = max.*field;
108 if (config.*field < min.*field)
109 config.*field = min.*field;
115 if (config1.*field != config2.*field)
131 return dynamic_reconfigure::ConfigTools::getParameter(msg, name, config.*field);
136 dynamic_reconfigure::ConfigTools::appendParameter(msg, name, config.*field);
161 virtual void toMessage(dynamic_reconfigure::Config& msg,
const boost::any& config)
const = 0;
162 virtual bool fromMessage(
const dynamic_reconfigure::Config& msg, boost::any& config)
const = 0;
164 virtual void setInitialState(boost::any& cfg)
const = 0;
168 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = abstract_parameters.begin();
169 i != abstract_parameters.end(); i++)
171 parameters.push_back(dynamic_reconfigure::ParamDescription(**i));
176 template <
class T,
class PT>
188 parameters = g.parameters;
192 virtual bool fromMessage(
const dynamic_reconfigure::Config& msg, boost::any& cfg)
const 194 PT* config = boost::any_cast<PT*>(cfg);
195 if (!dynamic_reconfigure::ConfigTools::getGroupState(msg, name, (*config).*field))
198 for (std::vector<AbstractGroupDescriptionConstPtr>::const_iterator i =
groups.begin(); i !=
groups.end(); i++)
200 boost::any n = &((*config).*field);
201 if (!(*i)->fromMessage(msg, n))
210 PT* config = boost::any_cast<PT*>(cfg);
211 T* group = &((*config).*field);
212 group->state = state;
214 for (std::vector<AbstractGroupDescriptionConstPtr>::const_iterator i =
groups.begin(); i !=
groups.end(); i++)
216 boost::any n = boost::any(&((*config).*field));
217 (*i)->setInitialState(n);
223 PT* config = boost::any_cast<PT*>(cfg);
225 T*
f = &((*config).*field);
226 f->setParams(top, abstract_parameters);
228 for (std::vector<AbstractGroupDescriptionConstPtr>::const_iterator i =
groups.begin(); i !=
groups.end(); i++)
230 boost::any n = &((*config).*field);
231 (*i)->updateParams(n, top);
235 virtual void toMessage(dynamic_reconfigure::Config& msg,
const boost::any& cfg)
const 237 const PT config = boost::any_cast<PT>(cfg);
238 dynamic_reconfigure::ConfigTools::appendGroup<T>(msg, name, id, parent, config.*field);
240 for (std::vector<AbstractGroupDescriptionConstPtr>::const_iterator i =
groups.begin(); i !=
groups.end(); i++)
242 (*i)->toMessage(msg, config.*field);
247 std::vector<OMPLDynamicReconfigureConfig::AbstractGroupDescriptionConstPtr>
groups;
261 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = params.begin(); i != params.end(); i++)
264 (*i)->getValue(config, val);
266 if (
"link_for_exploration_tree" == (*i)->name)
290 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin();
291 i != __param_descriptions__.end(); i++)
292 if ((*i)->fromMessage(msg, *
this))
295 for (std::vector<AbstractGroupDescriptionConstPtr>::const_iterator i = __group_descriptions__.begin();
296 i != __group_descriptions__.end(); i++)
300 boost::any n = boost::any(
this);
301 (*i)->updateParams(n, *
this);
302 (*i)->fromMessage(msg, n);
306 if (count != dynamic_reconfigure::ConfigTools::size(msg))
308 ROS_ERROR(
"OMPLDynamicReconfigureConfig::__fromMessage__ called with an unexpected parameter.");
310 for (
unsigned int i = 0; i < msg.bools.size(); i++)
311 ROS_ERROR(
" %s", msg.bools[i].name.c_str());
313 for (
unsigned int i = 0; i < msg.ints.size(); i++)
314 ROS_ERROR(
" %s", msg.ints[i].name.c_str());
316 for (
unsigned int i = 0; i < msg.doubles.size(); i++)
317 ROS_ERROR(
" %s", msg.doubles[i].name.c_str());
319 for (
unsigned int i = 0; i < msg.strs.size(); i++)
320 ROS_ERROR(
" %s", msg.strs[i].name.c_str());
331 const std::vector<AbstractParamDescriptionConstPtr>& __param_descriptions__,
332 const std::vector<AbstractGroupDescriptionConstPtr>& __group_descriptions__)
const 334 dynamic_reconfigure::ConfigTools::clear(msg);
335 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin();
336 i != __param_descriptions__.end(); i++)
337 (*i)->toMessage(msg, *
this);
339 for (std::vector<AbstractGroupDescriptionConstPtr>::const_iterator i = __group_descriptions__.begin();
340 i != __group_descriptions__.end(); i++)
344 (*i)->toMessage(msg, *
this);
353 __toMessage__(msg, __param_descriptions__, __group_descriptions__);
359 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin();
360 i != __param_descriptions__.end(); i++)
361 (*i)->toServer(nh, *
this);
366 static bool setup =
false;
369 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin();
370 i != __param_descriptions__.end(); i++)
371 (*i)->fromServer(nh, *
this);
374 for (std::vector<AbstractGroupDescriptionConstPtr>::const_iterator i = __group_descriptions__.begin();
375 i != __group_descriptions__.end(); i++)
377 if (!setup && (*i)->id == 0)
380 boost::any n = boost::any(
this);
381 (*i)->setInitialState(n);
391 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin();
392 i != __param_descriptions__.end(); i++)
393 (*i)->clamp(*
this, __max__, __min__);
400 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin();
401 i != __param_descriptions__.end(); i++)
402 (*i)->calcLevel(level, config, *
this);
435 __min__.link_for_exploration_tree =
"";
437 __max__.link_for_exploration_tree =
"";
439 __default__.link_for_exploration_tree =
"";
441 Default.
abstract_parameters.push_back(OMPLDynamicReconfigureConfig::AbstractParamDescriptionConstPtr(
443 "link_for_exploration_tree",
"str", 1,
"Show the exploration tree for a particular link",
"",
446 __param_descriptions__.push_back(OMPLDynamicReconfigureConfig::AbstractParamDescriptionConstPtr(
448 "link_for_exploration_tree",
"str", 1,
"Show the exploration tree for a particular link",
"",
453 __group_descriptions__.push_back(OMPLDynamicReconfigureConfig::AbstractGroupDescriptionConstPtr(
458 for (std::vector<OMPLDynamicReconfigureConfig::AbstractGroupDescriptionConstPtr>::const_iterator i =
459 __group_descriptions__.begin();
460 i != __group_descriptions__.end(); i++)
462 __description_message__.groups.push_back(**i);
464 __max__.__toMessage__(__description_message__.max, __param_descriptions__, __group_descriptions__);
465 __min__.__toMessage__(__description_message__.min, __param_descriptions__, __group_descriptions__);
466 __default__.__toMessage__(__description_message__.dflt, __param_descriptions__, __group_descriptions__);
506 inline const std::vector<OMPLDynamicReconfigureConfig::AbstractParamDescriptionConstPtr>&
512 inline const std::vector<OMPLDynamicReconfigureConfig::AbstractGroupDescriptionConstPtr>&
525 boost::mutex::scoped_lock lock(dynamic_reconfigure::__init_mutex__);
536 #endif // __OMPLDYNAMICRECONFIGURERECONFIGURATOR_H__
double min(double a, double b)
bool getParam(const std::string &key, std::string &s) const
double max(double a, double b)
void setParam(const std::string &key, const XmlRpc::XmlRpcValue &v) const