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://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 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                   * \ingroup mrpt_hwdrivers_grp
00077                 */
00078                 class HWDRIVERS_IMPEXP CBoardIR : public utils::CDebugOutputCapable, public CGenericSensor
00079                 {
00080                         DEFINE_GENERIC_SENSOR(CBoardIR)
00081 
00082                 public:
00083                         /** Constructor
00084                           * \param BUFFER_LENGTH The size of the communications buffer (default value should be fine always)
00085                           */
00086                         CBoardIR( int BUFFER_LENGTH = 13 );
00087 
00088                         /** Destructor
00089                           */
00090                         virtual ~CBoardIR();
00091 
00092                         /** This method tries to get a set of range measurements from the IR sensors.
00093                           * \param outObservation The output observation
00094                           * \param outThereIsObservation Will be true if an observation was sucessfully received.
00095                           * \param hardwareError Will be true if there's some important error, e.g. serial port can't be open.
00096                           */
00097                         void  getObservation(
00098                                 bool                                                    &outThereIsObservation,
00099                                 mrpt::slam::CObservationRange   &outObservation,
00100                                 bool                                                    &hardwareError );
00101 
00102                         /** This method should be called periodically (at least at 1Hz to capture ALL the real-time data)
00103                         *  It is thread safe, i.e. you can call this from one thread, then to other methods from other threads.
00104                         *  This method processes data from the GPS and update the object state accordingly.
00105                         */
00106                         void  doProcess();
00107 
00108                         void  setSerialPortName(const std::string &COM_port);   //!< Set the serial port to use (COM1, ttyUSB0, etc).
00109                         std::string getSerialPortName() const;                                  //!< Get the serial port to use (COM1, ttyUSB0, etc).
00110 
00111                 protected:
00112                         bool OnConnectionEstablished();
00113 
00114                         CSerialPort             m_COM;
00115 
00116                         poses::CPoint3D m_sensorPose;
00117 
00118                         std::string             m_customInit;
00119 
00120                         /** The minimum range in meters (10cm).
00121                           */
00122                         float                   m_minRange;
00123 
00124                         /** The maximum range in meters (80cm).
00125                           */
00126                         float                   m_maxRange;
00127 
00128                         /** The poses of the IR: x[m] y[m] z[m] yaw[deg] pitch[deg] roll[deg]
00129                           *  Up to 6 devices, but you can put any number of devices (from 1 to 6).
00130                           */
00131                         std::map<uint16_t,mrpt::math::TPose3D>  m_IRPoses;
00132 
00133                         /** 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)
00134                           *  See hwdrivers::CGPSInterface for the possible parameters
00135                           */
00136                         void  loadConfig_sensorSpecific(
00137                                 const mrpt::utils::CConfigFileBase &configSource,
00138                                 const std::string         &iniSection );
00139 
00140                 private:
00141                         std::string     m_COMname;
00142                         int                             m_COMbauds;
00143 
00144                         /** Returns true if the COM port is already open, or try to open it in other case.
00145                           * \return true if everything goes OK, or false if there are problems opening the port.
00146                           */
00147                         bool  tryToOpenTheCOM();
00148 
00149                 }; // end class
00150 
00151         } // end namespace
00152 } // end namespace
00153 
00154 #endif



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