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__SACSEGMENTATIONFROMNORMALSCONFIG_H__
00048 #define __pcl_ros__SACSEGMENTATIONFROMNORMALSCONFIG_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 SACSegmentationFromNormalsConfigStatics;
00060
00061 class SACSegmentationFromNormalsConfig
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(SACSegmentationFromNormalsConfig &config, const SACSegmentationFromNormalsConfig &max, const SACSegmentationFromNormalsConfig &min) const = 0;
00078 virtual void calcLevel(uint32_t &level, const SACSegmentationFromNormalsConfig &config1, const SACSegmentationFromNormalsConfig &config2) const = 0;
00079 virtual void fromServer(const ros::NodeHandle &nh, SACSegmentationFromNormalsConfig &config) const = 0;
00080 virtual void toServer(const ros::NodeHandle &nh, const SACSegmentationFromNormalsConfig &config) const = 0;
00081 virtual bool fromMessage(const dynamic_reconfigure::Config &msg, SACSegmentationFromNormalsConfig &config) const = 0;
00082 virtual void toMessage(dynamic_reconfigure::Config &msg, const SACSegmentationFromNormalsConfig &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 SACSegmentationFromNormalsConfig::* f) :
00094 AbstractParamDescription(name, type, level, description, edit_method),
00095 field(f)
00096 {}
00097
00098 T (SACSegmentationFromNormalsConfig::* field);
00099
00100 virtual void clamp(SACSegmentationFromNormalsConfig &config, const SACSegmentationFromNormalsConfig &max, const SACSegmentationFromNormalsConfig &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 SACSegmentationFromNormalsConfig &config1, const SACSegmentationFromNormalsConfig &config2) const
00110 {
00111 if (config1.*field != config2.*field)
00112 comb_level |= level;
00113 }
00114
00115 virtual void fromServer(const ros::NodeHandle &nh, SACSegmentationFromNormalsConfig &config) const
00116 {
00117 nh.getParam(name, config.*field);
00118 }
00119
00120 virtual void toServer(const ros::NodeHandle &nh, const SACSegmentationFromNormalsConfig &config) const
00121 {
00122 nh.setParam(name, config.*field);
00123 }
00124
00125 virtual bool fromMessage(const dynamic_reconfigure::Config &msg, SACSegmentationFromNormalsConfig &config) const
00126 {
00127 return dynamic_reconfigure::ConfigTools::getParameter(msg, name, config.*field);
00128 }
00129
00130 virtual void toMessage(dynamic_reconfigure::Config &msg, const SACSegmentationFromNormalsConfig &config) const
00131 {
00132 dynamic_reconfigure::ConfigTools::appendParameter(msg, name, config.*field);
00133 }
00134 };
00135
00136
00137 double normal_distance_weight;
00138
00139 int max_iterations;
00140
00141 double probability;
00142
00143 double distance_threshold;
00144
00145 bool optimize_coefficients;
00146
00147 double radius_min;
00148
00149 double radius_max;
00150
00151 double eps_angle;
00152
00153 int min_inliers;
00154
00155 std::string input_frame;
00156
00157 std::string output_frame;
00158
00159
00160 bool __fromMessage__(dynamic_reconfigure::Config &msg)
00161 {
00162 const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__ = __getParamDescriptions__();
00163 int count = 0;
00164 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00165 if ((*i)->fromMessage(msg, *this))
00166 count++;
00167 if (count != dynamic_reconfigure::ConfigTools::size(msg))
00168 {
00169 ROS_ERROR("SACSegmentationFromNormalsConfig::__fromMessage__ called with an unexpected parameter.");
00170 ROS_ERROR("Booleans:");
00171 for (unsigned int i = 0; i < msg.bools.size(); i++)
00172 ROS_ERROR(" %s", msg.bools[i].name.c_str());
00173 ROS_ERROR("Integers:");
00174 for (unsigned int i = 0; i < msg.ints.size(); i++)
00175 ROS_ERROR(" %s", msg.ints[i].name.c_str());
00176 ROS_ERROR("Doubles:");
00177 for (unsigned int i = 0; i < msg.doubles.size(); i++)
00178 ROS_ERROR(" %s", msg.doubles[i].name.c_str());
00179 ROS_ERROR("Strings:");
00180 for (unsigned int i = 0; i < msg.strs.size(); i++)
00181 ROS_ERROR(" %s", msg.strs[i].name.c_str());
00182
00183
00184 return false;
00185 }
00186 return true;
00187 }
00188
00189
00190
00191 void __toMessage__(dynamic_reconfigure::Config &msg, const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__) const
00192 {
00193 dynamic_reconfigure::ConfigTools::clear(msg);
00194 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00195 (*i)->toMessage(msg, *this);
00196 }
00197
00198 void __toMessage__(dynamic_reconfigure::Config &msg) const
00199 {
00200 const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__ = __getParamDescriptions__();
00201 __toMessage__(msg, __param_descriptions__);
00202 }
00203
00204 void __toServer__(const ros::NodeHandle &nh) const
00205 {
00206 const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__ = __getParamDescriptions__();
00207 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00208 (*i)->toServer(nh, *this);
00209 }
00210
00211 void __fromServer__(const ros::NodeHandle &nh)
00212 {
00213 const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__ = __getParamDescriptions__();
00214 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00215 (*i)->fromServer(nh, *this);
00216 }
00217
00218 void __clamp__()
00219 {
00220 const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__ = __getParamDescriptions__();
00221 const SACSegmentationFromNormalsConfig &__max__ = __getMax__();
00222 const SACSegmentationFromNormalsConfig &__min__ = __getMin__();
00223 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00224 (*i)->clamp(*this, __max__, __min__);
00225 }
00226
00227 uint32_t __level__(const SACSegmentationFromNormalsConfig &config) const
00228 {
00229 const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__ = __getParamDescriptions__();
00230 uint32_t level = 0;
00231 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00232 (*i)->calcLevel(level, config, *this);
00233 return level;
00234 }
00235
00236 static const dynamic_reconfigure::ConfigDescription &__getDescriptionMessage__();
00237 static const SACSegmentationFromNormalsConfig &__getDefault__();
00238 static const SACSegmentationFromNormalsConfig &__getMax__();
00239 static const SACSegmentationFromNormalsConfig &__getMin__();
00240 static const std::vector<AbstractParamDescriptionConstPtr> &__getParamDescriptions__();
00241
00242 private:
00243 static const SACSegmentationFromNormalsConfigStatics *__get_statics__();
00244 };
00245
00246 template <>
00247 inline void SACSegmentationFromNormalsConfig::ParamDescription<std::string>::clamp(SACSegmentationFromNormalsConfig &config, const SACSegmentationFromNormalsConfig &max, const SACSegmentationFromNormalsConfig &min) const
00248 {
00249 return;
00250 }
00251
00252 class SACSegmentationFromNormalsConfigStatics
00253 {
00254 friend class SACSegmentationFromNormalsConfig;
00255
00256 SACSegmentationFromNormalsConfigStatics()
00257 {
00258
00259 __min__.normal_distance_weight = 0.0;
00260
00261 __max__.normal_distance_weight = 1.0;
00262
00263 __default__.normal_distance_weight = 0.1;
00264
00265 __param_descriptions__.push_back(SACSegmentationFromNormalsConfig::AbstractParamDescriptionConstPtr(new SACSegmentationFromNormalsConfig::ParamDescription<double>("normal_distance_weight", "double", 0, "The relative weight (between 0 and 1) to give to the angular distance (0 to pi/2) between point normals and the plane normal.", "", &SACSegmentationFromNormalsConfig::normal_distance_weight)));
00266
00267 __min__.max_iterations = 0;
00268
00269 __max__.max_iterations = 100000;
00270
00271 __default__.max_iterations = 50;
00272
00273 __param_descriptions__.push_back(SACSegmentationFromNormalsConfig::AbstractParamDescriptionConstPtr(new SACSegmentationFromNormalsConfig::ParamDescription<int>("max_iterations", "int", 0, "The maximum number of iterations the algorithm will run for", "", &SACSegmentationFromNormalsConfig::max_iterations)));
00274
00275 __min__.probability = 0.5;
00276
00277 __max__.probability = 0.99;
00278
00279 __default__.probability = 0.99;
00280
00281 __param_descriptions__.push_back(SACSegmentationFromNormalsConfig::AbstractParamDescriptionConstPtr(new SACSegmentationFromNormalsConfig::ParamDescription<double>("probability", "double", 0, "The desired probability of choosing at least one sample free from outliers", "", &SACSegmentationFromNormalsConfig::probability)));
00282
00283 __min__.distance_threshold = 0.0;
00284
00285 __max__.distance_threshold = 1.0;
00286
00287 __default__.distance_threshold = 0.02;
00288
00289 __param_descriptions__.push_back(SACSegmentationFromNormalsConfig::AbstractParamDescriptionConstPtr(new SACSegmentationFromNormalsConfig::ParamDescription<double>("distance_threshold", "double", 0, "The distance to model threshold", "", &SACSegmentationFromNormalsConfig::distance_threshold)));
00290
00291 __min__.optimize_coefficients = 0;
00292
00293 __max__.optimize_coefficients = 1;
00294
00295 __default__.optimize_coefficients = 1;
00296
00297 __param_descriptions__.push_back(SACSegmentationFromNormalsConfig::AbstractParamDescriptionConstPtr(new SACSegmentationFromNormalsConfig::ParamDescription<bool>("optimize_coefficients", "bool", 0, "Model coefficient refinement", "", &SACSegmentationFromNormalsConfig::optimize_coefficients)));
00298
00299 __min__.radius_min = 0.0;
00300
00301 __max__.radius_min = 1.0;
00302
00303 __default__.radius_min = 0.0;
00304
00305 __param_descriptions__.push_back(SACSegmentationFromNormalsConfig::AbstractParamDescriptionConstPtr(new SACSegmentationFromNormalsConfig::ParamDescription<double>("radius_min", "double", 0, "The minimum allowed model radius (where applicable)", "", &SACSegmentationFromNormalsConfig::radius_min)));
00306
00307 __min__.radius_max = 0.0;
00308
00309 __max__.radius_max = 1.0;
00310
00311 __default__.radius_max = 0.05;
00312
00313 __param_descriptions__.push_back(SACSegmentationFromNormalsConfig::AbstractParamDescriptionConstPtr(new SACSegmentationFromNormalsConfig::ParamDescription<double>("radius_max", "double", 0, "The maximum allowed model radius (where applicable)", "", &SACSegmentationFromNormalsConfig::radius_max)));
00314
00315 __min__.eps_angle = 0.0;
00316
00317 __max__.eps_angle = 1.5707;
00318
00319 __default__.eps_angle = 0.17;
00320
00321 __param_descriptions__.push_back(SACSegmentationFromNormalsConfig::AbstractParamDescriptionConstPtr(new SACSegmentationFromNormalsConfig::ParamDescription<double>("eps_angle", "double", 0, "The maximum allowed difference between the model normal and the given axis in radians.", "", &SACSegmentationFromNormalsConfig::eps_angle)));
00322
00323 __min__.min_inliers = 0;
00324
00325 __max__.min_inliers = 100000;
00326
00327 __default__.min_inliers = 0;
00328
00329 __param_descriptions__.push_back(SACSegmentationFromNormalsConfig::AbstractParamDescriptionConstPtr(new SACSegmentationFromNormalsConfig::ParamDescription<int>("min_inliers", "int", 0, "The minimum number of inliers a model must have in order to be considered valid.", "", &SACSegmentationFromNormalsConfig::min_inliers)));
00330
00331 __min__.input_frame = "";
00332
00333 __max__.input_frame = "";
00334
00335 __default__.input_frame = "";
00336
00337 __param_descriptions__.push_back(SACSegmentationFromNormalsConfig::AbstractParamDescriptionConstPtr(new SACSegmentationFromNormalsConfig::ParamDescription<std::string>("input_frame", "str", 0, "The input TF frame the data should be transformed into, if input.header.frame_id is different.", "", &SACSegmentationFromNormalsConfig::input_frame)));
00338
00339 __min__.output_frame = "";
00340
00341 __max__.output_frame = "";
00342
00343 __default__.output_frame = "";
00344
00345 __param_descriptions__.push_back(SACSegmentationFromNormalsConfig::AbstractParamDescriptionConstPtr(new SACSegmentationFromNormalsConfig::ParamDescription<std::string>("output_frame", "str", 0, "The output TF frame the data should be transformed into, if input.header.frame_id is different.", "", &SACSegmentationFromNormalsConfig::output_frame)));
00346
00347
00348 for (std::vector<SACSegmentationFromNormalsConfig::AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00349 __description_message__.parameters.push_back(**i);
00350 __max__.__toMessage__(__description_message__.max, __param_descriptions__);
00351 __min__.__toMessage__(__description_message__.min, __param_descriptions__);
00352 __default__.__toMessage__(__description_message__.dflt, __param_descriptions__);
00353 }
00354 std::vector<SACSegmentationFromNormalsConfig::AbstractParamDescriptionConstPtr> __param_descriptions__;
00355 SACSegmentationFromNormalsConfig __max__;
00356 SACSegmentationFromNormalsConfig __min__;
00357 SACSegmentationFromNormalsConfig __default__;
00358 dynamic_reconfigure::ConfigDescription __description_message__;
00359 static const SACSegmentationFromNormalsConfigStatics *get_instance()
00360 {
00361
00362
00363
00364
00365 static SACSegmentationFromNormalsConfigStatics instance;
00366 return &instance;
00367 }
00368 };
00369
00370 inline const dynamic_reconfigure::ConfigDescription &SACSegmentationFromNormalsConfig::__getDescriptionMessage__()
00371 {
00372 return __get_statics__()->__description_message__;
00373 }
00374
00375 inline const SACSegmentationFromNormalsConfig &SACSegmentationFromNormalsConfig::__getDefault__()
00376 {
00377 return __get_statics__()->__default__;
00378 }
00379
00380 inline const SACSegmentationFromNormalsConfig &SACSegmentationFromNormalsConfig::__getMax__()
00381 {
00382 return __get_statics__()->__max__;
00383 }
00384
00385 inline const SACSegmentationFromNormalsConfig &SACSegmentationFromNormalsConfig::__getMin__()
00386 {
00387 return __get_statics__()->__min__;
00388 }
00389
00390 inline const std::vector<SACSegmentationFromNormalsConfig::AbstractParamDescriptionConstPtr> &SACSegmentationFromNormalsConfig::__getParamDescriptions__()
00391 {
00392 return __get_statics__()->__param_descriptions__;
00393 }
00394
00395 inline const SACSegmentationFromNormalsConfigStatics *SACSegmentationFromNormalsConfig::__get_statics__()
00396 {
00397 const static SACSegmentationFromNormalsConfigStatics *statics;
00398
00399 if (statics)
00400 return statics;
00401
00402 boost::mutex::scoped_lock lock(dynamic_reconfigure::__init_mutex__);
00403
00404 if (statics)
00405 return statics;
00406
00407 statics = SACSegmentationFromNormalsConfigStatics::get_instance();
00408
00409 return statics;
00410 }
00411
00412
00413 }
00414
00415 #endif // __SACSEGMENTATIONFROMNORMALSRECONFIGURATOR_H__