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__EXTRACTINDICESCONFIG_H__
00048 #define __pcl_ros__EXTRACTINDICESCONFIG_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 ExtractIndicesConfigStatics;
00060
00061 class ExtractIndicesConfig
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(ExtractIndicesConfig &config, const ExtractIndicesConfig &max, const ExtractIndicesConfig &min) const = 0;
00078 virtual void calcLevel(uint32_t &level, const ExtractIndicesConfig &config1, const ExtractIndicesConfig &config2) const = 0;
00079 virtual void fromServer(const ros::NodeHandle &nh, ExtractIndicesConfig &config) const = 0;
00080 virtual void toServer(const ros::NodeHandle &nh, const ExtractIndicesConfig &config) const = 0;
00081 virtual bool fromMessage(const dynamic_reconfigure::Config &msg, ExtractIndicesConfig &config) const = 0;
00082 virtual void toMessage(dynamic_reconfigure::Config &msg, const ExtractIndicesConfig &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 ExtractIndicesConfig::* f) :
00094 AbstractParamDescription(name, type, level, description, edit_method),
00095 field(f)
00096 {}
00097
00098 T (ExtractIndicesConfig::* field);
00099
00100 virtual void clamp(ExtractIndicesConfig &config, const ExtractIndicesConfig &max, const ExtractIndicesConfig &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 ExtractIndicesConfig &config1, const ExtractIndicesConfig &config2) const
00110 {
00111 if (config1.*field != config2.*field)
00112 comb_level |= level;
00113 }
00114
00115 virtual void fromServer(const ros::NodeHandle &nh, ExtractIndicesConfig &config) const
00116 {
00117 nh.getParam(name, config.*field);
00118 }
00119
00120 virtual void toServer(const ros::NodeHandle &nh, const ExtractIndicesConfig &config) const
00121 {
00122 nh.setParam(name, config.*field);
00123 }
00124
00125 virtual bool fromMessage(const dynamic_reconfigure::Config &msg, ExtractIndicesConfig &config) const
00126 {
00127 return dynamic_reconfigure::ConfigTools::getParameter(msg, name, config.*field);
00128 }
00129
00130 virtual void toMessage(dynamic_reconfigure::Config &msg, const ExtractIndicesConfig &config) const
00131 {
00132 dynamic_reconfigure::ConfigTools::appendParameter(msg, name, config.*field);
00133 }
00134 };
00135
00136
00137 bool negative;
00138
00139
00140 bool __fromMessage__(dynamic_reconfigure::Config &msg)
00141 {
00142 const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__ = __getParamDescriptions__();
00143 int count = 0;
00144 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00145 if ((*i)->fromMessage(msg, *this))
00146 count++;
00147 if (count != dynamic_reconfigure::ConfigTools::size(msg))
00148 {
00149 ROS_ERROR("ExtractIndicesConfig::__fromMessage__ called with an unexpected parameter.");
00150 ROS_ERROR("Booleans:");
00151 for (unsigned int i = 0; i < msg.bools.size(); i++)
00152 ROS_ERROR(" %s", msg.bools[i].name.c_str());
00153 ROS_ERROR("Integers:");
00154 for (unsigned int i = 0; i < msg.ints.size(); i++)
00155 ROS_ERROR(" %s", msg.ints[i].name.c_str());
00156 ROS_ERROR("Doubles:");
00157 for (unsigned int i = 0; i < msg.doubles.size(); i++)
00158 ROS_ERROR(" %s", msg.doubles[i].name.c_str());
00159 ROS_ERROR("Strings:");
00160 for (unsigned int i = 0; i < msg.strs.size(); i++)
00161 ROS_ERROR(" %s", msg.strs[i].name.c_str());
00162
00163
00164 return false;
00165 }
00166 return true;
00167 }
00168
00169
00170
00171 void __toMessage__(dynamic_reconfigure::Config &msg, const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__) const
00172 {
00173 dynamic_reconfigure::ConfigTools::clear(msg);
00174 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00175 (*i)->toMessage(msg, *this);
00176 }
00177
00178 void __toMessage__(dynamic_reconfigure::Config &msg) const
00179 {
00180 const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__ = __getParamDescriptions__();
00181 __toMessage__(msg, __param_descriptions__);
00182 }
00183
00184 void __toServer__(const ros::NodeHandle &nh) const
00185 {
00186 const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__ = __getParamDescriptions__();
00187 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00188 (*i)->toServer(nh, *this);
00189 }
00190
00191 void __fromServer__(const ros::NodeHandle &nh)
00192 {
00193 const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__ = __getParamDescriptions__();
00194 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00195 (*i)->fromServer(nh, *this);
00196 }
00197
00198 void __clamp__()
00199 {
00200 const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__ = __getParamDescriptions__();
00201 const ExtractIndicesConfig &__max__ = __getMax__();
00202 const ExtractIndicesConfig &__min__ = __getMin__();
00203 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00204 (*i)->clamp(*this, __max__, __min__);
00205 }
00206
00207 uint32_t __level__(const ExtractIndicesConfig &config) const
00208 {
00209 const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__ = __getParamDescriptions__();
00210 uint32_t level = 0;
00211 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00212 (*i)->calcLevel(level, config, *this);
00213 return level;
00214 }
00215
00216 static const dynamic_reconfigure::ConfigDescription &__getDescriptionMessage__();
00217 static const ExtractIndicesConfig &__getDefault__();
00218 static const ExtractIndicesConfig &__getMax__();
00219 static const ExtractIndicesConfig &__getMin__();
00220 static const std::vector<AbstractParamDescriptionConstPtr> &__getParamDescriptions__();
00221
00222 private:
00223 static const ExtractIndicesConfigStatics *__get_statics__();
00224 };
00225
00226 template <>
00227 inline void ExtractIndicesConfig::ParamDescription<std::string>::clamp(ExtractIndicesConfig &config, const ExtractIndicesConfig &max, const ExtractIndicesConfig &min) const
00228 {
00229 return;
00230 }
00231
00232 class ExtractIndicesConfigStatics
00233 {
00234 friend class ExtractIndicesConfig;
00235
00236 ExtractIndicesConfigStatics()
00237 {
00238
00239 __min__.negative = 0;
00240
00241 __max__.negative = 1;
00242
00243 __default__.negative = 0;
00244
00245 __param_descriptions__.push_back(ExtractIndicesConfig::AbstractParamDescriptionConstPtr(new ExtractIndicesConfig::ParamDescription<bool>("negative", "bool", 0, "Extract indices or the negative (all-indices)", "", &ExtractIndicesConfig::negative)));
00246
00247
00248 for (std::vector<ExtractIndicesConfig::AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00249 __description_message__.parameters.push_back(**i);
00250 __max__.__toMessage__(__description_message__.max, __param_descriptions__);
00251 __min__.__toMessage__(__description_message__.min, __param_descriptions__);
00252 __default__.__toMessage__(__description_message__.dflt, __param_descriptions__);
00253 }
00254 std::vector<ExtractIndicesConfig::AbstractParamDescriptionConstPtr> __param_descriptions__;
00255 ExtractIndicesConfig __max__;
00256 ExtractIndicesConfig __min__;
00257 ExtractIndicesConfig __default__;
00258 dynamic_reconfigure::ConfigDescription __description_message__;
00259 static const ExtractIndicesConfigStatics *get_instance()
00260 {
00261
00262
00263
00264
00265 static ExtractIndicesConfigStatics instance;
00266 return &instance;
00267 }
00268 };
00269
00270 inline const dynamic_reconfigure::ConfigDescription &ExtractIndicesConfig::__getDescriptionMessage__()
00271 {
00272 return __get_statics__()->__description_message__;
00273 }
00274
00275 inline const ExtractIndicesConfig &ExtractIndicesConfig::__getDefault__()
00276 {
00277 return __get_statics__()->__default__;
00278 }
00279
00280 inline const ExtractIndicesConfig &ExtractIndicesConfig::__getMax__()
00281 {
00282 return __get_statics__()->__max__;
00283 }
00284
00285 inline const ExtractIndicesConfig &ExtractIndicesConfig::__getMin__()
00286 {
00287 return __get_statics__()->__min__;
00288 }
00289
00290 inline const std::vector<ExtractIndicesConfig::AbstractParamDescriptionConstPtr> &ExtractIndicesConfig::__getParamDescriptions__()
00291 {
00292 return __get_statics__()->__param_descriptions__;
00293 }
00294
00295 inline const ExtractIndicesConfigStatics *ExtractIndicesConfig::__get_statics__()
00296 {
00297 const static ExtractIndicesConfigStatics *statics;
00298
00299 if (statics)
00300 return statics;
00301
00302 boost::mutex::scoped_lock lock(dynamic_reconfigure::__init_mutex__);
00303
00304 if (statics)
00305 return statics;
00306
00307 statics = ExtractIndicesConfigStatics::get_instance();
00308
00309 return statics;
00310 }
00311
00312
00313 }
00314
00315 #endif // __EXTRACTINDICESRECONFIGURATOR_H__