Main MRPT website > C++ reference
MRPT logo

CBoardIR.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 CBoardIR_H
00030 #define CBoardIR_H
00031 
00032 #include <mrpt/slam/CObservationRange.h>
00033 #include <mrpt/poses/CPoint3D.h>
00034 #include <mrpt/hwdrivers/CSerialPort.h>
00035 #include <mrpt/utils/CDebugOutputCapable.h>
00036 #include <mrpt/hwdrivers/CGenericSensor.h>
00037 
00038 namespace mrpt
00039 {
00040         namespace slam { class CObservationGPS; }
00041 
00042         namespace hwdrivers
00043         {
00044                 /** A parser of NMEA commands, for connecting to a GPS by a serial port.
00045                   * This class also supports more advanced GPS equipped with RTK corrections. See the JAVAD/TopCon extra initialization parameters.
00046                   *
00047                   *  \code
00048                   *  PARAMETERS IN THE ".INI"-LIKE CONFIGURATION STRINGS:
00049                   * -------------------------------------------------------
00050                   *   [supplied_section_name]
00051                   *    COM_port_WIN = COM3
00052                   *    COM_port_LIN = ttyS0
00053                   *    baudRate     = 4800   // The baudrate of the communications (typ. 4800 bauds)
00054                   *    pose_x       = 0      // 3D position of the sensed point relative to the robot (meters)
00055                   *    pose_y       = 0
00056                   *    pose_z       = 0
00057                   *    customInit   =       // See below for possible values
00058                   *
00059                   *        // The next parameters are optional and will be used only
00060                   *    // if customInit=="JAVAD" to enable/configure the usage of RTK corrections:
00061                   *    //JAVAD_rtk_src_port=/dev/ser/b
00062                   *    //JAVAD_rtk_src_baud=9600
00063                   *    //JAVAD_rtk_format=cmr
00064                   *
00065                   *  \endcode
00066                   *
00067                   * - customInit: Custom commands to send, depending on the sensor. Valid values are:
00068                   *             - "": Empty string
00069                   *             - "JAVAD": JAVAD or TopCon devices. Extra initialization commands will be sent.
00070                   *             - "TopCon": A synonymous with "JAVAD".
00071                   *
00072                   *  VERSIONS HISTORY:
00073                   *             -9/JUN/2006: First version (JLBC)
00074                   *             -4/JUN/2008: Added virtual methods for device-specific initialization commands.
00075                   *             -10/JUN/2008: Converted into CGenericSensor class (there are no inhirited classes anymore).
00076                 */
00077                 class HWDRIVERS_IMPEXP CBoardIR : public utils::CDebugOutputCapable, public CGenericSensor
00078                 {
00079                         DEFINE_GENERIC_SENSOR(CBoardIR)
00080 
00081                 public:
00082                         /** Constructor
00083                           * \param BUFFER_LENGTH The size of the communications buffer (default value should be fine always)
00084                           */
00085                         CBoardIR( int BUFFER_LENGTH = 13 );
00086 
00087                         /** Destructor
00088                           */
00089                         virtual ~CBoardIR();
00090 
00091                         /** This method tries to get a set of range measurements from the IR sensors.
00092                           * \param outObservation The output observation
00093                           * \param outThereIsObservation Will be true if an observation was sucessfully received.
00094                           * \param hardwareError Will be true if there's some important error, e.g. serial port can't be open.
00095                           */
00096                         void  getObservation(
00097                                 bool                                                    &outThereIsObservation,
00098                                 mrpt::slam::CObservationRange   &outObservation,
00099                                 bool                                                    &hardwareError );
00100 
00101                         /** This method should be called periodically (at least at 1Hz to capture ALL the real-time data)
00102                         *  It is thread safe, i.e. you can call this from one thread, then to other methods from other threads.
00103                         *  This method processes data from the GPS and update the object state accordingly.
00104                         */
00105                         void  doProcess();
00106 
00107                         void  setSerialPortName(const std::string &COM_port);   //!< Set the serial port to use (COM1, ttyUSB0, etc).
00108                         std::string getSerialPortName() const;                                  //!< Get the serial port to use (COM1, ttyUSB0, etc).
00109 
00110                 protected:
00111                         bool OnConnectionEstablished();
00112 
00113                         CSerialPort             m_COM;
00114 
00115                         poses::CPoint3D m_sensorPose;
00116 
00117                         std::string             m_customInit;
00118 
00119                         /** The minimum range in meters (10cm).
00120                           */
00121                         float                   m_minRange;
00122 
00123                         /** The maximum range in meters (80cm).
00124                           */
00125                         float                   m_maxRange;
00126 
00127                         /** The poses of the IR: x[m] y[m] z[m] yaw[deg] pitch[deg] roll[deg]
00128                           *  Up to 6 devices, but you can put any number of devices (from 1 to 6).
00129                           */
00130                         std::map<uint16_t,mrpt::math::TPose3D>  m_IRPoses;
00131 
00132                         /** Loads specific configuration for the device from a given source of configuration parameters, for example, an ".ini" file, loading from the section "[iniSection]" (see utils::CConfigFileBase and derived classes)
00133                           *  See hwdrivers::CGPSInterface for the possible parameters
00134                           */
00135                         void  loadConfig_sensorSpecific(
00136                                 const mrpt::utils::CConfigFileBase &configSource,
00137                                 const std::string         &iniSection );
00138 
00139                 private:
00140                         std::string     m_COMname;
00141                         int                             m_COMbauds;
00142 
00143                         /** Returns true if the COM port is already open, or try to open it in other case.
00144                           * \return true if everything goes OK, or false if there are problems opening the port.
00145                           */
00146                         bool  tryToOpenTheCOM();
00147 
00148                 }; // end class
00149 
00150         } // end namespace
00151 } // end namespace
00152 
00153 #endif



Page generated by Doxygen 1.7.3 for MRPT 0.9.4 SVN:exported at Tue Jan 25 21:56:31 UTC 2011