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 CTuMicos_H 00030 #define CTuMicos_H 00031 00032 #include <mrpt/hwdrivers/CSerialPort.h> 00033 #include <mrpt/hwdrivers/CPtuBase.h> 00034 00035 namespace mrpt 00036 { 00037 namespace hwdrivers 00038 { 00039 /** This class implements initialization and comunication methods to 00040 * control a Tilt Unit model DT-80, working in radians . 00041 */ 00042 class HWDLLIMPEXP CTuMicos : public CPtuBase 00043 { 00044 00045 public: 00046 00047 /** Default constructor */ 00048 00049 CTuMicos() {}; 00050 00051 /** Destructor */ 00052 00053 virtual ~CTuMicos(){ close(); } 00054 00055 /*************************** Commands ***************************/ 00056 00057 public: 00058 00059 /** Specification of positions in absolute terms */ 00060 00061 bool moveToAbsPos(char axis,double nRad); 00062 00063 /** Query position in absolute terms */ 00064 00065 bool absPosQ(char axis,double &nRad); 00066 00067 /** Specify desired axis position as an offset from the current position. \n 00068 * This method recives the number of radians to move. 00069 * \code 00070 * Example of use: 00071 * TT-500 * 00072 * A * 00073 * TO * Current Tilt position is -500 00074 * TO500 * 00075 * A * 00076 * TT * Current Pan position is 1000 00077 * \endcode 00078 */ 00079 00080 bool moveToOffPos(char axis,double nRad); 00081 00082 /** Query position in relative terms */ 00083 00084 bool offPosQ(char axis,double &nRad); 00085 00086 /** Query max movement limit of a axis in absolute terms */ 00087 00088 bool maxPosQ(char axis,double &nRad); 00089 00090 /** Query min movement limit of a axis in absolute terms */ 00091 00092 bool minPosQ(char axis,double &nRad); 00093 00094 /** Query if exist movement limits */ 00095 00096 bool enableLimitsQ(bool &enable); // Query if exist some limit 00097 00098 /** Enable/Disable movement limits */ 00099 00100 bool enableLimits(bool set); 00101 00102 /** With I mode (default) instructs pan-tilt unit to immediately 00103 * execute positional commands. \n 00104 * In S mode instructs pan-tilt unit to execute positional commands 00105 * only when an Await Position Command Completion command is executed 00106 * or when put into Immediate Execution Mode. \n 00107 * \code 00108 * Example of use of S mode: 00109 * DR * 00110 * S * 00111 * PP1500 * 00112 * TP-900 * 00113 * PP * Current Pan position is 0 00114 * TP * Current Tilt position is 0 00115 * A * 00116 * PP * Current Pan position is 1500 00117 * TP * Current Tilt position is -900 00118 * \endcode 00119 */ 00120 00121 bool inmediateExecution(bool set); 00122 00123 /** Wait the finish of the last position command to 00124 * continue accept commands 00125 */ 00126 00127 bool aWait(void); 00128 00129 /** Inmediately stop all */ 00130 00131 bool haltAll(); 00132 00133 /** Inmediately stop */ 00134 00135 bool halt(char axis); 00136 00137 /** Specification of turn speed */ 00138 00139 bool speed(char axis,double radSec); 00140 00141 /** Query turn speed */ 00142 00143 bool speedQ(char axis,double &radSec); 00144 00145 /** Specification (de/a)celeration in turn */ 00146 00147 bool aceleration(char axis,double radSec2); 00148 00149 /** Query (de/a)celeration in turn */ 00150 00151 bool acelerationQ(char axis,double &radSec2); 00152 00153 /** Specification of velocity to which start and finish 00154 * the (de/a)celeration 00155 */ 00156 00157 bool baseSpeed(char axis,double radSec); 00158 00159 /** Query velocity to which start and finish 00160 * the (de/a)celeration 00161 */ 00162 00163 bool baseSpeedQ(char axis,double &radSec); 00164 00165 /** Specification of velocity upper limit */ 00166 00167 bool upperSpeed(char axis,double radSec); 00168 00169 /** Query velocity upper limit */ 00170 00171 bool upperSpeedQ(char axis,double &radSec); 00172 00173 /** Specification of velocity lower limit */ 00174 00175 bool lowerSpeed(char axis,double radSec); 00176 00177 /** Query velocity lower limit */ 00178 00179 bool lowerSpeedQ(char axis,double &radSec); 00180 00181 /** Reset PTU to initial state */ 00182 00183 bool reset(void); 00184 00185 /** Save or restart default values */ 00186 00187 bool save(void); 00188 00189 /** Restore default values */ 00190 00191 bool restoreDefaults(void); 00192 00193 /** Restore factory default values */ 00194 00195 bool restoreFactoryDefaults(void); 00196 00197 /** Version and CopyRights */ 00198 00199 bool version(char * nVersion); 00200 00201 /** Number of version */ 00202 00203 void nversion(double &nVersion); 00204 00205 /** Query power mode */ 00206 00207 bool powerModeQ(bool transit,char &mode); 00208 00209 /** Specification of power mode */ 00210 00211 bool powerMode(bool transit,char mode); 00212 00213 /** Clear controller internal stack */ 00214 00215 bool clear(); 00216 00217 /** Set limits of movement */ 00218 00219 bool setLimits(char axis, double &l, double &u); 00220 00221 /* Change motion direction */ 00222 00223 bool changeMotionDir(); 00224 00225 00226 /**************************** State Queries ********************/ 00227 00228 int checkErrors(); 00229 00230 /** Clear errors **/ 00231 00232 inline void clearErrors() { } 00233 00234 00235 /*************************** Other member methods *****************/ 00236 00237 public: 00238 00239 /** PTU and serial port initialization */ 00240 00241 bool init(const std::string port); 00242 00243 /** Close conection with serial port */ 00244 00245 void close(); 00246 00247 /** To obtains the mistake for use discrete values when the movement 00248 * is expressed in radians. Parameters are the absolute position in 00249 * radians and the axis desired 00250 */ 00251 00252 double radError(char axis,double nRadMoved); 00253 00254 /** To obtain the discrete value for a number of radians */ 00255 00256 long radToPos(char axis,double nRad); 00257 00258 /** To obtain the number of radians for a discrete value */ 00259 00260 double posToRad(char axis,long nPos); 00261 00262 /** Performs a scan in the axis indicated and whit the precision desired. \n 00263 * \param <axis> {Pan or Till} \n 00264 * \param <tWait> {Wait time betwen commands} \n 00265 * \param <initial> {initial position} 00266 * \param <final> {final position} 00267 * \param <radPre> {radians precision for the scan} 00268 */ 00269 00270 bool scan(char axis, int wait, float initial, float final, double radPre); 00271 00272 /** Query verbose mode */ 00273 00274 bool verboseQ(bool &modo); 00275 00276 /** Set verbose. \n 00277 * \conde 00278 * Example of response with FV (verbose) active: 00279 * FV * 00280 * PP * Current pan position is 0 00281 * Example of response with FT (terse) active: 00282 * FT * 00283 * PP * 0 00284 * \endcode 00285 */ 00286 00287 bool verbose(bool set); 00288 00289 /** Query echo mode */ 00290 00291 bool echoModeQ(bool &mode); 00292 00293 /** Enable/Disable echo response with command. \n 00294 * \code 00295 * Example of use (EE supposed): 00296 * PP * 22 00297 * ED * 00298 * <pp entered again, but not echoed>* 22 00299 * \endcode 00300 */ 00301 00302 bool echoMode(bool mode); 00303 00304 /** Query the pan and tilt resolution per position moved 00305 * and initialize local atributes 00306 */ 00307 00308 bool resolution(void); 00309 00310 /** Check if ptu is moving */ 00311 00312 double status(double &rad); 00313 00314 00315 /*************************** Methods for internal use ****************/ 00316 00317 private: 00318 00319 /** To transmition commands to the PTU */ 00320 00321 bool transmit(const char * command); 00322 00323 /** To receive the responseof the PTU */ 00324 00325 bool receive(const char * command,char * response); 00326 00327 /** Used to obtains a number of radians */ 00328 00329 bool radQuerry(char axis,char command,double &nRad); 00330 00331 /** Method used for asign a number of radians with a command */ 00332 00333 bool radAsign(char axis,char command,double nRad); 00334 00335 /** Convert string to double */ 00336 00337 double convertToDouble(char *sDouble); 00338 00339 /** Convert string to long */ 00340 00341 long convertToLong(char *sLong); 00342 00343 /**************************** Atributes ********************/ 00344 00345 public: 00346 00347 /* Index of the Tilt axis in use */ 00348 00349 int axis_index; 00350 00351 00352 }; // End of class 00353 00354 } // End of namespace 00355 00356 } // End of namespace 00357 00358 #endif
Page generated by Doxygen 1.5.7.1 for MRPT 0.7.1 SVN: at Mon Aug 17 23:02:22 EDT 2009 |