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 __openni_camera__OPENNICONFIG_H__
00048 #define __openni_camera__OPENNICONFIG_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 openni_camera
00058 {
00059 class OpenNIConfigStatics;
00060
00061 class OpenNIConfig
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(OpenNIConfig &config, const OpenNIConfig &max, const OpenNIConfig &min) const = 0;
00078 virtual void calcLevel(uint32_t &level, const OpenNIConfig &config1, const OpenNIConfig &config2) const = 0;
00079 virtual void fromServer(const ros::NodeHandle &nh, OpenNIConfig &config) const = 0;
00080 virtual void toServer(const ros::NodeHandle &nh, const OpenNIConfig &config) const = 0;
00081 virtual bool fromMessage(const dynamic_reconfigure::Config &msg, OpenNIConfig &config) const = 0;
00082 virtual void toMessage(dynamic_reconfigure::Config &msg, const OpenNIConfig &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 OpenNIConfig::* f) :
00094 AbstractParamDescription(name, type, level, description, edit_method),
00095 field(f)
00096 {}
00097
00098 T (OpenNIConfig::* field);
00099
00100 virtual void clamp(OpenNIConfig &config, const OpenNIConfig &max, const OpenNIConfig &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 OpenNIConfig &config1, const OpenNIConfig &config2) const
00110 {
00111 if (config1.*field != config2.*field)
00112 comb_level |= level;
00113 }
00114
00115 virtual void fromServer(const ros::NodeHandle &nh, OpenNIConfig &config) const
00116 {
00117 nh.getParam(name, config.*field);
00118 }
00119
00120 virtual void toServer(const ros::NodeHandle &nh, const OpenNIConfig &config) const
00121 {
00122 nh.setParam(name, config.*field);
00123 }
00124
00125 virtual bool fromMessage(const dynamic_reconfigure::Config &msg, OpenNIConfig &config) const
00126 {
00127 return dynamic_reconfigure::ConfigTools::getParameter(msg, name, config.*field);
00128 }
00129
00130 virtual void toMessage(dynamic_reconfigure::Config &msg, const OpenNIConfig &config) const
00131 {
00132 dynamic_reconfigure::ConfigTools::appendParameter(msg, name, config.*field);
00133 }
00134 };
00135
00136
00137 int image_mode;
00138
00139 int debayering;
00140
00141 int depth_mode;
00142
00143 bool depth_registration;
00144
00145 double depth_time_offset;
00146
00147 double image_time_offset;
00148
00149
00150 bool __fromMessage__(dynamic_reconfigure::Config &msg)
00151 {
00152 const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__ = __getParamDescriptions__();
00153 int count = 0;
00154 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00155 if ((*i)->fromMessage(msg, *this))
00156 count++;
00157 if (count != dynamic_reconfigure::ConfigTools::size(msg))
00158 {
00159 ROS_ERROR("OpenNIConfig::__fromMessage__ called with an unexpected parameter.");
00160 ROS_ERROR("Booleans:");
00161 for (unsigned int i = 0; i < msg.bools.size(); i++)
00162 ROS_ERROR(" %s", msg.bools[i].name.c_str());
00163 ROS_ERROR("Integers:");
00164 for (unsigned int i = 0; i < msg.ints.size(); i++)
00165 ROS_ERROR(" %s", msg.ints[i].name.c_str());
00166 ROS_ERROR("Doubles:");
00167 for (unsigned int i = 0; i < msg.doubles.size(); i++)
00168 ROS_ERROR(" %s", msg.doubles[i].name.c_str());
00169 ROS_ERROR("Strings:");
00170 for (unsigned int i = 0; i < msg.strs.size(); i++)
00171 ROS_ERROR(" %s", msg.strs[i].name.c_str());
00172
00173
00174 return false;
00175 }
00176 return true;
00177 }
00178
00179
00180
00181 void __toMessage__(dynamic_reconfigure::Config &msg, const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__) const
00182 {
00183 dynamic_reconfigure::ConfigTools::clear(msg);
00184 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00185 (*i)->toMessage(msg, *this);
00186 }
00187
00188 void __toMessage__(dynamic_reconfigure::Config &msg) const
00189 {
00190 const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__ = __getParamDescriptions__();
00191 __toMessage__(msg, __param_descriptions__);
00192 }
00193
00194 void __toServer__(const ros::NodeHandle &nh) const
00195 {
00196 const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__ = __getParamDescriptions__();
00197 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00198 (*i)->toServer(nh, *this);
00199 }
00200
00201 void __fromServer__(const ros::NodeHandle &nh)
00202 {
00203 const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__ = __getParamDescriptions__();
00204 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00205 (*i)->fromServer(nh, *this);
00206 }
00207
00208 void __clamp__()
00209 {
00210 const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__ = __getParamDescriptions__();
00211 const OpenNIConfig &__max__ = __getMax__();
00212 const OpenNIConfig &__min__ = __getMin__();
00213 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00214 (*i)->clamp(*this, __max__, __min__);
00215 }
00216
00217 uint32_t __level__(const OpenNIConfig &config) const
00218 {
00219 const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__ = __getParamDescriptions__();
00220 uint32_t level = 0;
00221 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00222 (*i)->calcLevel(level, config, *this);
00223 return level;
00224 }
00225
00226 static const dynamic_reconfigure::ConfigDescription &__getDescriptionMessage__();
00227 static const OpenNIConfig &__getDefault__();
00228 static const OpenNIConfig &__getMax__();
00229 static const OpenNIConfig &__getMin__();
00230 static const std::vector<AbstractParamDescriptionConstPtr> &__getParamDescriptions__();
00231
00232 private:
00233 static const OpenNIConfigStatics *__get_statics__();
00234 };
00235
00236 template <>
00237 inline void OpenNIConfig::ParamDescription<std::string>::clamp(OpenNIConfig &config, const OpenNIConfig &max, const OpenNIConfig &min) const
00238 {
00239 return;
00240 }
00241
00242 class OpenNIConfigStatics
00243 {
00244 friend class OpenNIConfig;
00245
00246 OpenNIConfigStatics()
00247 {
00248
00249 __min__.image_mode = 1;
00250
00251 __max__.image_mode = 9;
00252
00253 __default__.image_mode = 2;
00254
00255 __param_descriptions__.push_back(OpenNIConfig::AbstractParamDescriptionConstPtr(new OpenNIConfig::ParamDescription<int>("image_mode", "int", 0, "Image output mode for the color/grayscale image", "{'enum_description': 'output mode', 'enum': [{'srcline': 10, 'description': '1280x1024@15Hz', 'srcfile': '../cfg/OpenNI.cfg', 'cconsttype': 'const int', 'value': 1, 'ctype': 'int', 'type': 'int', 'name': 'SXGA_15Hz'}, {'srcline': 11, 'description': '640x480@30Hz', 'srcfile': '../cfg/OpenNI.cfg', 'cconsttype': 'const int', 'value': 2, 'ctype': 'int', 'type': 'int', 'name': 'VGA_30Hz'}, {'srcline': 12, 'description': '640x480@25Hz', 'srcfile': '../cfg/OpenNI.cfg', 'cconsttype': 'const int', 'value': 3, 'ctype': 'int', 'type': 'int', 'name': 'VGA_25Hz'}, {'srcline': 13, 'description': '320x240@25Hz', 'srcfile': '../cfg/OpenNI.cfg', 'cconsttype': 'const int', 'value': 4, 'ctype': 'int', 'type': 'int', 'name': 'QVGA_25Hz'}, {'srcline': 14, 'description': '320x240@30Hz', 'srcfile': '../cfg/OpenNI.cfg', 'cconsttype': 'const int', 'value': 5, 'ctype': 'int', 'type': 'int', 'name': 'QVGA_30Hz'}, {'srcline': 15, 'description': '320x240@60Hz', 'srcfile': '../cfg/OpenNI.cfg', 'cconsttype': 'const int', 'value': 6, 'ctype': 'int', 'type': 'int', 'name': 'QVGA_60Hz'}, {'srcline': 16, 'description': '160x120@25Hz', 'srcfile': '../cfg/OpenNI.cfg', 'cconsttype': 'const int', 'value': 7, 'ctype': 'int', 'type': 'int', 'name': 'QQVGA_25Hz'}, {'srcline': 17, 'description': '160x120@30Hz', 'srcfile': '../cfg/OpenNI.cfg', 'cconsttype': 'const int', 'value': 8, 'ctype': 'int', 'type': 'int', 'name': 'QQVGA_30Hz'}, {'srcline': 18, 'description': '160x120@60Hz', 'srcfile': '../cfg/OpenNI.cfg', 'cconsttype': 'const int', 'value': 9, 'ctype': 'int', 'type': 'int', 'name': 'QQVGA_60Hz'}]}", &OpenNIConfig::image_mode)));
00256
00257 __min__.debayering = 0;
00258
00259 __max__.debayering = 2;
00260
00261 __default__.debayering = 0;
00262
00263 __param_descriptions__.push_back(OpenNIConfig::AbstractParamDescriptionConstPtr(new OpenNIConfig::ParamDescription<int>("debayering", "int", 0, "Bayer to RGB algorithm", "{'enum_description': 'Bayer to RGB algorithm selection', 'enum': [{'srcline': 21, 'description': 'Fast debayering algorithm using bilinear interpolation', 'srcfile': '../cfg/OpenNI.cfg', 'cconsttype': 'const int', 'value': 0, 'ctype': 'int', 'type': 'int', 'name': 'Bilinear'}, {'srcline': 22, 'description': 'debayering algorithm using an edge-aware algorithm', 'srcfile': '../cfg/OpenNI.cfg', 'cconsttype': 'const int', 'value': 1, 'ctype': 'int', 'type': 'int', 'name': 'EdgeAware'}, {'srcline': 23, 'description': 'debayering algorithm using a weighted edge-aware algorithm', 'srcfile': '../cfg/OpenNI.cfg', 'cconsttype': 'const int', 'value': 2, 'ctype': 'int', 'type': 'int', 'name': 'EdgeAwareWeighted'}]}", &OpenNIConfig::debayering)));
00264
00265 __min__.depth_mode = 2;
00266
00267 __max__.depth_mode = 9;
00268
00269 __default__.depth_mode = 2;
00270
00271 __param_descriptions__.push_back(OpenNIConfig::AbstractParamDescriptionConstPtr(new OpenNIConfig::ParamDescription<int>("depth_mode", "int", 0, "depth output mode", "{'enum_description': 'output mode', 'enum': [{'srcline': 10, 'description': '1280x1024@15Hz', 'srcfile': '../cfg/OpenNI.cfg', 'cconsttype': 'const int', 'value': 1, 'ctype': 'int', 'type': 'int', 'name': 'SXGA_15Hz'}, {'srcline': 11, 'description': '640x480@30Hz', 'srcfile': '../cfg/OpenNI.cfg', 'cconsttype': 'const int', 'value': 2, 'ctype': 'int', 'type': 'int', 'name': 'VGA_30Hz'}, {'srcline': 12, 'description': '640x480@25Hz', 'srcfile': '../cfg/OpenNI.cfg', 'cconsttype': 'const int', 'value': 3, 'ctype': 'int', 'type': 'int', 'name': 'VGA_25Hz'}, {'srcline': 13, 'description': '320x240@25Hz', 'srcfile': '../cfg/OpenNI.cfg', 'cconsttype': 'const int', 'value': 4, 'ctype': 'int', 'type': 'int', 'name': 'QVGA_25Hz'}, {'srcline': 14, 'description': '320x240@30Hz', 'srcfile': '../cfg/OpenNI.cfg', 'cconsttype': 'const int', 'value': 5, 'ctype': 'int', 'type': 'int', 'name': 'QVGA_30Hz'}, {'srcline': 15, 'description': '320x240@60Hz', 'srcfile': '../cfg/OpenNI.cfg', 'cconsttype': 'const int', 'value': 6, 'ctype': 'int', 'type': 'int', 'name': 'QVGA_60Hz'}, {'srcline': 16, 'description': '160x120@25Hz', 'srcfile': '../cfg/OpenNI.cfg', 'cconsttype': 'const int', 'value': 7, 'ctype': 'int', 'type': 'int', 'name': 'QQVGA_25Hz'}, {'srcline': 17, 'description': '160x120@30Hz', 'srcfile': '../cfg/OpenNI.cfg', 'cconsttype': 'const int', 'value': 8, 'ctype': 'int', 'type': 'int', 'name': 'QQVGA_30Hz'}, {'srcline': 18, 'description': '160x120@60Hz', 'srcfile': '../cfg/OpenNI.cfg', 'cconsttype': 'const int', 'value': 9, 'ctype': 'int', 'type': 'int', 'name': 'QQVGA_60Hz'}]}", &OpenNIConfig::depth_mode)));
00272
00273 __min__.depth_registration = 0;
00274
00275 __max__.depth_registration = 1;
00276
00277 __default__.depth_registration = 0;
00278
00279 __param_descriptions__.push_back(OpenNIConfig::AbstractParamDescriptionConstPtr(new OpenNIConfig::ParamDescription<bool>("depth_registration", "bool", 0, "Depth data registration", "", &OpenNIConfig::depth_registration)));
00280
00281 __min__.depth_time_offset = -1.0;
00282
00283 __max__.depth_time_offset = 1.0;
00284
00285 __default__.depth_time_offset = 0.0;
00286
00287 __param_descriptions__.push_back(OpenNIConfig::AbstractParamDescriptionConstPtr(new OpenNIConfig::ParamDescription<double>("depth_time_offset", "double", 0, "depth image time offset in seconds", "", &OpenNIConfig::depth_time_offset)));
00288
00289 __min__.image_time_offset = -1.0;
00290
00291 __max__.image_time_offset = 1.0;
00292
00293 __default__.image_time_offset = 0.0;
00294
00295 __param_descriptions__.push_back(OpenNIConfig::AbstractParamDescriptionConstPtr(new OpenNIConfig::ParamDescription<double>("image_time_offset", "double", 0, "image time offset in seconds", "", &OpenNIConfig::image_time_offset)));
00296
00297
00298 for (std::vector<OpenNIConfig::AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00299 __description_message__.parameters.push_back(**i);
00300 __max__.__toMessage__(__description_message__.max, __param_descriptions__);
00301 __min__.__toMessage__(__description_message__.min, __param_descriptions__);
00302 __default__.__toMessage__(__description_message__.dflt, __param_descriptions__);
00303 }
00304 std::vector<OpenNIConfig::AbstractParamDescriptionConstPtr> __param_descriptions__;
00305 OpenNIConfig __max__;
00306 OpenNIConfig __min__;
00307 OpenNIConfig __default__;
00308 dynamic_reconfigure::ConfigDescription __description_message__;
00309 static const OpenNIConfigStatics *get_instance()
00310 {
00311
00312
00313
00314
00315 static OpenNIConfigStatics instance;
00316 return &instance;
00317 }
00318 };
00319
00320 inline const dynamic_reconfigure::ConfigDescription &OpenNIConfig::__getDescriptionMessage__()
00321 {
00322 return __get_statics__()->__description_message__;
00323 }
00324
00325 inline const OpenNIConfig &OpenNIConfig::__getDefault__()
00326 {
00327 return __get_statics__()->__default__;
00328 }
00329
00330 inline const OpenNIConfig &OpenNIConfig::__getMax__()
00331 {
00332 return __get_statics__()->__max__;
00333 }
00334
00335 inline const OpenNIConfig &OpenNIConfig::__getMin__()
00336 {
00337 return __get_statics__()->__min__;
00338 }
00339
00340 inline const std::vector<OpenNIConfig::AbstractParamDescriptionConstPtr> &OpenNIConfig::__getParamDescriptions__()
00341 {
00342 return __get_statics__()->__param_descriptions__;
00343 }
00344
00345 inline const OpenNIConfigStatics *OpenNIConfig::__get_statics__()
00346 {
00347 const static OpenNIConfigStatics *statics;
00348
00349 if (statics)
00350 return statics;
00351
00352 boost::mutex::scoped_lock lock(dynamic_reconfigure::__init_mutex__);
00353
00354 if (statics)
00355 return statics;
00356
00357 statics = OpenNIConfigStatics::get_instance();
00358
00359 return statics;
00360 }
00361
00362
00363 const int OpenNI_SXGA_15Hz = 1;
00364
00365 const int OpenNI_VGA_30Hz = 2;
00366
00367 const int OpenNI_VGA_25Hz = 3;
00368
00369 const int OpenNI_QVGA_25Hz = 4;
00370
00371 const int OpenNI_QVGA_30Hz = 5;
00372
00373 const int OpenNI_QVGA_60Hz = 6;
00374
00375 const int OpenNI_QQVGA_25Hz = 7;
00376
00377 const int OpenNI_QQVGA_30Hz = 8;
00378
00379 const int OpenNI_QQVGA_60Hz = 9;
00380
00381 const int OpenNI_Bilinear = 0;
00382
00383 const int OpenNI_EdgeAware = 1;
00384
00385 const int OpenNI_EdgeAwareWeighted = 2;
00386 }
00387
00388 #endif // __OPENNIRECONFIGURATOR_H__