| 1 |
/* +------------------------------------------------------------------------+ |
| 2 |
| Mobile Robot Programming Toolkit (MRPT) | |
| 3 |
| https://www.mrpt.org/ | |
| 4 |
| | |
| 5 |
| Copyright (c) 2005-2026, 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 |
|
| 10 |
#include "hwdrivers-precomp.h" // Precompiled headers |
| 11 |
// |
| 12 |
#include <mrpt/config/CConfigFilePrefixer.h> |
| 13 |
#include <mrpt/hwdrivers/CGPS_NTRIP.h> |
| 14 |
|
| 15 |
#include <iostream> |
| 16 |
|
| 17 |
using namespace mrpt::hwdrivers; |
| 18 |
using namespace mrpt::obs; |
| 19 |
using namespace mrpt::system; |
| 20 |
using namespace std; |
| 21 |
|
| 22 |
IMPLEMENTS_GENERIC_SENSOR(CGPS_NTRIP, mrpt::hwdrivers) |
| 23 |
|
| 24 |
/** Constructor. See mrpt::hwdrivers::CGPSInterface for the meaning of params. |
| 25 |
*/ |
| 26 |
CGPS_NTRIP::CGPS_NTRIP() : gps(), ntrip() {} |
| 27 |
/** Destructor */ |
| 28 |
CGPS_NTRIP::~CGPS_NTRIP() = default; |
| 29 |
void CGPS_NTRIP::initialize() |
| 30 |
{ |
| 31 |
gps.initialize(); |
| 32 |
ntrip.initialize(); |
| 33 |
} |
| 34 |
|
| 35 |
// See docs in parent class |
| 36 |
void CGPS_NTRIP::doProcess() |
| 37 |
{ |
| 38 |
// Process GPS: |
| 39 |
gps.doProcess(); |
| 40 |
|
| 41 |
// Move sensed observations to this object: |
| 42 |
{ |
| 43 |
const TListObservations lst = gps.getObservations(); |
| 44 |
|
| 45 |
std::vector<mrpt::serialization::CSerializable::Ptr> vect; |
| 46 |
vect.reserve(lst.size()); |
| 47 |
for (const auto& kv : lst) vect.push_back(kv.second); |
| 48 |
this->appendObservations(vect); |
| 49 |
} |
| 50 |
|
| 51 |
// New GGA frames? |
| 52 |
std::string sLastGGA = gps.getLastGGA(); |
| 53 |
if (!sLastGGA.empty()) |
| 54 |
{ |
| 55 |
if (m_verbose) |
| 56 |
cout << "[CGPS_NTRIP] Redirecting GGA frame from GPS->NTRIP: '" << sLastGGA << "'" << endl; |
| 57 |
|
| 58 |
ntrip.getNTRIPClient().sendBackToServer(sLastGGA + std::string("\r\n")); |
| 59 |
} |
| 60 |
|
| 61 |
// Process NTRIP server comms: |
| 62 |
ntrip.doProcess(); |
| 63 |
} |
| 64 |
|
| 65 |
void CGPS_NTRIP::loadConfig_sensorSpecific( |
| 66 |
const mrpt::config::CConfigFileBase& cfg, const std::string& section) |
| 67 |
{ |
| 68 |
// Load GPS params: |
| 69 |
gps.loadConfig(mrpt::config::CConfigFilePrefixer(cfg, "", "gps_"), section); |
| 70 |
// NTRIP params: |
| 71 |
ntrip.loadConfig(mrpt::config::CConfigFilePrefixer(cfg, "", "ntrip_"), section); |
| 72 |
|
| 73 |
// Own params: |
| 74 |
// (none yet) |
| 75 |
} |