ntrip, testMode, zed9 gnss modul

This commit is contained in:
2022-09-13 20:31:52 +02:00
parent c7cb0d3895
commit af6cb98898
43 changed files with 907 additions and 262 deletions
+63 -3
View File
@@ -20,11 +20,14 @@ Navigation::Navigation(Route* route) {
uint8_t versionHigh = this->gps->getProtocolVersionHigh();
uint8_t versionLow = this->gps->getProtocolVersionLow();
std::cout << "Neo-M8Q protocol version: " << unsigned(versionHigh) << "." << unsigned(versionLow) << std::endl;
std::cout << "u-blox protocol version: " << unsigned(versionHigh) << "." << unsigned(versionLow) << std::endl;
this->gps->setI2COutput(COM_TYPE_UBX);
this->gps->setUSBOutput(COM_TYPE_UBX | COM_TYPE_NMEA);
this->gps->setPortInput(COM_PORT_I2C, COM_TYPE_UBX | COM_TYPE_NMEA | COM_TYPE_RTCM3);
this->gps->getNavigationFrequency(1);
if (route)
this->route = route;
@@ -34,13 +37,70 @@ Navigation::Navigation(Route* route) {
Navigation::~Navigation() {
delete this->gps;
if (this->isNtripInit) {
delete this->ntripClient;
delete this->host;
delete this->mountPoint;
delete this->user;
delete this->password;
}
if (this->route)
delete this->route;
}
void Navigation::initNtrip(String host, uint16_t port, String mountPoint, String user, String password) {
this->host = new char[host.length() + 1];
this->mountPoint = new char[mountPoint.length() + 1];
this->user = new char[user.length() + 1];
this->password = new char[password.length() + 1];
strcpy(this->host, host.c_str());
strcpy(this->mountPoint, mountPoint.c_str());
strcpy(this->user, user.c_str());
strcpy(this->password, password.c_str());
this->port = port;
this->ntripClient = new NTRIPClient;
this->isNtripInit = true;
std::cout << "Requesting SourceTable." << std::endl;
if(this->ntripClient->reqSrcTbl(this->host, (int) this->port)){
char buffer[512];
delay(5);
while(this->ntripClient->available()) {
this->ntripClient->readLine(buffer,sizeof(buffer));
std::cout << buffer << std::endl;
}
} else {
std::cout << "SourceTable request error" << std::endl;
}
std::cout << "Requesting SourceTable is OK" << std::endl;
this->ntripClient->stop(); //Need to call "stop" function for next request.
std::cout << "Requesting MountPoint's Raw data" << std::endl;
if(!this->ntripClient->reqRaw(this->host, this->port, this->mountPoint,
this->user, this->password)){
delay(15000);
ESP.restart();
}
std::cout << "Requesting MountPoint is OK" << std::endl;
}
void Navigation::loop() {
//FIXME: Hier sollte funktion zum aktualisieren des GPS Moduls stehen
//this->gps->checkUbloxI2C();
if (millis() - this->lastMillis < this->timeToWait)
return;
uint8_t rtcmData[512 * 4];
uint16_t rtcmCount = this->ntripClient->available();
if (rtcmCount) {
this->ntripClient->readBytes(rtcmData, rtcmCount);
this->gps->pushRawData(rtcmData, rtcmCount);
}
}
void Navigation::newRoute() {
+23
View File
@@ -19,6 +19,7 @@
#include "route.h"
#include "navigationUtils.h"
#include "NTRIPClient.h"
/**
* @brief The minimal distance between Points
@@ -64,6 +65,17 @@ class Navigation {
*/
~Navigation();
/**
* @brief
*
* @param host
* @param port
* @param mountPoint
* @param user
* @param password
*/
void initNtrip(String host, uint16_t port, String mountPoint, String user, String password);
/**
* @brief Decodes new GPS information
*
@@ -169,12 +181,23 @@ class Navigation {
SFE_UBLOX_GNSS* gps;
Route* route = nullptr;
NTRIPClient* ntripClient = nullptr;
Point lastPoint;
Point targetPoint;
bool navigationStarted = false;
bool navigationFinished = false;
bool isNtripInit = false;
char* host;
char* mountPoint;
char* user;
char* password;
uint8_t timeToWait = 5;
uint16_t port;
uint32_t lastMillis = 0;
};
#endif // NAVIGATION_H