Main MRPT website > C++ reference
MRPT logo

CTuMicos.h

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



Page generated by Doxygen 1.7.3 for MRPT 0.9.4 SVN: at Sat Mar 26 06:40:17 UTC 2011