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