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



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