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 __pcl_ros__MLSCONFIG_H__
00048 #define __pcl_ros__MLSCONFIG_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/config_init_mutex.h>
00056
00057 namespace pcl_ros
00058 {
00059 class MLSConfigStatics;
00060
00061 class MLSConfig
00062 {
00063 public:
00064 class AbstractParamDescription : public dynamic_reconfigure::ParamDescription
00065 {
00066 public:
00067 AbstractParamDescription(std::string n, std::string t, uint32_t l,
00068 std::string d, std::string e)
00069 {
00070 name = n;
00071 type = t;
00072 level = l;
00073 description = d;
00074 edit_method = e;
00075 }
00076
00077 virtual void clamp(MLSConfig &config, const MLSConfig &max, const MLSConfig &min) const = 0;
00078 virtual void calcLevel(uint32_t &level, const MLSConfig &config1, const MLSConfig &config2) const = 0;
00079 virtual void fromServer(const ros::NodeHandle &nh, MLSConfig &config) const = 0;
00080 virtual void toServer(const ros::NodeHandle &nh, const MLSConfig &config) const = 0;
00081 virtual bool fromMessage(const dynamic_reconfigure::Config &msg, MLSConfig &config) const = 0;
00082 virtual void toMessage(dynamic_reconfigure::Config &msg, const MLSConfig &config) const = 0;
00083 };
00084
00085 typedef boost::shared_ptr<AbstractParamDescription> AbstractParamDescriptionPtr;
00086 typedef boost::shared_ptr<const AbstractParamDescription> AbstractParamDescriptionConstPtr;
00087
00088 template <class T>
00089 class ParamDescription : public AbstractParamDescription
00090 {
00091 public:
00092 ParamDescription(std::string name, std::string type, uint32_t level,
00093 std::string description, std::string edit_method, T MLSConfig::* f) :
00094 AbstractParamDescription(name, type, level, description, edit_method),
00095 field(f)
00096 {}
00097
00098 T (MLSConfig::* field);
00099
00100 virtual void clamp(MLSConfig &config, const MLSConfig &max, const MLSConfig &min) const
00101 {
00102 if (config.*field > max.*field)
00103 config.*field = max.*field;
00104
00105 if (config.*field < min.*field)
00106 config.*field = min.*field;
00107 }
00108
00109 virtual void calcLevel(uint32_t &comb_level, const MLSConfig &config1, const MLSConfig &config2) const
00110 {
00111 if (config1.*field != config2.*field)
00112 comb_level |= level;
00113 }
00114
00115 virtual void fromServer(const ros::NodeHandle &nh, MLSConfig &config) const
00116 {
00117 nh.getParam(name, config.*field);
00118 }
00119
00120 virtual void toServer(const ros::NodeHandle &nh, const MLSConfig &config) const
00121 {
00122 nh.setParam(name, config.*field);
00123 }
00124
00125 virtual bool fromMessage(const dynamic_reconfigure::Config &msg, MLSConfig &config) const
00126 {
00127 return dynamic_reconfigure::ConfigTools::getParameter(msg, name, config.*field);
00128 }
00129
00130 virtual void toMessage(dynamic_reconfigure::Config &msg, const MLSConfig &config) const
00131 {
00132 dynamic_reconfigure::ConfigTools::appendParameter(msg, name, config.*field);
00133 }
00134 };
00135
00136
00137 int spatial_locator;
00138
00139 double search_radius;
00140
00141 bool use_polynomial_fit;
00142
00143 int polynomial_order;
00144
00145 double gaussian_parameter;
00146
00147
00148 bool __fromMessage__(dynamic_reconfigure::Config &msg)
00149 {
00150 const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__ = __getParamDescriptions__();
00151 int count = 0;
00152 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00153 if ((*i)->fromMessage(msg, *this))
00154 count++;
00155 if (count != dynamic_reconfigure::ConfigTools::size(msg))
00156 {
00157 ROS_ERROR("MLSConfig::__fromMessage__ called with an unexpected parameter.");
00158 ROS_ERROR("Booleans:");
00159 for (unsigned int i = 0; i < msg.bools.size(); i++)
00160 ROS_ERROR(" %s", msg.bools[i].name.c_str());
00161 ROS_ERROR("Integers:");
00162 for (unsigned int i = 0; i < msg.ints.size(); i++)
00163 ROS_ERROR(" %s", msg.ints[i].name.c_str());
00164 ROS_ERROR("Doubles:");
00165 for (unsigned int i = 0; i < msg.doubles.size(); i++)
00166 ROS_ERROR(" %s", msg.doubles[i].name.c_str());
00167 ROS_ERROR("Strings:");
00168 for (unsigned int i = 0; i < msg.strs.size(); i++)
00169 ROS_ERROR(" %s", msg.strs[i].name.c_str());
00170
00171
00172 return false;
00173 }
00174 return true;
00175 }
00176
00177
00178
00179 void __toMessage__(dynamic_reconfigure::Config &msg, const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__) const
00180 {
00181 dynamic_reconfigure::ConfigTools::clear(msg);
00182 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00183 (*i)->toMessage(msg, *this);
00184 }
00185
00186 void __toMessage__(dynamic_reconfigure::Config &msg) const
00187 {
00188 const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__ = __getParamDescriptions__();
00189 __toMessage__(msg, __param_descriptions__);
00190 }
00191
00192 void __toServer__(const ros::NodeHandle &nh) const
00193 {
00194 const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__ = __getParamDescriptions__();
00195 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00196 (*i)->toServer(nh, *this);
00197 }
00198
00199 void __fromServer__(const ros::NodeHandle &nh)
00200 {
00201 const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__ = __getParamDescriptions__();
00202 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00203 (*i)->fromServer(nh, *this);
00204 }
00205
00206 void __clamp__()
00207 {
00208 const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__ = __getParamDescriptions__();
00209 const MLSConfig &__max__ = __getMax__();
00210 const MLSConfig &__min__ = __getMin__();
00211 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00212 (*i)->clamp(*this, __max__, __min__);
00213 }
00214
00215 uint32_t __level__(const MLSConfig &config) const
00216 {
00217 const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__ = __getParamDescriptions__();
00218 uint32_t level = 0;
00219 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00220 (*i)->calcLevel(level, config, *this);
00221 return level;
00222 }
00223
00224 static const dynamic_reconfigure::ConfigDescription &__getDescriptionMessage__();
00225 static const MLSConfig &__getDefault__();
00226 static const MLSConfig &__getMax__();
00227 static const MLSConfig &__getMin__();
00228 static const std::vector<AbstractParamDescriptionConstPtr> &__getParamDescriptions__();
00229
00230 private:
00231 static const MLSConfigStatics *__get_statics__();
00232 };
00233
00234 template <>
00235 inline void MLSConfig::ParamDescription<std::string>::clamp(MLSConfig &config, const MLSConfig &max, const MLSConfig &min) const
00236 {
00237 return;
00238 }
00239
00240 class MLSConfigStatics
00241 {
00242 friend class MLSConfig;
00243
00244 MLSConfigStatics()
00245 {
00246
00247 __min__.spatial_locator = 0;
00248
00249 __max__.spatial_locator = 2;
00250
00251 __default__.spatial_locator = 0;
00252
00253 __param_descriptions__.push_back(MLSConfig::AbstractParamDescriptionConstPtr(new MLSConfig::ParamDescription<int>("spatial_locator", "int", 0, "Set the spatial locator", "{'enum_description': 'Set the spatial locator', 'enum': [{'srcline': 11, 'description': 'ANN', 'srcfile': '../cfg/MLS.cfg', 'cconsttype': 'const int', 'value': 0, 'ctype': 'int', 'type': 'int', 'name': 'ANN'}, {'srcline': 11, 'description': 'FLANN', 'srcfile': '../cfg/MLS.cfg', 'cconsttype': 'const int', 'value': 1, 'ctype': 'int', 'type': 'int', 'name': 'FLANN'}, {'srcline': 11, 'description': 'Dense/organized data locator', 'srcfile': '../cfg/MLS.cfg', 'cconsttype': 'const int', 'value': 2, 'ctype': 'int', 'type': 'int', 'name': 'organized'}]}", &MLSConfig::spatial_locator)));
00254
00255 __min__.search_radius = 0.0;
00256
00257 __max__.search_radius = 0.5;
00258
00259 __default__.search_radius = 0.02;
00260
00261 __param_descriptions__.push_back(MLSConfig::AbstractParamDescriptionConstPtr(new MLSConfig::ParamDescription<double>("search_radius", "double", 0, "Sphere radius for nearest neighbor search", "", &MLSConfig::search_radius)));
00262
00263 __min__.use_polynomial_fit = 0;
00264
00265 __max__.use_polynomial_fit = 1;
00266
00267 __default__.use_polynomial_fit = 1;
00268
00269 __param_descriptions__.push_back(MLSConfig::AbstractParamDescriptionConstPtr(new MLSConfig::ParamDescription<bool>("use_polynomial_fit", "bool", 0, "Whether to use polynomial fit", "", &MLSConfig::use_polynomial_fit)));
00270
00271 __min__.polynomial_order = 0;
00272
00273 __max__.polynomial_order = 5;
00274
00275 __default__.polynomial_order = 2;
00276
00277 __param_descriptions__.push_back(MLSConfig::AbstractParamDescriptionConstPtr(new MLSConfig::ParamDescription<int>("polynomial_order", "int", 0, "Set the spatial locator", "", &MLSConfig::polynomial_order)));
00278
00279 __min__.gaussian_parameter = 0.0;
00280
00281 __max__.gaussian_parameter = 0.5;
00282
00283 __default__.gaussian_parameter = 0.02;
00284
00285 __param_descriptions__.push_back(MLSConfig::AbstractParamDescriptionConstPtr(new MLSConfig::ParamDescription<double>("gaussian_parameter", "double", 0, "How 'flat' should the neighbor weighting gaussian be (the smaller, the more local the fit)", "", &MLSConfig::gaussian_parameter)));
00286
00287
00288 for (std::vector<MLSConfig::AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00289 __description_message__.parameters.push_back(**i);
00290 __max__.__toMessage__(__description_message__.max, __param_descriptions__);
00291 __min__.__toMessage__(__description_message__.min, __param_descriptions__);
00292 __default__.__toMessage__(__description_message__.dflt, __param_descriptions__);
00293 }
00294 std::vector<MLSConfig::AbstractParamDescriptionConstPtr> __param_descriptions__;
00295 MLSConfig __max__;
00296 MLSConfig __min__;
00297 MLSConfig __default__;
00298 dynamic_reconfigure::ConfigDescription __description_message__;
00299 static const MLSConfigStatics *get_instance()
00300 {
00301
00302
00303
00304
00305 static MLSConfigStatics instance;
00306 return &instance;
00307 }
00308 };
00309
00310 inline const dynamic_reconfigure::ConfigDescription &MLSConfig::__getDescriptionMessage__()
00311 {
00312 return __get_statics__()->__description_message__;
00313 }
00314
00315 inline const MLSConfig &MLSConfig::__getDefault__()
00316 {
00317 return __get_statics__()->__default__;
00318 }
00319
00320 inline const MLSConfig &MLSConfig::__getMax__()
00321 {
00322 return __get_statics__()->__max__;
00323 }
00324
00325 inline const MLSConfig &MLSConfig::__getMin__()
00326 {
00327 return __get_statics__()->__min__;
00328 }
00329
00330 inline const std::vector<MLSConfig::AbstractParamDescriptionConstPtr> &MLSConfig::__getParamDescriptions__()
00331 {
00332 return __get_statics__()->__param_descriptions__;
00333 }
00334
00335 inline const MLSConfigStatics *MLSConfig::__get_statics__()
00336 {
00337 const static MLSConfigStatics *statics;
00338
00339 if (statics)
00340 return statics;
00341
00342 boost::mutex::scoped_lock lock(dynamic_reconfigure::__init_mutex__);
00343
00344 if (statics)
00345 return statics;
00346
00347 statics = MLSConfigStatics::get_instance();
00348
00349 return statics;
00350 }
00351
00352
00353 const int MLS_ANN = 0;
00354
00355 const int MLS_FLANN = 1;
00356
00357 const int MLS_organized = 2;
00358 }
00359
00360 #endif // __MLSRECONFIGURATOR_H__