latest version v1.9 - last update 10 Apr 2010 |
00001 /* 00002 * Copyright (C) 2003, 2004, 2005, 2006 00003 * Lehrstuhl fuer Technische Informatik, RWTH-Aachen, Germany 00004 * 00005 * This file is part of the LTI-Computer Vision Library (LTI-Lib) 00006 * 00007 * The LTI-Lib is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public License (LGPL) 00009 * as published by the Free Software Foundation; either version 2.1 of 00010 * the License, or (at your option) any later version. 00011 * 00012 * The LTI-Lib is distributed in the hope that it will be 00013 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty 00014 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with the LTI-Lib; see the file LICENSE. If 00019 * not, write to the Free Software Foundation, Inc., 59 Temple Place - 00020 * Suite 330, Boston, MA 02111-1307, USA. 00021 */ 00022 00023 00024 /*-------------------------------------------------------------------- 00025 * project ....: LTI-Lib: Image Processing and Computer Vision Library 00026 * file .......: ltiPanTiltUnit.h 00027 * authors ....: Claudia Goenner, Christian Hein 00028 * organization: LTI, RWTH Aachen 00029 * creation ...: 28.8.2003 00030 * revisions ..: $Id: ltiPanTiltUnit.h,v 1.8 2006/02/07 19:58:46 ltilib Exp $ 00031 */ 00032 00033 #ifndef _LTI_PANTILTUNIT_H_ 00034 #define _LTI_PANTILTUNIT_H_ 00035 00036 #include "ltiFunctor.h" 00037 #include "ltiPoint.h" 00038 00039 namespace lti { 00040 /** 00041 * Parent class for all pan tilt units. 00042 * 00043 * Inherited classes should use the parameter \a angleFormat to 00044 * allow passing the pan and tilt values in either degrees or 00045 * radians. Please add all values (which can be set) as parameters 00046 * to allow construction with application specific settings. During 00047 * operation, value settings using a specific method is more efficient as 00048 * by setParameters. Pan tilt constants, e.g. the max. pan and 00049 * tilt, should be defined as constant static parameters. 00050 * 00051 * Please note that the camera may take a little while until a pan 00052 * or tilt position is reached. Thus the values in the parameters 00053 * and those returned by the get-methods may differ. 00054 * 00055 * The parameter functionality was reimplemented, following the 00056 * functor's concept, because of a problem with multiple 00057 * inheritance, which occures when deriving classed which are both a 00058 * camera and a panTiltUnit. 00059 */ 00060 class panTiltUnit : public virtual functor { 00061 public: 00062 /** 00063 * the parameters for the class panTiltUnit 00064 */ 00065 class parameters : public virtual functor::parameters { 00066 public: 00067 /** 00068 * default constructor 00069 */ 00070 parameters(); 00071 00072 /** 00073 * copy constructor 00074 * @param other the parameters object to be copied 00075 */ 00076 parameters(const parameters& other); 00077 00078 /** 00079 * constructor 00080 * @param minPan 00081 * @param maxPan 00082 * @param minTilt 00083 * @param maxTilt 00084 */ 00085 parameters(float minPan, float maxPan, float minTilt,float maxTilt); 00086 00087 /** 00088 * destructor 00089 */ 00090 ~parameters(); 00091 00092 /** 00093 * returns name of this type 00094 */ 00095 const char* getTypeName() const; 00096 00097 /** 00098 * copy the contents of a parameters object 00099 * @param other the parameters object to be copied 00100 * @return a reference to this parameters object 00101 */ 00102 parameters& copy(const parameters& other); 00103 00104 /** 00105 * copy the contents of a parameters object 00106 * @param other the parameters object to be copied 00107 * @return a reference to this parameters object 00108 */ 00109 parameters& operator=(const parameters& other); 00110 00111 00112 /** 00113 * returns a pointer to a clone of the parameters 00114 */ 00115 virtual functor::parameters* clone() const; 00116 00117 /** 00118 * write the parameters in the given ioHandler 00119 * @param handler the ioHandler to be used 00120 * @param complete if true (the default) the enclosing begin/end will 00121 * be also written, otherwise only the data block will be written. 00122 * @return true if write was successful 00123 */ 00124 virtual bool write(ioHandler& handler,const bool complete=true) const; 00125 00126 /** 00127 * read the parameters from the given ioHandler 00128 * @param handler the ioHandler to be used 00129 * @param complete if true (the default) the enclosing begin/end will 00130 * be also written, otherwise only the data block will be written. 00131 * @return true if write was successful 00132 */ 00133 virtual bool read(ioHandler& handler,const bool complete=true); 00134 00135 # ifdef _LTI_MSC_6 00136 /** 00137 * this function is required by MSVC only, as a workaround for a 00138 * very awful bug, which exists since MSVC V.4.0, and still by 00139 * V.6.0 with all bugfixes (so called "service packs") remains 00140 * there... This method is also public due to another bug, so please 00141 * NEVER EVER call this method directly: use read() instead 00142 */ 00143 bool readMS(ioHandler& handler,const bool complete=true); 00144 00145 /** 00146 * this function is required by MSVC only, as a workaround for a 00147 * very awful bug, which exists since MSVC V.4.0, and still by 00148 * V.6.0 with all bugfixes (so called "service packs") remains 00149 * there... This method is also public due to another bug, so please 00150 * NEVER EVER call this method directly: use write() instead 00151 */ 00152 bool writeMS(ioHandler& handler,const bool complete=true) const; 00153 # endif 00154 00155 // ------------------------------------------------ 00156 // the parameters 00157 // ------------------------------------------------ 00158 /** 00159 * angle formats 00160 */ 00161 enum eAngleFormatType {Degrees, Radiant}; 00162 00163 /** 00164 * Specifies if the pan and tilt values are measured in degrees or radiant. 00165 * Default: Radiant. 00166 */ 00167 eAngleFormatType angleFormat; 00168 00169 /** 00170 * Pan value to which the pan tilt device shall move. Default: 0. 00171 */ 00172 float pan; 00173 00174 /** 00175 * Tilt value to which the pan tilt device shall move. Default: 0. 00176 */ 00177 float tilt; 00178 00179 /** 00180 * Specifies whether the pan tilt device shall move to a relative (true) 00181 * or absolute Position (false). This is here to ensure a well defined 00182 * behavior. If a specific pan tilt device does not support the one or 00183 * the other, catch it in setParameters(). This way any application 00184 * can be informed about a relative or absolute movement. 00185 */ 00186 bool relativeMovement; 00187 00188 /** 00189 * The pan tilt unit can physically move between minPan and 00190 * maxPan. This values are always specified in radiants and 00191 * automatically converted by the getMinPan() / getMaxPan() method 00192 * if the angle format is set to degrees. 00193 */ 00194 const float minPan; 00195 00196 const float maxPan; 00197 00198 /** 00199 * The pan tilt unit can physically move between minTilt and 00200 * maxTilt. This values are always specified in radiants and 00201 * automatically converted by the getMinTilt() / getMaxTilt() method 00202 * if the angle format is set to degrees. 00203 */ 00204 00205 const float minTilt; 00206 00207 const float maxTilt; 00208 00209 }; 00210 00211 /** 00212 * default constructor 00213 */ 00214 panTiltUnit(); 00215 00216 /** 00217 * Construct a functor using the given parameters 00218 */ 00219 panTiltUnit(const parameters& par); 00220 00221 /** 00222 * copy constructor 00223 * @param other the object to be copied 00224 */ 00225 panTiltUnit(const panTiltUnit& other); 00226 00227 /** 00228 * destructor 00229 */ 00230 virtual ~panTiltUnit(); 00231 00232 /** 00233 * returns the name of this type ("panTiltUnit") 00234 */ 00235 virtual const char* getTypeName() const; 00236 00237 /** 00238 * copy data of "other" functor. 00239 * @param other the functor to be copied 00240 * @return a reference to this functor object 00241 */ 00242 panTiltUnit& copy(const panTiltUnit& other); 00243 00244 /** 00245 * alias for copy member 00246 * @param other the functor to be copied 00247 * @return a reference to this functor object 00248 */ 00249 panTiltUnit& operator=(const panTiltUnit& other); 00250 00251 /** 00252 * returns a pointer to a clone of this functor. 00253 */ 00254 virtual functor* clone() const = 0; 00255 00256 /** 00257 * returns used parameters 00258 */ 00259 const parameters& getParameters() const; 00260 00261 //---------------------- 00262 // pan tilt unit methods 00263 //---------------------- 00264 00265 /** 00266 * Reset the pan tilt device. 00267 * 00268 * This method resets internal pan and tilt registers. Some 00269 * devices need resets from time to time to avoid accumulation 00270 * errors. After succesfull execution the pan tilt unit should be 00271 * in the same position as before the call. During execution the 00272 * pan tilt unit may move. @return true on success 00273 */ 00274 virtual bool reset() = 0; 00275 00276 /** 00277 * stop the movement 00278 * @return true on success 00279 */ 00280 virtual bool stopPanTilt() = 0; 00281 00282 /** 00283 * set the pan and tilt position. Usually pan and tilt are sent to 00284 * the device in a single package. 00285 * @param pan the pan position the device will move to 00286 * @param tilt the pan position the device will move to 00287 * @return true on success 00288 */ 00289 virtual bool setPanTilt(float pan, float tilt) = 0; 00290 00291 /** 00292 * set the pan and tilt position. Usually pan and tilt are sent to 00293 * the device in a single package. 00294 * @param pos the pan tilt position the device will move to 00295 * @return true on success 00296 */ 00297 inline bool setPanTilt(const tpoint<float> &pos) { 00298 return setPanTilt(pos.x, pos.y); 00299 }; 00300 00301 /** 00302 * set the pan position 00303 * @param pan the pan position the device will move to 00304 * @return true on success 00305 */ 00306 virtual bool setPan(float pan) = 0; 00307 00308 /** 00309 * set the tilt position 00310 * @param tilt the pan position the device will move to 00311 * @return true on success 00312 */ 00313 virtual bool setTilt(float tilt) = 0; 00314 00315 /** 00316 * get the current pan and tilt position. The combined 00317 * get-methods guarantee pan and tilt positions of the 00318 * same time instant. 00319 * @param pan the pan position which the device is in 00320 * @param tilt the tilt position which the device is in 00321 * @return true on success 00322 */ 00323 virtual bool getPanTilt(float& pan, float& tilt) const = 0; 00324 00325 /** 00326 * get the current pan and tilt position. The combined 00327 * get-method guarantees pan and tilt positions of the 00328 * same time instant. 00329 * @return the current pan and tilt position 00330 */ 00331 inline tpoint<float> getPanTilt() const { 00332 tpoint<float> tmp; 00333 getPanTilt(tmp.x, tmp.y); 00334 return tmp; 00335 }; 00336 00337 /** 00338 * @return the current pan position 00339 */ 00340 virtual float getPan() const = 0; 00341 00342 /** 00343 * @return the current tilt position 00344 */ 00345 virtual float getTilt() const = 0; 00346 00347 /** 00348 * get the min. supported pan and tilt positions as specified by 00349 * angleFormat 00350 * 00351 * @param minPan the min. pan position 00352 * @param minTilt the min. tilt position 00353 * @return true on success 00354 */ 00355 virtual bool getMinPanTilt(float& minPan, float& minTilt) const; 00356 00357 /** 00358 * @return the min. supported pan and tilt positions as specified 00359 * by angleFormat 00360 */ 00361 inline tpoint<float> getMinPanTilt() const { 00362 tpoint<float> tmp; 00363 getMinPanTilt(tmp.x, tmp.y); 00364 return tmp; 00365 }; 00366 00367 /** 00368 * get the max. supported pan and tilt positions as specified by 00369 * angleFormat 00370 * 00371 * @param maxPan the max. pan position 00372 * @param maxTilt the max. tilt position 00373 * @return true on success 00374 */ 00375 virtual bool getMaxPanTilt(float& maxPan, float& maxTilt) const; 00376 00377 /** 00378 * @return the max. supported pan and tilt positions as specified 00379 * by angleFormat 00380 */ 00381 inline tpoint<float> getMaxPanTilt() const { 00382 tpoint<float> tmp; 00383 getMaxPanTilt(tmp.x, tmp.y); 00384 return tmp; 00385 }; 00386 00387 /** 00388 * @return the min. supported pan position as specified by angleFormat 00389 */ 00390 virtual float getMinPan() const; 00391 00392 /** 00393 * @return the max. supported pan position as specified by angleFormat 00394 */ 00395 virtual float getMaxPan() const; 00396 00397 /** 00398 * @return the min. supported tilt position as specified by angleFormat 00399 */ 00400 virtual float getMinTilt() const; 00401 00402 /** 00403 * @return the max. supported tilt position as specified by angleFormat 00404 */ 00405 virtual float getMaxTilt() const; 00406 00407 }; 00408 } 00409 00410 #endif