MRPT  2.0.1
CNTRIPEmitter.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10 
11 #include <mrpt/comms/CSerialPort.h>
14 #include <mrpt/system/CTicTac.h>
15 #include <fstream>
16 
17 namespace mrpt::hwdrivers
18 {
19 /** This "virtual driver" encapsulates a NTRIP client (see CNTRIPClient) but
20  * adds the functionality of dumping the received datastream to a given serial
21  * port.
22  * Used within rawlog-grabber, along CGPSInterface, this class allows to build
23  * a powerful & simple RTK-capable GPS receiver system.
24  *
25  * Therefore, this sensor will never "collect" any observation via the
26  * CGenericSensor interface.
27  *
28  * See also the example configuration file for rawlog-grabber in
29  * "share/mrpt/config_files/rawlog-grabber".
30  *
31  * \code
32  * PARAMETERS IN THE ".INI"-LIKE CONFIGURATION STRINGS:
33  * -------------------------------------------------------
34  * [supplied_section_name]
35  * COM_port_WIN = COM1 // Serial port where the NTRIP stream will be
36  * dumped to.
37  * COM_port_LIN = ttyUSB0
38  * baudRate = 38400
39  * #transmit_to_server = true // (Default:true) Whether to send back to the
40  * TCP/IP caster all data received from the output serial port
41  * #raw_output_file_prefix = raw_ntrip_data // If provided, save raw data
42  * from the NTRIP to a file, useful for post-processing. In this case, not
43  * having a serial port configured (commented out) is a valid configuration.
44  *
45  * server = 143.123.9.129 // NTRIP caster IP
46  * port = 2101
47  * mountpoint = MYPOINT23
48  * //user = pepe // User & password optional.
49  * //password = loco
50  *
51  * \endcode
52  *
53  * The next picture summarizes existing MRPT classes related to GPS / GNSS
54  * devices (CGPSInterface, CNTRIPEmitter, CGPS_NTRIP):
55  *
56  * <div align=center> <img src="mrpt_gps_classes_usage.png"> </div>
57  *
58  * \ingroup mrpt_hwdrivers_grp
59  * \sa CGPSInterface, CGPS_NTRIP, CNTRIPClient
60  */
62 {
64 
65  private:
67 
68  /** The NTRIP comms object. */
70  /** The output serial port. */
72 
73  /** If set to non-empty, the serial port will be attempted to be opened
74  * automatically when this class is first used to request data from the
75  * laser. */
76  std::string m_com_port;
77  int m_com_bauds{38400};
80  std::ofstream m_raw_output_file_stream;
82  size_t m_rate_count{0};
83 
84  protected:
85  /** See the class documentation at the top for expected parameters */
87  const mrpt::config::CConfigFileBase& configSource,
88  const std::string& iniSection) override;
89 
90  public:
91  /** Constructor */
92  CNTRIPEmitter();
93 
94  /** Destructor */
95  ~CNTRIPEmitter() override;
96 
97  /** Changes the serial port to connect to (call prior to 'doProcess'), for
98  * example "COM1" or "ttyS0".
99  * This is not needed if the configuration is loaded with "loadConfig".
100  */
101  void setOutputSerialPort(const std::string& port) { m_com_port = port; }
102  std::string getOutputSerialPort() const { return m_com_port; }
103  void setRawOutputFilePrefix(const std::string& outfile)
104  {
106  }
107  std::string getRawOutputFilePrefix() const
108  {
110  }
111 
112  /** Set up the NTRIP communications, raising an exception on fatal errors.
113  * Called automatically by rawlog-grabber.
114  * If used manually, call after "loadConfig" and before "doProcess".
115  */
116  void initialize() override;
117 
118  /** The main loop, which must be called in a timely fashion in order to
119  * process the incomming NTRIP data stream and dump it to the serial port.
120  * This method is called automatically when used within rawlog-grabber.
121  */
122  void doProcess() override;
123 
124  /** Exposes the NTRIP client object */
126  /** Exposes the NTRIP client object */
127  const CNTRIPClient& getNTRIPClient() const { return m_client; }
128 }; // End of class
129 
130 } // namespace mrpt::hwdrivers
A generic interface for a wide-variety of sensors designed to be used in the application RawLogGrabbe...
void doProcess() override
The main loop, which must be called in a timely fashion in order to process the incomming NTRIP data ...
void initialize() override
Set up the NTRIP communications, raising an exception on fatal errors.
FILE * outfile
Definition: mrpt_jpeglib.h:910
A communications serial port built as an implementation of a utils::CStream.
Definition: CSerialPort.h:41
void setOutputSerialPort(const std::string &port)
Changes the serial port to connect to (call prior to &#39;doProcess&#39;), for example "COM1" or "ttyS0"...
std::string m_com_port
If set to non-empty, the serial port will be attempted to be opened automatically when this class is ...
Definition: CNTRIPEmitter.h:76
CNTRIPClient m_client
The NTRIP comms object.
Definition: CNTRIPEmitter.h:69
A high-performance stopwatch, with typical resolution of nanoseconds.
Contains classes for various device interfaces.
A client for NTRIP (HTTP) sources of differential GPS corrections from internet servers, or Global navigation satellite system (GNSS) internet radio.
Definition: CNTRIPClient.h:36
~CNTRIPEmitter() override
Destructor.
This class allows loading and storing values and vectors of different types from a configuration text...
void loadConfig_sensorSpecific(const mrpt::config::CConfigFileBase &configSource, const std::string &iniSection) override
See the class documentation at the top for expected parameters.
#define DEFINE_GENERIC_SENSOR(class_name)
This declaration must be inserted in all CGenericSensor classes definition, within the class declarat...
CNTRIPClient::NTRIPArgs m_ntrip_args
Definition: CNTRIPEmitter.h:66
std::ofstream m_raw_output_file_stream
Definition: CNTRIPEmitter.h:80
std::string getRawOutputFilePrefix() const
std::string getOutputSerialPort() const
mrpt::comms::CSerialPort m_out_COM
The output serial port.
Definition: CNTRIPEmitter.h:71
void setRawOutputFilePrefix(const std::string &outfile)
mrpt::system::CTicTac m_rate_timer
Definition: CNTRIPEmitter.h:81
This "virtual driver" encapsulates a NTRIP client (see CNTRIPClient) but adds the functionality of du...
Definition: CNTRIPEmitter.h:61
The arguments for connecting to a NTRIP stream, used in CNTRIPClient::open.
Definition: CNTRIPClient.h:79
CNTRIPClient & getNTRIPClient()
Exposes the NTRIP client object.
const CNTRIPClient & getNTRIPClient() const
Exposes the NTRIP client object.



Page generated by Doxygen 1.8.14 for MRPT 2.0.1 Git: 0fef1a6d7 Fri Apr 3 23:00:21 2020 +0200 at vie abr 3 23:20:28 CEST 2020