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 __pointcloud_to_laserscan__CLOUDSCANCONFIG_H__
00048 #define __pointcloud_to_laserscan__CLOUDSCANCONFIG_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 pointcloud_to_laserscan
00058 {
00059 class CloudScanConfigStatics;
00060
00061 class CloudScanConfig
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(CloudScanConfig &config, const CloudScanConfig &max, const CloudScanConfig &min) const = 0;
00078 virtual void calcLevel(uint32_t &level, const CloudScanConfig &config1, const CloudScanConfig &config2) const = 0;
00079 virtual void fromServer(const ros::NodeHandle &nh, CloudScanConfig &config) const = 0;
00080 virtual void toServer(const ros::NodeHandle &nh, const CloudScanConfig &config) const = 0;
00081 virtual bool fromMessage(const dynamic_reconfigure::Config &msg, CloudScanConfig &config) const = 0;
00082 virtual void toMessage(dynamic_reconfigure::Config &msg, const CloudScanConfig &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 CloudScanConfig::* f) :
00094 AbstractParamDescription(name, type, level, description, edit_method),
00095 field(f)
00096 {}
00097
00098 T (CloudScanConfig::* field);
00099
00100 virtual void clamp(CloudScanConfig &config, const CloudScanConfig &max, const CloudScanConfig &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 CloudScanConfig &config1, const CloudScanConfig &config2) const
00110 {
00111 if (config1.*field != config2.*field)
00112 comb_level |= level;
00113 }
00114
00115 virtual void fromServer(const ros::NodeHandle &nh, CloudScanConfig &config) const
00116 {
00117 nh.getParam(name, config.*field);
00118 }
00119
00120 virtual void toServer(const ros::NodeHandle &nh, const CloudScanConfig &config) const
00121 {
00122 nh.setParam(name, config.*field);
00123 }
00124
00125 virtual bool fromMessage(const dynamic_reconfigure::Config &msg, CloudScanConfig &config) const
00126 {
00127 return dynamic_reconfigure::ConfigTools::getParameter(msg, name, config.*field);
00128 }
00129
00130 virtual void toMessage(dynamic_reconfigure::Config &msg, const CloudScanConfig &config) const
00131 {
00132 dynamic_reconfigure::ConfigTools::appendParameter(msg, name, config.*field);
00133 }
00134 };
00135
00136
00137 double min_height;
00138
00139 double max_height;
00140
00141 double angle_min;
00142
00143 double angle_max;
00144
00145 double angle_increment;
00146
00147 double scan_time;
00148
00149 double range_min;
00150
00151 double range_max;
00152
00153 std::string output_frame_id;
00154
00155
00156 bool __fromMessage__(dynamic_reconfigure::Config &msg)
00157 {
00158 const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__ = __getParamDescriptions__();
00159 int count = 0;
00160 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00161 if ((*i)->fromMessage(msg, *this))
00162 count++;
00163 if (count != dynamic_reconfigure::ConfigTools::size(msg))
00164 {
00165 ROS_ERROR("CloudScanConfig::__fromMessage__ called with an unexpected parameter.");
00166 ROS_ERROR("Booleans:");
00167 for (unsigned int i = 0; i < msg.bools.size(); i++)
00168 ROS_ERROR(" %s", msg.bools[i].name.c_str());
00169 ROS_ERROR("Integers:");
00170 for (unsigned int i = 0; i < msg.ints.size(); i++)
00171 ROS_ERROR(" %s", msg.ints[i].name.c_str());
00172 ROS_ERROR("Doubles:");
00173 for (unsigned int i = 0; i < msg.doubles.size(); i++)
00174 ROS_ERROR(" %s", msg.doubles[i].name.c_str());
00175 ROS_ERROR("Strings:");
00176 for (unsigned int i = 0; i < msg.strs.size(); i++)
00177 ROS_ERROR(" %s", msg.strs[i].name.c_str());
00178
00179
00180 return false;
00181 }
00182 return true;
00183 }
00184
00185
00186
00187 void __toMessage__(dynamic_reconfigure::Config &msg, const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__) const
00188 {
00189 dynamic_reconfigure::ConfigTools::clear(msg);
00190 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00191 (*i)->toMessage(msg, *this);
00192 }
00193
00194 void __toMessage__(dynamic_reconfigure::Config &msg) const
00195 {
00196 const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__ = __getParamDescriptions__();
00197 __toMessage__(msg, __param_descriptions__);
00198 }
00199
00200 void __toServer__(const ros::NodeHandle &nh) const
00201 {
00202 const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__ = __getParamDescriptions__();
00203 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00204 (*i)->toServer(nh, *this);
00205 }
00206
00207 void __fromServer__(const ros::NodeHandle &nh)
00208 {
00209 const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__ = __getParamDescriptions__();
00210 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00211 (*i)->fromServer(nh, *this);
00212 }
00213
00214 void __clamp__()
00215 {
00216 const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__ = __getParamDescriptions__();
00217 const CloudScanConfig &__max__ = __getMax__();
00218 const CloudScanConfig &__min__ = __getMin__();
00219 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00220 (*i)->clamp(*this, __max__, __min__);
00221 }
00222
00223 uint32_t __level__(const CloudScanConfig &config) const
00224 {
00225 const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__ = __getParamDescriptions__();
00226 uint32_t level = 0;
00227 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00228 (*i)->calcLevel(level, config, *this);
00229 return level;
00230 }
00231
00232 static const dynamic_reconfigure::ConfigDescription &__getDescriptionMessage__();
00233 static const CloudScanConfig &__getDefault__();
00234 static const CloudScanConfig &__getMax__();
00235 static const CloudScanConfig &__getMin__();
00236 static const std::vector<AbstractParamDescriptionConstPtr> &__getParamDescriptions__();
00237
00238 private:
00239 static const CloudScanConfigStatics *__get_statics__();
00240 };
00241
00242 template <>
00243 inline void CloudScanConfig::ParamDescription<std::string>::clamp(CloudScanConfig &config, const CloudScanConfig &max, const CloudScanConfig &min) const
00244 {
00245 return;
00246 }
00247
00248 class CloudScanConfigStatics
00249 {
00250 friend class CloudScanConfig;
00251
00252 CloudScanConfigStatics()
00253 {
00254
00255 __min__.min_height = 0.0;
00256
00257 __max__.min_height = 100.0;
00258
00259 __default__.min_height = 0.1;
00260
00261 __param_descriptions__.push_back(CloudScanConfig::AbstractParamDescriptionConstPtr(new CloudScanConfig::ParamDescription<double>("min_height", "double", 0, "The minimum height to include from the point cloud.", "", &CloudScanConfig::min_height)));
00262
00263 __min__.max_height = 0.0;
00264
00265 __max__.max_height = 100.0;
00266
00267 __default__.max_height = 0.15;
00268
00269 __param_descriptions__.push_back(CloudScanConfig::AbstractParamDescriptionConstPtr(new CloudScanConfig::ParamDescription<double>("max_height", "double", 0, "The maximum height to include from the point cloud.", "", &CloudScanConfig::max_height)));
00270
00271 __min__.angle_min = -3.14159265359;
00272
00273 __max__.angle_min = 3.14159265359;
00274
00275 __default__.angle_min = -1.57079632679;
00276
00277 __param_descriptions__.push_back(CloudScanConfig::AbstractParamDescriptionConstPtr(new CloudScanConfig::ParamDescription<double>("angle_min", "double", 0, "The minimum angle of the resulting laser scan.", "", &CloudScanConfig::angle_min)));
00278
00279 __min__.angle_max = -3.14159265359;
00280
00281 __max__.angle_max = 3.14159265359;
00282
00283 __default__.angle_max = 1.57079632679;
00284
00285 __param_descriptions__.push_back(CloudScanConfig::AbstractParamDescriptionConstPtr(new CloudScanConfig::ParamDescription<double>("angle_max", "double", 0, "The maximum angle of the resulting laser scan.", "", &CloudScanConfig::angle_max)));
00286
00287 __min__.angle_increment = 0.0;
00288
00289 __max__.angle_increment = 3.14159265359;
00290
00291 __default__.angle_increment = 0.00872664625997;
00292
00293 __param_descriptions__.push_back(CloudScanConfig::AbstractParamDescriptionConstPtr(new CloudScanConfig::ParamDescription<double>("angle_increment", "double", 0, "The angle increment of the resulting laser scan.", "", &CloudScanConfig::angle_increment)));
00294
00295 __min__.scan_time = 0.0;
00296
00297 __max__.scan_time = 1.0;
00298
00299 __default__.scan_time = 0.0333333333333;
00300
00301 __param_descriptions__.push_back(CloudScanConfig::AbstractParamDescriptionConstPtr(new CloudScanConfig::ParamDescription<double>("scan_time", "double", 0, "The scan time of the resulting laser scan.", "", &CloudScanConfig::scan_time)));
00302
00303 __min__.range_min = 0.0;
00304
00305 __max__.range_min = 100.0;
00306
00307 __default__.range_min = 0.45;
00308
00309 __param_descriptions__.push_back(CloudScanConfig::AbstractParamDescriptionConstPtr(new CloudScanConfig::ParamDescription<double>("range_min", "double", 0, "The minimum range of the resulting laser scan.", "", &CloudScanConfig::range_min)));
00310
00311 __min__.range_max = 0.0;
00312
00313 __max__.range_max = 100.0;
00314
00315 __default__.range_max = 10.0;
00316
00317 __param_descriptions__.push_back(CloudScanConfig::AbstractParamDescriptionConstPtr(new CloudScanConfig::ParamDescription<double>("range_max", "double", 0, "The maximum range of the resulting laser scan.", "", &CloudScanConfig::range_max)));
00318
00319 __min__.output_frame_id = "";
00320
00321 __max__.output_frame_id = "";
00322
00323 __default__.output_frame_id = "/openi_depth_frame";
00324
00325 __param_descriptions__.push_back(CloudScanConfig::AbstractParamDescriptionConstPtr(new CloudScanConfig::ParamDescription<std::string>("output_frame_id", "str", 0, "The frame id of the resulting laser scan.", "", &CloudScanConfig::output_frame_id)));
00326
00327
00328 for (std::vector<CloudScanConfig::AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00329 __description_message__.parameters.push_back(**i);
00330 __max__.__toMessage__(__description_message__.max, __param_descriptions__);
00331 __min__.__toMessage__(__description_message__.min, __param_descriptions__);
00332 __default__.__toMessage__(__description_message__.dflt, __param_descriptions__);
00333 }
00334 std::vector<CloudScanConfig::AbstractParamDescriptionConstPtr> __param_descriptions__;
00335 CloudScanConfig __max__;
00336 CloudScanConfig __min__;
00337 CloudScanConfig __default__;
00338 dynamic_reconfigure::ConfigDescription __description_message__;
00339 static const CloudScanConfigStatics *get_instance()
00340 {
00341
00342
00343
00344
00345 static CloudScanConfigStatics instance;
00346 return &instance;
00347 }
00348 };
00349
00350 inline const dynamic_reconfigure::ConfigDescription &CloudScanConfig::__getDescriptionMessage__()
00351 {
00352 return __get_statics__()->__description_message__;
00353 }
00354
00355 inline const CloudScanConfig &CloudScanConfig::__getDefault__()
00356 {
00357 return __get_statics__()->__default__;
00358 }
00359
00360 inline const CloudScanConfig &CloudScanConfig::__getMax__()
00361 {
00362 return __get_statics__()->__max__;
00363 }
00364
00365 inline const CloudScanConfig &CloudScanConfig::__getMin__()
00366 {
00367 return __get_statics__()->__min__;
00368 }
00369
00370 inline const std::vector<CloudScanConfig::AbstractParamDescriptionConstPtr> &CloudScanConfig::__getParamDescriptions__()
00371 {
00372 return __get_statics__()->__param_descriptions__;
00373 }
00374
00375 inline const CloudScanConfigStatics *CloudScanConfig::__get_statics__()
00376 {
00377 const static CloudScanConfigStatics *statics;
00378
00379 if (statics)
00380 return statics;
00381
00382 boost::mutex::scoped_lock lock(dynamic_reconfigure::__init_mutex__);
00383
00384 if (statics)
00385 return statics;
00386
00387 statics = CloudScanConfigStatics::get_instance();
00388
00389 return statics;
00390 }
00391
00392
00393 }
00394
00395 #endif // __CLOUDSCANRECONFIGURATOR_H__