00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 #ifndef __tibi_dabo_laser_2d_to_3d__TIBIDABOLASER2DTO3DCONFIG_H__
00048 #define __tibi_dabo_laser_2d_to_3d__TIBIDABOLASER2DTO3DCONFIG_H__
00049
00050 #include <dynamic_reconfigure/config_tools.h>
00051 #include <limits>
00052 #include <ros/node_handle.h>
00053 #include <dynamic_reconfigure/ConfigDescription.h>
00054 #include <dynamic_reconfigure/ParamDescription.h>
00055 #include <dynamic_reconfigure/Group.h>
00056 #include <dynamic_reconfigure/config_init_mutex.h>
00057 #include <boost/any.hpp>
00058
00059 namespace tibi_dabo_laser_2d_to_3d
00060 {
00061 class TibiDaboLaser2dTo3dConfigStatics;
00062
00063 class TibiDaboLaser2dTo3dConfig
00064 {
00065 public:
00066 class AbstractParamDescription : public dynamic_reconfigure::ParamDescription
00067 {
00068 public:
00069 AbstractParamDescription(std::string n, std::string t, uint32_t l,
00070 std::string d, std::string e)
00071 {
00072 name = n;
00073 type = t;
00074 level = l;
00075 description = d;
00076 edit_method = e;
00077 }
00078
00079 virtual void clamp(TibiDaboLaser2dTo3dConfig &config, const TibiDaboLaser2dTo3dConfig &max, const TibiDaboLaser2dTo3dConfig &min) const = 0;
00080 virtual void calcLevel(uint32_t &level, const TibiDaboLaser2dTo3dConfig &config1, const TibiDaboLaser2dTo3dConfig &config2) const = 0;
00081 virtual void fromServer(const ros::NodeHandle &nh, TibiDaboLaser2dTo3dConfig &config) const = 0;
00082 virtual void toServer(const ros::NodeHandle &nh, const TibiDaboLaser2dTo3dConfig &config) const = 0;
00083 virtual bool fromMessage(const dynamic_reconfigure::Config &msg, TibiDaboLaser2dTo3dConfig &config) const = 0;
00084 virtual void toMessage(dynamic_reconfigure::Config &msg, const TibiDaboLaser2dTo3dConfig &config) const = 0;
00085 virtual void getValue(const TibiDaboLaser2dTo3dConfig &config, boost::any &val) const = 0;
00086 };
00087
00088 typedef boost::shared_ptr<AbstractParamDescription> AbstractParamDescriptionPtr;
00089 typedef boost::shared_ptr<const AbstractParamDescription> AbstractParamDescriptionConstPtr;
00090
00091 template <class T>
00092 class ParamDescription : public AbstractParamDescription
00093 {
00094 public:
00095 ParamDescription(std::string name, std::string type, uint32_t level,
00096 std::string description, std::string edit_method, T TibiDaboLaser2dTo3dConfig::* f) :
00097 AbstractParamDescription(name, type, level, description, edit_method),
00098 field(f)
00099 {}
00100
00101 T (TibiDaboLaser2dTo3dConfig::* field);
00102
00103 virtual void clamp(TibiDaboLaser2dTo3dConfig &config, const TibiDaboLaser2dTo3dConfig &max, const TibiDaboLaser2dTo3dConfig &min) const
00104 {
00105 if (config.*field > max.*field)
00106 config.*field = max.*field;
00107
00108 if (config.*field < min.*field)
00109 config.*field = min.*field;
00110 }
00111
00112 virtual void calcLevel(uint32_t &comb_level, const TibiDaboLaser2dTo3dConfig &config1, const TibiDaboLaser2dTo3dConfig &config2) const
00113 {
00114 if (config1.*field != config2.*field)
00115 comb_level |= level;
00116 }
00117
00118 virtual void fromServer(const ros::NodeHandle &nh, TibiDaboLaser2dTo3dConfig &config) const
00119 {
00120 nh.getParam(name, config.*field);
00121 }
00122
00123 virtual void toServer(const ros::NodeHandle &nh, const TibiDaboLaser2dTo3dConfig &config) const
00124 {
00125 nh.setParam(name, config.*field);
00126 }
00127
00128 virtual bool fromMessage(const dynamic_reconfigure::Config &msg, TibiDaboLaser2dTo3dConfig &config) const
00129 {
00130 return dynamic_reconfigure::ConfigTools::getParameter(msg, name, config.*field);
00131 }
00132
00133 virtual void toMessage(dynamic_reconfigure::Config &msg, const TibiDaboLaser2dTo3dConfig &config) const
00134 {
00135 dynamic_reconfigure::ConfigTools::appendParameter(msg, name, config.*field);
00136 }
00137
00138 virtual void getValue(const TibiDaboLaser2dTo3dConfig &config, boost::any &val) const
00139 {
00140 val = config.*field;
00141 }
00142 };
00143
00144 class AbstractGroupDescription : public dynamic_reconfigure::Group
00145 {
00146 public:
00147 AbstractGroupDescription(std::string n, std::string t, int p, int i, bool s)
00148 {
00149 name = n;
00150 type = t;
00151 parent = p;
00152 state = s;
00153 id = i;
00154 }
00155
00156 std::vector<AbstractParamDescriptionConstPtr> abstract_parameters;
00157 bool state;
00158
00159 virtual void toMessage(dynamic_reconfigure::Config &msg, const boost::any &config) const = 0;
00160 virtual bool fromMessage(const dynamic_reconfigure::Config &msg, boost::any &config) const =0;
00161 virtual void updateParams(boost::any &cfg, TibiDaboLaser2dTo3dConfig &top) const= 0;
00162 virtual void setInitialState(boost::any &cfg) const = 0;
00163
00164
00165 void convertParams()
00166 {
00167 for(std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = abstract_parameters.begin(); i != abstract_parameters.end(); i++)
00168 {
00169 parameters.push_back(dynamic_reconfigure::ParamDescription(**i));
00170 }
00171 }
00172 };
00173
00174 typedef boost::shared_ptr<AbstractGroupDescription> AbstractGroupDescriptionPtr;
00175 typedef boost::shared_ptr<const AbstractGroupDescription> AbstractGroupDescriptionConstPtr;
00176
00177 template<class T, class PT>
00178 class GroupDescription : public AbstractGroupDescription
00179 {
00180 public:
00181 GroupDescription(std::string name, std::string type, int parent, int id, bool s, T PT::* f) : AbstractGroupDescription(name, type, parent, id, s), field(f)
00182 {
00183 }
00184
00185 GroupDescription(const GroupDescription<T, PT>& g): AbstractGroupDescription(g.name, g.type, g.parent, g.id, g.state), field(g.field), groups(g.groups)
00186 {
00187 parameters = g.parameters;
00188 abstract_parameters = g.abstract_parameters;
00189 }
00190
00191 virtual bool fromMessage(const dynamic_reconfigure::Config &msg, boost::any &cfg) const
00192 {
00193 PT* config = boost::any_cast<PT*>(cfg);
00194 if(!dynamic_reconfigure::ConfigTools::getGroupState(msg, name, (*config).*field))
00195 return false;
00196
00197 for(std::vector<AbstractGroupDescriptionConstPtr>::const_iterator i = groups.begin(); i != groups.end(); i++)
00198 {
00199 boost::any n = &((*config).*field);
00200 if(!(*i)->fromMessage(msg, n))
00201 return false;
00202 }
00203
00204 return true;
00205 }
00206
00207 virtual void setInitialState(boost::any &cfg) const
00208 {
00209 PT* config = boost::any_cast<PT*>(cfg);
00210 T* group = &((*config).*field);
00211 group->state = state;
00212
00213 for(std::vector<AbstractGroupDescriptionConstPtr>::const_iterator i = groups.begin(); i != groups.end(); i++)
00214 {
00215 boost::any n = boost::any(&((*config).*field));
00216 (*i)->setInitialState(n);
00217 }
00218
00219 }
00220
00221 virtual void updateParams(boost::any &cfg, TibiDaboLaser2dTo3dConfig &top) const
00222 {
00223 PT* config = boost::any_cast<PT*>(cfg);
00224
00225 T* f = &((*config).*field);
00226 f->setParams(top, abstract_parameters);
00227
00228 for(std::vector<AbstractGroupDescriptionConstPtr>::const_iterator i = groups.begin(); i != groups.end(); i++)
00229 {
00230 boost::any n = &((*config).*field);
00231 (*i)->updateParams(n, top);
00232 }
00233 }
00234
00235 virtual void toMessage(dynamic_reconfigure::Config &msg, const boost::any &cfg) const
00236 {
00237 const PT config = boost::any_cast<PT>(cfg);
00238 dynamic_reconfigure::ConfigTools::appendGroup<T>(msg, name, id, parent, config.*field);
00239
00240 for(std::vector<AbstractGroupDescriptionConstPtr>::const_iterator i = groups.begin(); i != groups.end(); i++)
00241 {
00242 (*i)->toMessage(msg, config.*field);
00243 }
00244 }
00245
00246 T (PT::* field);
00247 std::vector<TibiDaboLaser2dTo3dConfig::AbstractGroupDescriptionConstPtr> groups;
00248 };
00249
00250 class DEFAULT
00251 {
00252 public:
00253 DEFAULT()
00254 {
00255 state = true;
00256 name = "Default";
00257 }
00258
00259 void setParams(TibiDaboLaser2dTo3dConfig &config, const std::vector<AbstractParamDescriptionConstPtr> params)
00260 {
00261 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = params.begin(); i != params.end(); i++)
00262 {
00263 boost::any val;
00264 (*i)->getValue(config, val);
00265
00266 if("scan_velocity"==(*i)->name){scan_velocity = boost::any_cast<double>(val);}
00267 if("min_angle"==(*i)->name){min_angle = boost::any_cast<double>(val);}
00268 if("max_angle"==(*i)->name){max_angle = boost::any_cast<double>(val);}
00269 }
00270 }
00271
00272 double scan_velocity;
00273 double min_angle;
00274 double max_angle;
00275
00276 bool state;
00277 std::string name;
00278
00279
00280 }groups;
00281
00282
00283
00284
00285 double scan_velocity;
00286
00287 double min_angle;
00288
00289 double max_angle;
00290
00291
00292 bool __fromMessage__(dynamic_reconfigure::Config &msg)
00293 {
00294 const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__ = __getParamDescriptions__();
00295 const std::vector<AbstractGroupDescriptionConstPtr> &__group_descriptions__ = __getGroupDescriptions__();
00296
00297 int count = 0;
00298 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00299 if ((*i)->fromMessage(msg, *this))
00300 count++;
00301
00302 for (std::vector<AbstractGroupDescriptionConstPtr>::const_iterator i = __group_descriptions__.begin(); i != __group_descriptions__.end(); i ++)
00303 {
00304 if ((*i)->id == 0)
00305 {
00306 boost::any n = boost::any(this);
00307 (*i)->updateParams(n, *this);
00308 (*i)->fromMessage(msg, n);
00309 }
00310 }
00311
00312 if (count != dynamic_reconfigure::ConfigTools::size(msg))
00313 {
00314 ROS_ERROR("TibiDaboLaser2dTo3dConfig::__fromMessage__ called with an unexpected parameter.");
00315 ROS_ERROR("Booleans:");
00316 for (unsigned int i = 0; i < msg.bools.size(); i++)
00317 ROS_ERROR(" %s", msg.bools[i].name.c_str());
00318 ROS_ERROR("Integers:");
00319 for (unsigned int i = 0; i < msg.ints.size(); i++)
00320 ROS_ERROR(" %s", msg.ints[i].name.c_str());
00321 ROS_ERROR("Doubles:");
00322 for (unsigned int i = 0; i < msg.doubles.size(); i++)
00323 ROS_ERROR(" %s", msg.doubles[i].name.c_str());
00324 ROS_ERROR("Strings:");
00325 for (unsigned int i = 0; i < msg.strs.size(); i++)
00326 ROS_ERROR(" %s", msg.strs[i].name.c_str());
00327
00328
00329 return false;
00330 }
00331 return true;
00332 }
00333
00334
00335
00336 void __toMessage__(dynamic_reconfigure::Config &msg, const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__, const std::vector<AbstractGroupDescriptionConstPtr> &__group_descriptions__) const
00337 {
00338 dynamic_reconfigure::ConfigTools::clear(msg);
00339 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00340 (*i)->toMessage(msg, *this);
00341
00342 for (std::vector<AbstractGroupDescriptionConstPtr>::const_iterator i = __group_descriptions__.begin(); i != __group_descriptions__.end(); i++)
00343 {
00344 if((*i)->id == 0)
00345 {
00346 (*i)->toMessage(msg, *this);
00347 }
00348 }
00349 }
00350
00351 void __toMessage__(dynamic_reconfigure::Config &msg) const
00352 {
00353 const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__ = __getParamDescriptions__();
00354 const std::vector<AbstractGroupDescriptionConstPtr> &__group_descriptions__ = __getGroupDescriptions__();
00355 __toMessage__(msg, __param_descriptions__, __group_descriptions__);
00356 }
00357
00358 void __toServer__(const ros::NodeHandle &nh) const
00359 {
00360 const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__ = __getParamDescriptions__();
00361 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00362 (*i)->toServer(nh, *this);
00363 }
00364
00365 void __fromServer__(const ros::NodeHandle &nh)
00366 {
00367 static bool setup=false;
00368
00369 const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__ = __getParamDescriptions__();
00370 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00371 (*i)->fromServer(nh, *this);
00372
00373 const std::vector<AbstractGroupDescriptionConstPtr> &__group_descriptions__ = __getGroupDescriptions__();
00374 for (std::vector<AbstractGroupDescriptionConstPtr>::const_iterator i = __group_descriptions__.begin(); i != __group_descriptions__.end(); i++){
00375 if (!setup && (*i)->id == 0) {
00376 setup = true;
00377 boost::any n = boost::any(this);
00378 (*i)->setInitialState(n);
00379 }
00380 }
00381 }
00382
00383 void __clamp__()
00384 {
00385 const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__ = __getParamDescriptions__();
00386 const TibiDaboLaser2dTo3dConfig &__max__ = __getMax__();
00387 const TibiDaboLaser2dTo3dConfig &__min__ = __getMin__();
00388 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00389 (*i)->clamp(*this, __max__, __min__);
00390 }
00391
00392 uint32_t __level__(const TibiDaboLaser2dTo3dConfig &config) const
00393 {
00394 const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__ = __getParamDescriptions__();
00395 uint32_t level = 0;
00396 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00397 (*i)->calcLevel(level, config, *this);
00398 return level;
00399 }
00400
00401 static const dynamic_reconfigure::ConfigDescription &__getDescriptionMessage__();
00402 static const TibiDaboLaser2dTo3dConfig &__getDefault__();
00403 static const TibiDaboLaser2dTo3dConfig &__getMax__();
00404 static const TibiDaboLaser2dTo3dConfig &__getMin__();
00405 static const std::vector<AbstractParamDescriptionConstPtr> &__getParamDescriptions__();
00406 static const std::vector<AbstractGroupDescriptionConstPtr> &__getGroupDescriptions__();
00407
00408 private:
00409 static const TibiDaboLaser2dTo3dConfigStatics *__get_statics__();
00410 };
00411
00412 template <>
00413 inline void TibiDaboLaser2dTo3dConfig::ParamDescription<std::string>::clamp(TibiDaboLaser2dTo3dConfig &config, const TibiDaboLaser2dTo3dConfig &max, const TibiDaboLaser2dTo3dConfig &min) const
00414 {
00415 return;
00416 }
00417
00418 class TibiDaboLaser2dTo3dConfigStatics
00419 {
00420 friend class TibiDaboLaser2dTo3dConfig;
00421
00422 TibiDaboLaser2dTo3dConfigStatics()
00423 {
00424 TibiDaboLaser2dTo3dConfig::GroupDescription<TibiDaboLaser2dTo3dConfig::DEFAULT, TibiDaboLaser2dTo3dConfig> Default("Default", "", 0, 0, true, &TibiDaboLaser2dTo3dConfig::groups);
00425
00426 __min__.scan_velocity = 1.0;
00427
00428 __max__.scan_velocity = 120.0;
00429
00430 __default__.scan_velocity = 60.0;
00431
00432 Default.abstract_parameters.push_back(TibiDaboLaser2dTo3dConfig::AbstractParamDescriptionConstPtr(new TibiDaboLaser2dTo3dConfig::ParamDescription<double>("scan_velocity", "double", 0, "Scan servo velocity (degrees/sec)", "", &TibiDaboLaser2dTo3dConfig::scan_velocity)));
00433
00434 __param_descriptions__.push_back(TibiDaboLaser2dTo3dConfig::AbstractParamDescriptionConstPtr(new TibiDaboLaser2dTo3dConfig::ParamDescription<double>("scan_velocity", "double", 0, "Scan servo velocity (degrees/sec)", "", &TibiDaboLaser2dTo3dConfig::scan_velocity)));
00435
00436 __min__.min_angle = -35.0;
00437
00438 __max__.min_angle = 0.0;
00439
00440 __default__.min_angle = -30.0;
00441
00442 Default.abstract_parameters.push_back(TibiDaboLaser2dTo3dConfig::AbstractParamDescriptionConstPtr(new TibiDaboLaser2dTo3dConfig::ParamDescription<double>("min_angle", "double", 0, "Minimum pan angle (degrees)", "", &TibiDaboLaser2dTo3dConfig::min_angle)));
00443
00444 __param_descriptions__.push_back(TibiDaboLaser2dTo3dConfig::AbstractParamDescriptionConstPtr(new TibiDaboLaser2dTo3dConfig::ParamDescription<double>("min_angle", "double", 0, "Minimum pan angle (degrees)", "", &TibiDaboLaser2dTo3dConfig::min_angle)));
00445
00446 __min__.max_angle = 0.0;
00447
00448 __max__.max_angle = 35.0;
00449
00450 __default__.max_angle = 30.0;
00451
00452 Default.abstract_parameters.push_back(TibiDaboLaser2dTo3dConfig::AbstractParamDescriptionConstPtr(new TibiDaboLaser2dTo3dConfig::ParamDescription<double>("max_angle", "double", 0, "Maximum pan angle (degrees)", "", &TibiDaboLaser2dTo3dConfig::max_angle)));
00453
00454 __param_descriptions__.push_back(TibiDaboLaser2dTo3dConfig::AbstractParamDescriptionConstPtr(new TibiDaboLaser2dTo3dConfig::ParamDescription<double>("max_angle", "double", 0, "Maximum pan angle (degrees)", "", &TibiDaboLaser2dTo3dConfig::max_angle)));
00455
00456 Default.convertParams();
00457
00458 __group_descriptions__.push_back(TibiDaboLaser2dTo3dConfig::AbstractGroupDescriptionConstPtr(new TibiDaboLaser2dTo3dConfig::GroupDescription<TibiDaboLaser2dTo3dConfig::DEFAULT, TibiDaboLaser2dTo3dConfig>(Default)));
00459
00460
00461 for (std::vector<TibiDaboLaser2dTo3dConfig::AbstractGroupDescriptionConstPtr>::const_iterator i = __group_descriptions__.begin(); i != __group_descriptions__.end(); i++)
00462 {
00463 __description_message__.groups.push_back(**i);
00464 }
00465 __max__.__toMessage__(__description_message__.max, __param_descriptions__, __group_descriptions__);
00466 __min__.__toMessage__(__description_message__.min, __param_descriptions__, __group_descriptions__);
00467 __default__.__toMessage__(__description_message__.dflt, __param_descriptions__, __group_descriptions__);
00468 }
00469 std::vector<TibiDaboLaser2dTo3dConfig::AbstractParamDescriptionConstPtr> __param_descriptions__;
00470 std::vector<TibiDaboLaser2dTo3dConfig::AbstractGroupDescriptionConstPtr> __group_descriptions__;
00471 TibiDaboLaser2dTo3dConfig __max__;
00472 TibiDaboLaser2dTo3dConfig __min__;
00473 TibiDaboLaser2dTo3dConfig __default__;
00474 dynamic_reconfigure::ConfigDescription __description_message__;
00475
00476 static const TibiDaboLaser2dTo3dConfigStatics *get_instance()
00477 {
00478
00479
00480
00481
00482 static TibiDaboLaser2dTo3dConfigStatics instance;
00483 return &instance;
00484 }
00485 };
00486
00487 inline const dynamic_reconfigure::ConfigDescription &TibiDaboLaser2dTo3dConfig::__getDescriptionMessage__()
00488 {
00489 return __get_statics__()->__description_message__;
00490 }
00491
00492 inline const TibiDaboLaser2dTo3dConfig &TibiDaboLaser2dTo3dConfig::__getDefault__()
00493 {
00494 return __get_statics__()->__default__;
00495 }
00496
00497 inline const TibiDaboLaser2dTo3dConfig &TibiDaboLaser2dTo3dConfig::__getMax__()
00498 {
00499 return __get_statics__()->__max__;
00500 }
00501
00502 inline const TibiDaboLaser2dTo3dConfig &TibiDaboLaser2dTo3dConfig::__getMin__()
00503 {
00504 return __get_statics__()->__min__;
00505 }
00506
00507 inline const std::vector<TibiDaboLaser2dTo3dConfig::AbstractParamDescriptionConstPtr> &TibiDaboLaser2dTo3dConfig::__getParamDescriptions__()
00508 {
00509 return __get_statics__()->__param_descriptions__;
00510 }
00511
00512 inline const std::vector<TibiDaboLaser2dTo3dConfig::AbstractGroupDescriptionConstPtr> &TibiDaboLaser2dTo3dConfig::__getGroupDescriptions__()
00513 {
00514 return __get_statics__()->__group_descriptions__;
00515 }
00516
00517 inline const TibiDaboLaser2dTo3dConfigStatics *TibiDaboLaser2dTo3dConfig::__get_statics__()
00518 {
00519 const static TibiDaboLaser2dTo3dConfigStatics *statics;
00520
00521 if (statics)
00522 return statics;
00523
00524 boost::mutex::scoped_lock lock(dynamic_reconfigure::__init_mutex__);
00525
00526 if (statics)
00527 return statics;
00528
00529 statics = TibiDaboLaser2dTo3dConfigStatics::get_instance();
00530
00531 return statics;
00532 }
00533
00534
00535 }
00536
00537 #endif // __TIBIDABOLASER2DTO3DRECONFIGURATOR_H__