00001 /* +---------------------------------------------------------------------------+ 00002 | The Mobile Robot ProRadmming Toolkit (MRPT) C++ library | 00003 | | 00004 | http://mrpt.sourceforge.net/ | 00005 | | 00006 | Copyright (C) 2005-2009 University of Malaga | 00007 | | 00008 | This software was written by the Perception and Robotics | 00009 | research group, University of Malaga (Spain). | 00010 | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> | 00011 | | 00012 | This file is part of the MRPT project. | 00013 | | 00014 | MRPT is free software: you can redistribute it and/or modify | 00015 | it under the terms of the GNU General Public License as published by | 00016 | the Free Software Foundation, either version 3 of the License, or | 00017 | (at your option) any later version. | 00018 | | 00019 | MRPT is distributed in the hope that it will be useful, | 00020 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 00021 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 00022 | GNU General Public License for more details. | 00023 | | 00024 | You should have received a copy of the GNU General Public License | 00025 | along with MRPT. If not, see <http://www.gnu.org/licenses/>. | 00026 | | 00027 +---------------------------------------------------------------------------+ */ 00028 00029 #ifndef CPtuBase_H 00030 #define CPtuBase_H 00031 00032 #include <mrpt/hwdrivers/CSerialPort.h> 00033 00034 namespace mrpt 00035 { 00036 namespace hwdrivers 00037 { 00038 /** This class implements initialization and comunication methods to 00039 * control a generic Pan and Tilt Unit, working in radians. 00040 */ 00041 class HWDLLIMPEXP CPtuBase 00042 { 00043 00044 /*************************** Atributes **********************/ 00045 00046 public: 00047 00048 double tiltResolution,panResolution; 00049 00050 protected: 00051 00052 CSerialPort *serPort; 00053 00054 /**************************** Methods ***********************/ 00055 00056 public: 00057 00058 /** Default constructor */ 00059 00060 CPtuBase() {}; 00061 00062 /** Destructor */ 00063 00064 virtual ~CPtuBase() {}; 00065 00066 /** Specification of positions in absolute terms */ 00067 00068 virtual bool moveToAbsPos(char axis,double nRad)=0; 00069 00070 /** Query position in absolute terms */ 00071 00072 virtual bool absPosQ(char axis,double &nRad)=0; 00073 00074 /** Specify desired axis position as an offset from the current position. \n 00075 * This method recives the number of radians to move. 00076 * \code 00077 * Example of use: 00078 * TT-500 * 00079 * A * 00080 * TO * Current Tilt position is -500 00081 * TO500 * 00082 * A * 00083 * TT * Current Pan position is 1000 00084 * \endcode 00085 */ 00086 00087 virtual bool moveToOffPos(char axis,double nRad)=0; 00088 00089 /** Query position in relative terms */ 00090 00091 virtual bool offPosQ(char axis,double &nRad)=0; 00092 00093 /** Query max movement limit of a axis in absolute terms */ 00094 00095 virtual bool maxPosQ(char axis,double &nRad)=0; 00096 00097 /** Query min movement limit of a axis in absolute terms */ 00098 00099 virtual bool minPosQ(char axis,double &nRad)=0; 00100 00101 /** Query if exist movement limits */ 00102 00103 virtual bool enableLimitsQ(bool &enable)=0; // Query if exist some limit 00104 00105 /** Enable/Disable movement limits */ 00106 00107 virtual bool enableLimits(bool set)=0; 00108 00109 /** With I mode (default) instructs pan-tilt unit to immediately 00110 * execute positional commands. \n 00111 * In S mode instructs pan-tilt unit to execute positional commands 00112 * only when an Await Position Command Completion command is executed 00113 * or when put into Immediate Execution Mode. \n 00114 * \code 00115 * Example of use of S mode: 00116 * DR * 00117 * S * 00118 * PP1500 * 00119 * TP-900 * 00120 * PP * Current Pan position is 0 00121 * TP * Current Tilt position is 0 00122 * A * 00123 * PP * Current Pan position is 1500 00124 * TP * Current Tilt position is -900 00125 * \endcode 00126 */ 00127 00128 virtual bool inmediateExecution(bool set)=0; 00129 00130 /** Wait the finish of the last position command to 00131 * continue accept commands 00132 */ 00133 00134 virtual bool aWait(void)=0; 00135 00136 /** Inmediately stop all */ 00137 00138 virtual bool haltAll()=0; 00139 00140 /** Inmediately stop */ 00141 00142 virtual bool halt(char axis)=0; 00143 00144 /** Specification of turn speed */ 00145 00146 virtual bool speed(char axis,double RadSec)=0; 00147 00148 /** Query turn speed */ 00149 00150 virtual bool speedQ(char axis,double &RadSec)=0; 00151 00152 /** Specification (de/a)celeration in turn */ 00153 00154 virtual bool aceleration(char axis,double RadSec2)=0; 00155 00156 /** Query (de/a)celeration in turn */ 00157 00158 virtual bool acelerationQ(char axis,double &RadSec2)=0; 00159 00160 /** Specification of velocity to which start and finish 00161 * the (de/a)celeration 00162 */ 00163 00164 virtual bool baseSpeed(char axis,double RadSec)=0; 00165 00166 /** Query velocity to which start and finish 00167 * the (de/a)celeration 00168 */ 00169 00170 virtual bool baseSpeedQ(char axis,double &RadSec)=0; 00171 00172 /** Specification of velocity upper limit */ 00173 00174 virtual bool upperSpeed(char axis,double RadSec)=0; 00175 00176 /** Query velocity upper limit */ 00177 00178 virtual bool upperSpeedQ(char axis,double &RadSec)=0; 00179 00180 /** Specification of velocity lower limit */ 00181 00182 virtual bool lowerSpeed(char axis,double RadSec)=0; 00183 00184 /** Query velocity lower limit */ 00185 00186 virtual bool lowerSpeedQ(char axis,double &RadSec)=0; 00187 00188 /** Reset PTU to initial state */ 00189 00190 virtual bool reset(void)=0; 00191 00192 /** Save or restart default values */ 00193 00194 virtual bool save(void)=0; 00195 00196 /** Restore default values */ 00197 00198 virtual bool restoreDefaults(void)=0; 00199 00200 /** Restore factory default values */ 00201 00202 virtual bool restoreFactoryDefaults(void)=0; 00203 00204 /** Version and CopyRights */ 00205 00206 virtual bool version(char * nVersion)=0; 00207 00208 /** Number of version */ 00209 00210 virtual void nversion(double &nVersion)=0; 00211 00212 /** Query power mode */ 00213 00214 virtual bool powerModeQ(bool transit,char &mode)=0; 00215 00216 /** Specification of power mode */ 00217 00218 virtual bool powerMode(bool transit,char mode)=0; 00219 00220 /** Check if ptu is moving */ 00221 00222 virtual double status(double &rad)=0; 00223 00224 /** Set limits of movement */ 00225 00226 virtual bool setLimits(char axis, double &l, double &u)=0; 00227 00228 /* Change motion direction */ 00229 00230 virtual bool changeMotionDir()=0; 00231 00232 00233 /**************************** State Queries ********************/ 00234 00235 /** Check errors, returns 0 if there are not errors or error code otherwise **/ 00236 00237 virtual int checkErrors()=0; 00238 00239 /** Clear errors **/ 00240 00241 virtual void clearErrors()=0; 00242 00243 00244 /*************************** Other member methods *****************/ 00245 00246 /** PTU and serial port initialization */ 00247 00248 virtual bool init(const std::string port)=0; 00249 00250 /** Close conection with serial port */ 00251 00252 virtual void close()=0; 00253 00254 /** To obtains the mistake for use discrete values when the movement 00255 * is expressed in radians. Parameters are the absolute position in 00256 * radians and the axis desired 00257 */ 00258 00259 virtual double radError(char axis,double nRadMoved)=0; 00260 00261 /** To obtain the discrete value for a number of radians */ 00262 00263 virtual long radToPos(char axis,double nRad)=0; 00264 00265 /** To obtain the number of radians for a discrete value */ 00266 00267 virtual double posToRad(char axis,long nPos)=0; 00268 00269 /** Performs a scan in the axis indicated and whit the precision desired. 00270 * \param <axis> {Pan or Till} 00271 * \param <tWait> {Wait time betwen commands} 00272 * \param <initial> {initial position} 00273 * \param <final> {final position} 00274 * \param <RadPre> {radians precision for the scan} 00275 */ 00276 00277 virtual bool scan(char axis, int wait, float initial, float final, double RadPre)=0; 00278 00279 /** Query verbose mode */ 00280 00281 virtual bool verboseQ(bool &modo)=0; 00282 00283 /** Set verbose. \n 00284 * \conde 00285 * Example of response with FV (verbose) active: 00286 * FV * 00287 * PP * Current pan position is 0 00288 * Example of response with FT (terse) active: 00289 * FT * 00290 * PP * 0 00291 * \endcode 00292 */ 00293 00294 virtual bool verbose(bool set)=0; 00295 00296 /** Query echo mode */ 00297 00298 virtual bool echoModeQ(bool &mode)=0; 00299 00300 /** Enable/Disable echo response with command. \n 00301 * \code 00302 * Example of use (EE supposed): 00303 * PP * 22 00304 * ED * 00305 * <pp entered again, but not echoed>* 22 00306 * \endcode 00307 */ 00308 00309 virtual bool echoMode(bool mode)=0; 00310 00311 /** Query the pan and tilt resolution per position moved 00312 * and initialize local atributes 00313 */ 00314 00315 virtual bool resolution(void)=0; 00316 00317 00318 /*************************** Methods for internal use ****************/ 00319 00320 private: 00321 00322 /** To transmition commands to the PTU */ 00323 00324 virtual bool transmit(const char * command)=0; 00325 00326 /** To receive the responseof the PTU */ 00327 00328 virtual bool receive(const char * command,char * response)=0; 00329 00330 /** Used to obtains a number of radians */ 00331 00332 virtual bool radQuerry(char axis,char command,double &nRad)=0; 00333 00334 /** Method used for asign a number of radians with a command */ 00335 00336 virtual bool radAsign(char axis,char command,double nRad)=0; 00337 00338 00339 }; // End of class 00340 00341 } // End of namespace 00342 00343 } // End of namespace 00344 00345 #endif
Page generated by Doxygen 1.5.7.1 for MRPT 0.7.1 SVN: at Mon Aug 17 22:58:25 EDT 2009 |