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



Page generated by Doxygen 1.7.5 for MRPT 0.9.5 SVN: at Thu Oct 13 21:25:36 UTC 2011