48 #include <dynamic_reconfigure/config_tools.h>
52 #include <dynamic_reconfigure/ConfigDescription.h>
53 #include <dynamic_reconfigure/ParamDescription.h>
54 #include <dynamic_reconfigure/Group.h>
55 #include <dynamic_reconfigure/config_init_mutex.h>
56 #include <boost/any.hpp>
66 class AbstractParamDescription :
public dynamic_reconfigure::ParamDescription
90 class ParamDescription :
public AbstractParamDescription
130 return dynamic_reconfigure::ConfigTools::getParameter(msg,
name, config.*
field);
135 dynamic_reconfigure::ConfigTools::appendParameter(msg,
name, config.*
field);
160 virtual void toMessage(dynamic_reconfigure::Config& msg,
const boost::any& config)
const = 0;
161 virtual bool fromMessage(
const dynamic_reconfigure::Config& msg, boost::any& config)
const = 0;
167 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i =
abstract_parameters.begin();
170 parameters.push_back(dynamic_reconfigure::ParamDescription(**i));
175 template <
class T,
class PT>
176 class GroupDescription :
public AbstractGroupDescription
187 parameters = g.parameters;
191 virtual bool fromMessage(
const dynamic_reconfigure::Config& msg, boost::any& cfg)
const
193 PT* config = boost::any_cast<PT*>(cfg);
194 if (!dynamic_reconfigure::ConfigTools::getGroupState(msg,
name, (*config).*
field))
197 for (std::vector<AbstractGroupDescriptionConstPtr>::const_iterator i =
groups.begin(); i !=
groups.end(); i++)
199 boost::any n = &((*config).*
field);
200 if (!(*i)->fromMessage(msg, n))
209 PT* config = boost::any_cast<PT*>(cfg);
210 T* group = &((*config).*
field);
213 for (std::vector<AbstractGroupDescriptionConstPtr>::const_iterator i =
groups.begin(); i !=
groups.end(); i++)
215 boost::any n = boost::any(&((*config).*
field));
216 (*i)->setInitialState(n);
222 PT* config = boost::any_cast<PT*>(cfg);
224 T*
f = &((*config).*
field);
227 for (std::vector<AbstractGroupDescriptionConstPtr>::const_iterator i =
groups.begin(); i !=
groups.end(); i++)
229 boost::any n = &((*config).*
field);
230 (*i)->updateParams(n, top);
234 virtual void toMessage(dynamic_reconfigure::Config& msg,
const boost::any& cfg)
const
236 const PT config = boost::any_cast<PT>(cfg);
237 dynamic_reconfigure::ConfigTools::appendGroup<T>(msg, name,
id, parent, config.*
field);
239 for (std::vector<AbstractGroupDescriptionConstPtr>::const_iterator i =
groups.begin(); i !=
groups.end(); i++)
241 (*i)->toMessage(msg, config.*
field);
246 std::vector<OMPLDynamicReconfigureConfig::AbstractGroupDescriptionConstPtr>
groups;
260 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = params.begin(); i != params.end(); i++)
263 (*i)->getValue(config, val);
265 if (
"link_for_exploration_tree" == (*i)->name)
289 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin();
290 i != __param_descriptions__.end(); i++)
291 if ((*i)->fromMessage(msg, *
this))
294 for (std::vector<AbstractGroupDescriptionConstPtr>::const_iterator i = __group_descriptions__.begin();
295 i != __group_descriptions__.end(); i++)
299 boost::any n = boost::any(
this);
300 (*i)->updateParams(n, *
this);
301 (*i)->fromMessage(msg, n);
305 if (count != dynamic_reconfigure::ConfigTools::size(msg))
307 ROS_ERROR(
"OMPLDynamicReconfigureConfig::__fromMessage__ called with an unexpected parameter.");
309 for (
unsigned int i = 0; i < msg.bools.size(); i++)
310 ROS_ERROR(
" %s", msg.bools[i].name.c_str());
312 for (
unsigned int i = 0; i < msg.ints.size(); i++)
313 ROS_ERROR(
" %s", msg.ints[i].name.c_str());
315 for (
unsigned int i = 0; i < msg.doubles.size(); i++)
316 ROS_ERROR(
" %s", msg.doubles[i].name.c_str());
318 for (
unsigned int i = 0; i < msg.strs.size(); i++)
319 ROS_ERROR(
" %s", msg.strs[i].name.c_str());
330 const std::vector<AbstractParamDescriptionConstPtr>& __param_descriptions__,
331 const std::vector<AbstractGroupDescriptionConstPtr>& __group_descriptions__)
const
333 dynamic_reconfigure::ConfigTools::clear(msg);
334 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin();
335 i != __param_descriptions__.end(); i++)
336 (*i)->toMessage(msg, *
this);
338 for (std::vector<AbstractGroupDescriptionConstPtr>::const_iterator i = __group_descriptions__.begin();
339 i != __group_descriptions__.end(); i++)
343 (*i)->toMessage(msg, *
this);
352 __toMessage__(msg, __param_descriptions__, __group_descriptions__);
358 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin();
359 i != __param_descriptions__.end(); i++)
360 (*i)->toServer(nh, *
this);
365 static bool setup =
false;
368 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin();
369 i != __param_descriptions__.end(); i++)
370 (*i)->fromServer(nh, *
this);
373 for (std::vector<AbstractGroupDescriptionConstPtr>::const_iterator i = __group_descriptions__.begin();
374 i != __group_descriptions__.end(); i++)
376 if (!
setup && (*i)->id == 0)
379 boost::any n = boost::any(
this);
380 (*i)->setInitialState(n);
390 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin();
391 i != __param_descriptions__.end(); i++)
392 (*i)->clamp(*
this, __max__, __min__);
399 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin();
400 i != __param_descriptions__.end(); i++)
401 (*i)->calcLevel(level, config, *
this);
440 Default.abstract_parameters.push_back(OMPLDynamicReconfigureConfig::AbstractParamDescriptionConstPtr(
442 "link_for_exploration_tree",
"str", 1,
"Show the exploration tree for a particular link",
"",
447 "link_for_exploration_tree",
"str", 1,
"Show the exploration tree for a particular link",
"",
450 Default.convertParams();
457 for (std::vector<OMPLDynamicReconfigureConfig::AbstractGroupDescriptionConstPtr>::const_iterator i =
505 inline const std::vector<OMPLDynamicReconfigureConfig::AbstractParamDescriptionConstPtr>&
511 inline const std::vector<OMPLDynamicReconfigureConfig::AbstractGroupDescriptionConstPtr>&
524 std::unique_lock<std::mutex> lock(dynamic_reconfigure::__init_mutex__);