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 __prosilica_camera__PROSILICACAMERACONFIG_H__
00048 #define __prosilica_camera__PROSILICACAMERACONFIG_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 prosilica_camera
00058 {
00059 class ProsilicaCameraConfigStatics;
00060
00061 class ProsilicaCameraConfig
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(ProsilicaCameraConfig &config, const ProsilicaCameraConfig &max, const ProsilicaCameraConfig &min) const = 0;
00078 virtual void calcLevel(uint32_t &level, const ProsilicaCameraConfig &config1, const ProsilicaCameraConfig &config2) const = 0;
00079 virtual void fromServer(const ros::NodeHandle &nh, ProsilicaCameraConfig &config) const = 0;
00080 virtual void toServer(const ros::NodeHandle &nh, const ProsilicaCameraConfig &config) const = 0;
00081 virtual bool fromMessage(const dynamic_reconfigure::Config &msg, ProsilicaCameraConfig &config) const = 0;
00082 virtual void toMessage(dynamic_reconfigure::Config &msg, const ProsilicaCameraConfig &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 ProsilicaCameraConfig::* f) :
00094 AbstractParamDescription(name, type, level, description, edit_method),
00095 field(f)
00096 {}
00097
00098 T (ProsilicaCameraConfig::* field);
00099
00100 virtual void clamp(ProsilicaCameraConfig &config, const ProsilicaCameraConfig &max, const ProsilicaCameraConfig &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 ProsilicaCameraConfig &config1, const ProsilicaCameraConfig &config2) const
00110 {
00111 if (config1.*field != config2.*field)
00112 comb_level |= level;
00113 }
00114
00115 virtual void fromServer(const ros::NodeHandle &nh, ProsilicaCameraConfig &config) const
00116 {
00117 nh.getParam(name, config.*field);
00118 }
00119
00120 virtual void toServer(const ros::NodeHandle &nh, const ProsilicaCameraConfig &config) const
00121 {
00122 nh.setParam(name, config.*field);
00123 }
00124
00125 virtual bool fromMessage(const dynamic_reconfigure::Config &msg, ProsilicaCameraConfig &config) const
00126 {
00127 return dynamic_reconfigure::ConfigTools::getParameter(msg, name, config.*field);
00128 }
00129
00130 virtual void toMessage(dynamic_reconfigure::Config &msg, const ProsilicaCameraConfig &config) const
00131 {
00132 dynamic_reconfigure::ConfigTools::appendParameter(msg, name, config.*field);
00133 }
00134 };
00135
00136
00137 std::string trigger_mode;
00138
00139 bool auto_exposure;
00140
00141 double exposure;
00142
00143 bool auto_gain;
00144
00145 int gain;
00146
00147 bool auto_whitebalance;
00148
00149 int whitebalance_red;
00150
00151 int whitebalance_blue;
00152
00153 int binning_x;
00154
00155 int binning_y;
00156
00157 int x_offset;
00158
00159 int y_offset;
00160
00161 int width;
00162
00163 int height;
00164
00165 std::string frame_id;
00166
00167 std::string trig_timestamp_topic;
00168
00169 double trig_rate;
00170
00171
00172 bool __fromMessage__(dynamic_reconfigure::Config &msg)
00173 {
00174 const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__ = __getParamDescriptions__();
00175 int count = 0;
00176 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00177 if ((*i)->fromMessage(msg, *this))
00178 count++;
00179 if (count != dynamic_reconfigure::ConfigTools::size(msg))
00180 {
00181 ROS_ERROR("ProsilicaCameraConfig::__fromMessage__ called with an unexpected parameter.");
00182 ROS_ERROR("Booleans:");
00183 for (unsigned int i = 0; i < msg.bools.size(); i++)
00184 ROS_ERROR(" %s", msg.bools[i].name.c_str());
00185 ROS_ERROR("Integers:");
00186 for (unsigned int i = 0; i < msg.ints.size(); i++)
00187 ROS_ERROR(" %s", msg.ints[i].name.c_str());
00188 ROS_ERROR("Doubles:");
00189 for (unsigned int i = 0; i < msg.doubles.size(); i++)
00190 ROS_ERROR(" %s", msg.doubles[i].name.c_str());
00191 ROS_ERROR("Strings:");
00192 for (unsigned int i = 0; i < msg.strs.size(); i++)
00193 ROS_ERROR(" %s", msg.strs[i].name.c_str());
00194
00195
00196 return false;
00197 }
00198 return true;
00199 }
00200
00201
00202
00203 void __toMessage__(dynamic_reconfigure::Config &msg, const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__) const
00204 {
00205 dynamic_reconfigure::ConfigTools::clear(msg);
00206 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00207 (*i)->toMessage(msg, *this);
00208 }
00209
00210 void __toMessage__(dynamic_reconfigure::Config &msg) const
00211 {
00212 const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__ = __getParamDescriptions__();
00213 __toMessage__(msg, __param_descriptions__);
00214 }
00215
00216 void __toServer__(const ros::NodeHandle &nh) const
00217 {
00218 const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__ = __getParamDescriptions__();
00219 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00220 (*i)->toServer(nh, *this);
00221 }
00222
00223 void __fromServer__(const ros::NodeHandle &nh)
00224 {
00225 const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__ = __getParamDescriptions__();
00226 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00227 (*i)->fromServer(nh, *this);
00228 }
00229
00230 void __clamp__()
00231 {
00232 const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__ = __getParamDescriptions__();
00233 const ProsilicaCameraConfig &__max__ = __getMax__();
00234 const ProsilicaCameraConfig &__min__ = __getMin__();
00235 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00236 (*i)->clamp(*this, __max__, __min__);
00237 }
00238
00239 uint32_t __level__(const ProsilicaCameraConfig &config) const
00240 {
00241 const std::vector<AbstractParamDescriptionConstPtr> &__param_descriptions__ = __getParamDescriptions__();
00242 uint32_t level = 0;
00243 for (std::vector<AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00244 (*i)->calcLevel(level, config, *this);
00245 return level;
00246 }
00247
00248 static const dynamic_reconfigure::ConfigDescription &__getDescriptionMessage__();
00249 static const ProsilicaCameraConfig &__getDefault__();
00250 static const ProsilicaCameraConfig &__getMax__();
00251 static const ProsilicaCameraConfig &__getMin__();
00252 static const std::vector<AbstractParamDescriptionConstPtr> &__getParamDescriptions__();
00253
00254 private:
00255 static const ProsilicaCameraConfigStatics *__get_statics__();
00256 };
00257
00258 template <>
00259 inline void ProsilicaCameraConfig::ParamDescription<std::string>::clamp(ProsilicaCameraConfig &config, const ProsilicaCameraConfig &max, const ProsilicaCameraConfig &min) const
00260 {
00261 return;
00262 }
00263
00264 class ProsilicaCameraConfigStatics
00265 {
00266 friend class ProsilicaCameraConfig;
00267
00268 ProsilicaCameraConfigStatics()
00269 {
00270
00271 __min__.trigger_mode = "";
00272
00273 __max__.trigger_mode = "";
00274
00275 __default__.trigger_mode = "streaming";
00276
00277 __param_descriptions__.push_back(ProsilicaCameraConfig::AbstractParamDescriptionConstPtr(new ProsilicaCameraConfig::ParamDescription<std::string>("trigger_mode", "str", 1, "Camera Trigger mode", "{'enum_description': 'Enum to set the trigger mode', 'enum': [{'srcline': 11, 'description': 'Run at maximum frame rate', 'srcfile': '../cfg/ProsilicaCamera.cfg', 'cconsttype': 'const char * const', 'value': 'streaming', 'ctype': 'std::string', 'type': 'str', 'name': 'StreamingMode'}, {'srcline': 12, 'description': 'Capture frame in response to service call', 'srcfile': '../cfg/ProsilicaCamera.cfg', 'cconsttype': 'const char * const', 'value': 'polled', 'ctype': 'std::string', 'type': 'str', 'name': 'PolledMode'}, {'srcline': 14, 'description': 'External trigger on SyncIn1 line', 'srcfile': '../cfg/ProsilicaCamera.cfg', 'cconsttype': 'const char * const', 'value': 'syncin1', 'ctype': 'std::string', 'type': 'str', 'name': 'External1Mode'}, {'srcline': 15, 'description': 'External trigger on SyncIn2 line', 'srcfile': '../cfg/ProsilicaCamera.cfg', 'cconsttype': 'const char * const', 'value': 'syncin2', 'ctype': 'std::string', 'type': 'str', 'name': 'External2Mode'}]}", &ProsilicaCameraConfig::trigger_mode)));
00278
00279 __min__.auto_exposure = 0;
00280
00281 __max__.auto_exposure = 1;
00282
00283 __default__.auto_exposure = 1;
00284
00285 __param_descriptions__.push_back(ProsilicaCameraConfig::AbstractParamDescriptionConstPtr(new ProsilicaCameraConfig::ParamDescription<bool>("auto_exposure", "bool", 0, "Sets the camera exposure duration to automatic. Causes the @b exposure setting to be ignored.", "", &ProsilicaCameraConfig::auto_exposure)));
00286
00287 __min__.exposure = 2.5e-05;
00288
00289 __max__.exposure = 60.0;
00290
00291 __default__.exposure = 0.025;
00292
00293 __param_descriptions__.push_back(ProsilicaCameraConfig::AbstractParamDescriptionConstPtr(new ProsilicaCameraConfig::ParamDescription<double>("exposure", "double", 0, "Camera exposure time in seconds.", "", &ProsilicaCameraConfig::exposure)));
00294
00295 __min__.auto_gain = 0;
00296
00297 __max__.auto_gain = 1;
00298
00299 __default__.auto_gain = 1;
00300
00301 __param_descriptions__.push_back(ProsilicaCameraConfig::AbstractParamDescriptionConstPtr(new ProsilicaCameraConfig::ParamDescription<bool>("auto_gain", "bool", 0, "Sets the analog gain to automatic. Causes the @b gain setting to be ignored.", "", &ProsilicaCameraConfig::auto_gain)));
00302
00303 __min__.gain = 0;
00304
00305 __max__.gain = 24;
00306
00307 __default__.gain = 0;
00308
00309 __param_descriptions__.push_back(ProsilicaCameraConfig::AbstractParamDescriptionConstPtr(new ProsilicaCameraConfig::ParamDescription<int>("gain", "int", 0, "The gain level in dB.", "", &ProsilicaCameraConfig::gain)));
00310
00311 __min__.auto_whitebalance = 0;
00312
00313 __max__.auto_whitebalance = 1;
00314
00315 __default__.auto_whitebalance = 1;
00316
00317 __param_descriptions__.push_back(ProsilicaCameraConfig::AbstractParamDescriptionConstPtr(new ProsilicaCameraConfig::ParamDescription<bool>("auto_whitebalance", "bool", 0, "Whether whitebalance will continuously adjust to the current scene. Causes the @b whitebalance_red and @b whitebalance_blue settings to be ignored.", "", &ProsilicaCameraConfig::auto_whitebalance)));
00318
00319 __min__.whitebalance_red = 80;
00320
00321 __max__.whitebalance_red = 300;
00322
00323 __default__.whitebalance_red = 100;
00324
00325 __param_descriptions__.push_back(ProsilicaCameraConfig::AbstractParamDescriptionConstPtr(new ProsilicaCameraConfig::ParamDescription<int>("whitebalance_red", "int", 0, "Red gain as a percentage of the camera default setting.", "", &ProsilicaCameraConfig::whitebalance_red)));
00326
00327 __min__.whitebalance_blue = 80;
00328
00329 __max__.whitebalance_blue = 300;
00330
00331 __default__.whitebalance_blue = 100;
00332
00333 __param_descriptions__.push_back(ProsilicaCameraConfig::AbstractParamDescriptionConstPtr(new ProsilicaCameraConfig::ParamDescription<int>("whitebalance_blue", "int", 0, "Blue gain as a percentage of the camera default setting.", "", &ProsilicaCameraConfig::whitebalance_blue)));
00334
00335 __min__.binning_x = 1;
00336
00337 __max__.binning_x = 8;
00338
00339 __default__.binning_x = 1;
00340
00341 __param_descriptions__.push_back(ProsilicaCameraConfig::AbstractParamDescriptionConstPtr(new ProsilicaCameraConfig::ParamDescription<int>("binning_x", "int", 0, "Number of pixels to bin together horizontally.", "", &ProsilicaCameraConfig::binning_x)));
00342
00343 __min__.binning_y = 1;
00344
00345 __max__.binning_y = 14;
00346
00347 __default__.binning_y = 1;
00348
00349 __param_descriptions__.push_back(ProsilicaCameraConfig::AbstractParamDescriptionConstPtr(new ProsilicaCameraConfig::ParamDescription<int>("binning_y", "int", 0, "Number of pixels to bin together vertically.", "", &ProsilicaCameraConfig::binning_y)));
00350
00351 __min__.x_offset = 0;
00352
00353 __max__.x_offset = 2447;
00354
00355 __default__.x_offset = 0;
00356
00357 __param_descriptions__.push_back(ProsilicaCameraConfig::AbstractParamDescriptionConstPtr(new ProsilicaCameraConfig::ParamDescription<int>("x_offset", "int", 0, "X offset of the region of interest.", "", &ProsilicaCameraConfig::x_offset)));
00358
00359 __min__.y_offset = 0;
00360
00361 __max__.y_offset = 2049;
00362
00363 __default__.y_offset = 0;
00364
00365 __param_descriptions__.push_back(ProsilicaCameraConfig::AbstractParamDescriptionConstPtr(new ProsilicaCameraConfig::ParamDescription<int>("y_offset", "int", 0, "Y offset of the region of interest.", "", &ProsilicaCameraConfig::y_offset)));
00366
00367 __min__.width = 0;
00368
00369 __max__.width = 2448;
00370
00371 __default__.width = 0;
00372
00373 __param_descriptions__.push_back(ProsilicaCameraConfig::AbstractParamDescriptionConstPtr(new ProsilicaCameraConfig::ParamDescription<int>("width", "int", 0, "Width of the region of interest (0 for automatic).", "", &ProsilicaCameraConfig::width)));
00374
00375 __min__.height = 0;
00376
00377 __max__.height = 2050;
00378
00379 __default__.height = 0;
00380
00381 __param_descriptions__.push_back(ProsilicaCameraConfig::AbstractParamDescriptionConstPtr(new ProsilicaCameraConfig::ParamDescription<int>("height", "int", 0, "Height of the region of interest (0 for automatic).", "", &ProsilicaCameraConfig::height)));
00382
00383 __min__.frame_id = "";
00384
00385 __max__.frame_id = "";
00386
00387 __default__.frame_id = "";
00388
00389 __param_descriptions__.push_back(ProsilicaCameraConfig::AbstractParamDescriptionConstPtr(new ProsilicaCameraConfig::ParamDescription<std::string>("frame_id", "str", 0, "The optical camera TF frame set in message headers.", "", &ProsilicaCameraConfig::frame_id)));
00390
00391 __min__.trig_timestamp_topic = "";
00392
00393 __max__.trig_timestamp_topic = "";
00394
00395 __default__.trig_timestamp_topic = "";
00396
00397 __param_descriptions__.push_back(ProsilicaCameraConfig::AbstractParamDescriptionConstPtr(new ProsilicaCameraConfig::ParamDescription<std::string>("trig_timestamp_topic", "str", 1, "Sets the topic from which an externally trigged camera receives its trigger timestamps.", "", &ProsilicaCameraConfig::trig_timestamp_topic)));
00398
00399 __min__.trig_rate = 1.0;
00400
00401 __max__.trig_rate = 100.0;
00402
00403 __default__.trig_rate = 15.0;
00404
00405 __param_descriptions__.push_back(ProsilicaCameraConfig::AbstractParamDescriptionConstPtr(new ProsilicaCameraConfig::ParamDescription<double>("trig_rate", "double", 0, "Sets the expected triggering rate in externally triggered mode.", "", &ProsilicaCameraConfig::trig_rate)));
00406
00407
00408 for (std::vector<ProsilicaCameraConfig::AbstractParamDescriptionConstPtr>::const_iterator i = __param_descriptions__.begin(); i != __param_descriptions__.end(); i++)
00409 __description_message__.parameters.push_back(**i);
00410 __max__.__toMessage__(__description_message__.max, __param_descriptions__);
00411 __min__.__toMessage__(__description_message__.min, __param_descriptions__);
00412 __default__.__toMessage__(__description_message__.dflt, __param_descriptions__);
00413 }
00414 std::vector<ProsilicaCameraConfig::AbstractParamDescriptionConstPtr> __param_descriptions__;
00415 ProsilicaCameraConfig __max__;
00416 ProsilicaCameraConfig __min__;
00417 ProsilicaCameraConfig __default__;
00418 dynamic_reconfigure::ConfigDescription __description_message__;
00419 static const ProsilicaCameraConfigStatics *get_instance()
00420 {
00421
00422
00423
00424
00425 static ProsilicaCameraConfigStatics instance;
00426 return &instance;
00427 }
00428 };
00429
00430 inline const dynamic_reconfigure::ConfigDescription &ProsilicaCameraConfig::__getDescriptionMessage__()
00431 {
00432 return __get_statics__()->__description_message__;
00433 }
00434
00435 inline const ProsilicaCameraConfig &ProsilicaCameraConfig::__getDefault__()
00436 {
00437 return __get_statics__()->__default__;
00438 }
00439
00440 inline const ProsilicaCameraConfig &ProsilicaCameraConfig::__getMax__()
00441 {
00442 return __get_statics__()->__max__;
00443 }
00444
00445 inline const ProsilicaCameraConfig &ProsilicaCameraConfig::__getMin__()
00446 {
00447 return __get_statics__()->__min__;
00448 }
00449
00450 inline const std::vector<ProsilicaCameraConfig::AbstractParamDescriptionConstPtr> &ProsilicaCameraConfig::__getParamDescriptions__()
00451 {
00452 return __get_statics__()->__param_descriptions__;
00453 }
00454
00455 inline const ProsilicaCameraConfigStatics *ProsilicaCameraConfig::__get_statics__()
00456 {
00457 const static ProsilicaCameraConfigStatics *statics;
00458
00459 if (statics)
00460 return statics;
00461
00462 boost::mutex::scoped_lock lock(dynamic_reconfigure::__init_mutex__);
00463
00464 if (statics)
00465 return statics;
00466
00467 statics = ProsilicaCameraConfigStatics::get_instance();
00468
00469 return statics;
00470 }
00471
00472
00473 const char * const ProsilicaCamera_StreamingMode = "streaming";
00474
00475 const char * const ProsilicaCamera_PolledMode = "polled";
00476
00477 const char * const ProsilicaCamera_External1Mode = "syncin1";
00478
00479 const char * const ProsilicaCamera_External2Mode = "syncin2";
00480 }
00481
00482 #endif // __PROSILICACAMERARECONFIGURATOR_H__