Main MRPT website > C++ reference
MRPT logo

CNTRIPEmitter.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 #ifndef CNTRIPEmitter_H
00029 #define CNTRIPEmitter_H
00030 
00031 #include <mrpt/hwdrivers/CNTRIPClient.h>
00032 #include <mrpt/hwdrivers/CSerialPort.h>
00033 #include <mrpt/hwdrivers/CGenericSensor.h>
00034 
00035 namespace mrpt
00036 {
00037         namespace hwdrivers
00038         {
00039                 /** This "virtual driver" encapsulates a NTRIP client (see CNTRIPClient) but adds the functionality of dumping the received datastream to a given serial port.
00040                   *  Used within rawlog-grabber, along CGPSInterface, this class allows to build a powerful & simple RTK-capable GPS receiver system.
00041                   *
00042                   *  Therefore, this sensor will never "collect" any observation via the CGenericSensor interface.
00043                   *
00044                   *   See also the example configuration file for rawlog-grabber in "share/mrpt/config_files/rawlog-grabber".
00045                   *
00046                   *  \code
00047                   *  PARAMETERS IN THE ".INI"-LIKE CONFIGURATION STRINGS:
00048                   * -------------------------------------------------------
00049                   *   [supplied_section_name]
00050                   *   COM_port_WIN = COM1         // Serial port where the NTRIP stream will be dumped to.
00051                   *   COM_port_LIN = ttyUSB0
00052                   *   baudRate     = 38400   
00053                   *
00054                   *   server   = 143.123.9.129    // NTRIP caster IP
00055                   *   port     = 2101
00056                   *   mountpoint = MYPOINT23
00057                   *   //user = pepe            // User & password optional.
00058                   *   //password = loco
00059                   *
00060                   *  \endcode
00061                   *
00062                   * \sa CGPSInterface, CNTRIPClient
00063                   */
00064                 class HWDRIVERS_IMPEXP CNTRIPEmitter : public CGenericSensor
00065                 {
00066                         DEFINE_GENERIC_SENSOR(CNTRIPEmitter)
00067 
00068                 private:
00069                         CNTRIPClient::NTRIPArgs m_ntrip_args;
00070 
00071                         CNTRIPClient    m_client;  //!< The NTRIP comms object.
00072                         CSerialPort             m_out_COM; //!< The output serial port.
00073 
00074                         std::string             m_com_port;             //!< If set to non-empty, the serial port will be attempted to be opened automatically when this class is first used to request data from the laser.
00075                         int                             m_com_bauds;
00076 
00077                 protected:
00078                         /** 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)
00079                           *  See hwdrivers::CNTRIPEmitter for the possible parameters
00080                           */
00081                         void  loadConfig_sensorSpecific(
00082                                 const mrpt::utils::CConfigFileBase &configSource,
00083                                 const std::string         &iniSection );
00084 
00085                 public:
00086                         /** Constructor  */
00087                         CNTRIPEmitter();
00088 
00089                         /** Destructor  */
00090                         virtual ~CNTRIPEmitter();
00091 
00092                         /** Changes the serial port to connect to (call prior to 'doProcess'), for example "COM1" or "ttyS0".
00093                           *  This is not needed if the configuration is loaded with "loadConfig".
00094                           */
00095                         void  setOutputSerialPort(const std::string &port) { m_com_port = port; }
00096 
00097                         /** Set up the NTRIP communications, raising an exception on fatal errors.
00098                           *  Called automatically by rawlog-grabber.
00099                           *  If used manually, call after "loadConfig" and before "doProcess".
00100                           */
00101                         void initialize();
00102 
00103                         /** The main loop, which must be called in a timely fashion in order to process the incomming NTRIP data stream and dump it to the serial port.
00104                           *  This method is called automatically when used within rawlog-grabber.
00105                           */
00106                         void doProcess(); 
00107 
00108                 };      // End of class
00109 
00110         } // End of namespace
00111 } // End of namespace
00112 
00113 #endif



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