ntripClient runs now - gnss to spi

This commit is contained in:
2022-11-29 20:38:46 +01:00
parent e36b6475b8
commit 599f176622
12 changed files with 125 additions and 31 deletions
+4 -4
View File
@@ -10,11 +10,11 @@ INTL1 32 GND GND
INTL2 33 19 SCL SCL INTL2 33 19 SCL SCL
INTB1 25 18 VCC INTB1 25 18 VCC
INTB2 26 5 INTB2 26 5
DirL1 27 17 GPS RX deprecated DirL1 27 17 SPI_CS
DirR2 14 16 GPS TX deprecated DirR2 14 16 SPI_COPI
DirL2 12 4 SD-Card DirL2 12 4 SPI_CIPO
GND x GND x
PWML 13 2 SD-Card PWML 13 2 SPI_SCK
x 15 WS2812 LED ? x 15 WS2812 LED ?
x x x x
CMD x CMD x
+4
View File
@@ -15,3 +15,7 @@
* The PS3-Controller only connects to the address which is saved in it. * The PS3-Controller only connects to the address which is saved in it.
*/ */
#define CONTROLLER_MAC "24:62:AB:F2:4B:3A" #define CONTROLLER_MAC "24:62:AB:F2:4B:3A"
#define UBLOX_GNSS_SPI_CS 17
#define UBLOX_GNSS_SPI_COPI 16
#define UBLOX_GNSS_SPI_CIPO 4
#define UBLOX_GNSS_SPI_SCK 2
+11 -1
View File
@@ -31,7 +31,7 @@
#define WLAN_CONNECT_LOOP_TIME 500 #define WLAN_CONNECT_LOOP_TIME 500
#define WLAN_DNS_SERVER "8.8.8.8" #define WLAN_DNS_SERVER "8.8.8.8"
#define NTRIP_NS #define NTRIP_RTK2GO
// NTRIP config NRW // NTRIP config NRW
#ifdef NTRIP_NRW #ifdef NTRIP_NRW
@@ -51,6 +51,16 @@
#define NTRIP_PASSWORD "ALdx-1-3e49" #define NTRIP_PASSWORD "ALdx-1-3e49"
#endif // NTRIP_NS #endif // NTRIP_NS
// NTRIP config RTK2Go
#ifdef NTRIP_RTK2GO
#define NTRIP_HOST "rtk2go.com"
#define NTRIP_PORT 2101
#define NTRIP_MOUNT_POINT "Blijham"
#define NTRIP_USER "alex17813@gmail.com"
#define NTRIP_PASSWORD "none"
#endif // NTRIP_RTK2GO
#define RHEDE #define RHEDE
//Network config ESP32 //Network config ESP32
+13 -1
View File
@@ -17,7 +17,19 @@ Navigation::Navigation(Route* route) {
std::cout << "u-blox GNSS not detected at default I2C address. Please check wiring. Freezing." << std::endl; std::cout << "u-blox GNSS not detected at default I2C address. Please check wiring. Freezing." << std::endl;
while (1); while (1);
} }
this->init(route);
}
Navigation::Navigation(SPIClass spiPort, uint8_t csPin, Route* route) {
this->gps = new SFE_UBLOX_GNSS();
if (this->gps->begin(spiPort, csPin, 4000000) == false) {
std::cout << "u-blox GNSS not detected on SPI bus. Please check wiring. Freezing." << std::endl;
while (1);
}
this->init(route);
}
void Navigation::init(Route* route) {
uint8_t versionHigh = this->gps->getProtocolVersionHigh(); uint8_t versionHigh = this->gps->getProtocolVersionHigh();
uint8_t versionLow = this->gps->getProtocolVersionLow(); uint8_t versionLow = this->gps->getProtocolVersionLow();
std::cout << "u-blox protocol version: " << unsigned(versionHigh) << "." << unsigned(versionLow) << std::endl; std::cout << "u-blox protocol version: " << unsigned(versionHigh) << "." << unsigned(versionLow) << std::endl;
@@ -47,7 +59,7 @@ void Navigation::initNtrip(String host, uint16_t port, String mountPoint, String
this->ntripClient = new NTRIPClient(this->gps, host.c_str(), port, mountPoint.c_str(), user.c_str(), password.c_str()); this->ntripClient = new NTRIPClient(this->gps, host.c_str(), port, mountPoint.c_str(), user.c_str(), password.c_str());
this->ntripClient->gpsConfiguration(); this->ntripClient->gpsConfiguration();
this->ntripClient->loop(); this->ntripClient->loop();
this->ntripClient->setActivated(true); this->ntripClient->setActivated(false);
this->isNtripInit = true; this->isNtripInit = true;
} }
+18 -2
View File
@@ -14,8 +14,8 @@
#include <SparkFun_u-blox_GNSS_Arduino_Library.h> #include <SparkFun_u-blox_GNSS_Arduino_Library.h>
#include <Arduino.h> #include <Arduino.h>
#include <Wire.h>
#include <iostream> #include <iostream>
#include <SPI.h>
#include "route.h" #include "route.h"
#include "navigationUtils.h" #include "navigationUtils.h"
@@ -53,12 +53,19 @@ struct CourseCorrection {
class Navigation { class Navigation {
public: public:
/** /**
* @brief Construct a new Navigation object * @brief Construct a new Navigation object and using I2C
* *
* @param route with which to navigate * @param route with which to navigate
*/ */
Navigation(Route* route = nullptr); Navigation(Route* route = nullptr);
/**
* @brief Construct a new Navigation object and using SPI
*
* @param route with which to navigate
*/
Navigation(SPIClass spiPort, uint8_t csPin, Route* route = nullptr);
/** /**
* @brief Destroy the Navigation object * @brief Destroy the Navigation object
* *
@@ -126,6 +133,13 @@ class Navigation {
*/ */
SFE_UBLOX_GNSS* getGPS() { return this->gps; } SFE_UBLOX_GNSS* getGPS() { return this->gps; }
/**
* @brief Returns the NTRIPClient object
*
* @return NTRIPClient*
*/
NTRIPClient* getNTRIPClient() { return this->ntripClient; }
/** /**
* @brief Get the Route Info object * @brief Get the Route Info object
* *
@@ -179,6 +193,8 @@ class Navigation {
*/ */
static double courseTo(Point p1, Point p2); static double courseTo(Point p1, Point p2);
void init(Route* route);
SFE_UBLOX_GNSS* gps; SFE_UBLOX_GNSS* gps;
Route* route = nullptr; Route* route = nullptr;
NTRIPClient* ntripClient = nullptr; NTRIPClient* ntripClient = nullptr;
+15 -7
View File
@@ -10,6 +10,7 @@
*/ */
#include "ntripClient.h" #include "ntripClient.h"
bool NTRIPClient::outputStatusPrintPVTdata = false;
NTRIPClient::NTRIPClient(SFE_UBLOX_GNSS* gps, const char* host, uint16_t port, const char* mountPoint, const char* user, const char* password) { NTRIPClient::NTRIPClient(SFE_UBLOX_GNSS* gps, const char* host, uint16_t port, const char* mountPoint, const char* user, const char* password) {
this->gps = gps; this->gps = gps;
@@ -34,7 +35,7 @@ void NTRIPClient::loop() {
this->gps->checkUblox(); this->gps->checkUblox();
this->gps->checkCallbacks(); this->gps->checkCallbacks();
if (millis() - this->lastGPGGAPushTime > this->pushGPGGATime) { if (millis() - this->lastGPGGAPushTime > this->pushGPGGATime && this->activated) {
this->lastGPGGAPushTime = millis(); this->lastGPGGAPushTime = millis();
// std::cout << "Try to push GPGGA data." << std::endl; // std::cout << "Try to push GPGGA data." << std::endl;
NMEA_GGA_data_t *data = new NMEA_GGA_data_t; NMEA_GGA_data_t *data = new NMEA_GGA_data_t;
@@ -83,7 +84,7 @@ void NTRIPClient::loop() {
if (this->activated) if (this->activated)
this->state = NTRIPClientStates::openConnection; this->state = NTRIPClientStates::openConnection;
if (this->activated) { if (this->activated) {
std::cout << "state is openConnection" << std::endl; // std::cout << "state is openConnection" << std::endl;
} }
break; break;
@@ -98,7 +99,7 @@ void NTRIPClient::gpsConfiguration() {
this->gps->setI2COutput(COM_TYPE_UBX | COM_TYPE_NMEA); this->gps->setI2COutput(COM_TYPE_UBX | COM_TYPE_NMEA);
this->gps->setPortInput(COM_PORT_I2C, COM_TYPE_UBX | COM_TYPE_NMEA | COM_TYPE_RTCM3); this->gps->setPortInput(COM_PORT_I2C, COM_TYPE_UBX | COM_TYPE_NMEA | COM_TYPE_RTCM3);
// Set the differential mode - ambiguities are fixed whenever possible // Set the differential mode - ambiguities are fixed whenever possible
// this->gps->setDGNSSConfiguration(SFE_UBLOX_DGNSS_MODE_FIXED); this->gps->setDGNSSConfiguration(SFE_UBLOX_DGNSS_MODE_FIXED);
this->gps->setNavigationFrequency(1); this->gps->setNavigationFrequency(1);
this->gps->setMainTalkerID(SFE_UBLOX_MAIN_TALKER_ID_GP); this->gps->setMainTalkerID(SFE_UBLOX_MAIN_TALKER_ID_GP);
this->gps->enableNMEAMessage(UBX_NMEA_GGA, COM_PORT_I2C, 10); this->gps->enableNMEAMessage(UBX_NMEA_GGA, COM_PORT_I2C, 10);
@@ -226,7 +227,7 @@ bool NTRIPClient::processConnection() {
if (rtcmCount > 0) { if (rtcmCount > 0) {
this->lastReceivedRtcmTime = millis(); this->lastReceivedRtcmTime = millis();
this->gps->pushRawData(rtcmData, rtcmCount); this->gps->pushRawData(rtcmData, rtcmCount);
std::cout << "Pushed " << rtcmCount << " RTCM bytes to ZED." << std::endl; // std::cout << "Pushed " << rtcmCount << " RTCM bytes to ZED." << std::endl;
} }
} else { } else {
std::cout << "Connection to " << this->host << " dropped!" << std::endl; std::cout << "Connection to " << this->host << " dropped!" << std::endl;
@@ -242,13 +243,16 @@ bool NTRIPClient::processConnection() {
} }
void NTRIPClient::pushGPGGA(NMEA_GGA_data_t *nmeaData) { void NTRIPClient::pushGPGGA(NMEA_GGA_data_t *nmeaData) {
if (this->ntripClient->connected() && this->transmitLocation) { if (this->ntripClient->connected() && this->transmitLocation)
std::cout << "Pushing GGA to server: " << (const char *)nmeaData->nmea << std::endl;
this->ntripClient->print((const char *)nmeaData->nmea); this->ntripClient->print((const char *)nmeaData->nmea);
} else
std::cout << "Failed to pushing GGA to server: " << (const char *)nmeaData->nmea << std::endl;
} }
void NTRIPClient::printPVTdata(UBX_NAV_PVT_data_t *ubxDataStruct) { void NTRIPClient::printPVTdata(UBX_NAV_PVT_data_t *ubxDataStruct) {
if (!NTRIPClient::outputStatusPrintPVTdata)
return;
double latitude = (double) ubxDataStruct->lat / 10000000.0; double latitude = (double) ubxDataStruct->lat / 10000000.0;
double longitude = (double) ubxDataStruct->lon / 10000000.0; double longitude = (double) ubxDataStruct->lon / 10000000.0;
double altitude = (double) ubxDataStruct->hMSL / 1000.0; double altitude = (double) ubxDataStruct->hMSL / 1000.0;
@@ -293,6 +297,10 @@ void NTRIPClient::printPVTdata(UBX_NAV_PVT_data_t *ubxDataStruct) {
<< " Horizontal Accuracy Estimate: " << hAcc << " mm" << std::endl; << " Horizontal Accuracy Estimate: " << hAcc << " mm" << std::endl;
} }
void NTRIPClient::setOutputStatusPrintPVTdata(bool status) {
NTRIPClient::outputStatusPrintPVTdata = status;
}
bool NTRIPClient::isConnected() { bool NTRIPClient::isConnected() {
if (this->state == NTRIPClientStates::pushData) if (this->state == NTRIPClientStates::pushData)
return true; return true;
+3
View File
@@ -31,6 +31,7 @@ class NTRIPClient {
NTRIPClientStates getClientState() { return this->state; } NTRIPClientStates getClientState() { return this->state; }
static void printPVTdata(UBX_NAV_PVT_data_t *ubxDataStruct); static void printPVTdata(UBX_NAV_PVT_data_t *ubxDataStruct);
static void setOutputStatusPrintPVTdata(bool status);
private: private:
void pushGPGGA(NMEA_GGA_data_t *nmeaData); void pushGPGGA(NMEA_GGA_data_t *nmeaData);
@@ -60,6 +61,8 @@ class NTRIPClient {
const uint16_t tryReconnectTime = 5000; const uint16_t tryReconnectTime = 5000;
const uint16_t bufferSize = 512; const uint16_t bufferSize = 512;
const uint16_t pushGPGGATime = 10000; const uint16_t pushGPGGATime = 10000;
static bool outputStatusPrintPVTdata;
}; };
#endif #endif
+44 -7
View File
@@ -11,8 +11,9 @@
#include "menuGPS.h" #include "menuGPS.h"
MenuGPS::MenuGPS(SFE_UBLOX_GNSS* gps) { MenuGPS::MenuGPS(DriveManager* driveManager) {
this->gps = gps; this->gps = driveManager->getNavigation()->getGPS();
this->ntripClient = driveManager->getNavigation()->getNTRIPClient();
this->lastMillis = millis(); this->lastMillis = millis();
} }
@@ -33,7 +34,7 @@ void MenuGPS::down() {
} }
void MenuGPS::right() { void MenuGPS::right() {
this->printMenu(); this->yes();
} }
void MenuGPS::left() { void MenuGPS::left() {
@@ -46,11 +47,12 @@ void MenuGPS::no() {
} }
void MenuGPS::yes() { void MenuGPS::yes() {
this->runCommand();
this->printMenu(); this->printMenu();
} }
void MenuGPS::printMenu() { void MenuGPS::printMenu() {
this->printPage(this->currentPage); this->printPage();
} }
void MenuGPS::update() { void MenuGPS::update() {
@@ -61,7 +63,7 @@ void MenuGPS::update() {
this->lastMillis = millis(); this->lastMillis = millis();
} }
void MenuGPS::printPage(uint8_t page) const { void MenuGPS::printPage() const {
uint8_t fixType = gps->getFixType(); uint8_t fixType = gps->getFixType();
switch (this->currentPage) { switch (this->currentPage) {
@@ -127,13 +129,48 @@ void MenuGPS::printPage(uint8_t page) const {
} }
break; break;
case 3: {
bool status;
if (this->ntripClient->getClientState() == NTRIPClientStates::pushData)
status = true;
else
status = false;
if (this->lcd) {
lcd->clear();
lcd->setCursor(0, 0);
lcd->print("NTRIP Client");
lcd->setCursor(0, 1);
if (status)
lcd->print("enabled");
else
lcd->print("disabled");
}
if (status)
std::cout << "NTRIP Client is enabled." << std::endl;
else
std::cout << "NTRIP Client is disabled" << std::endl;
}
break;
default: default:
if (this->lcd) { if (this->lcd) {
lcd->clear(); lcd->clear();
lcd->setCursor(0, 0); lcd->setCursor(0, 0);
lcd->printf("Page: %u", page); lcd->printf("Page: %u", this->currentPage);
} }
std::cout << "Page: " << (int) page << std::endl; std::cout << "Page: " << (int) this->currentPage << std::endl;
break;
}
}
void MenuGPS::runCommand() const {
switch (this->currentPage) {
case 3:
if (this->ntripClient->getClientState() == NTRIPClientStates::pushData)
this->ntripClient->setActivated(false);
else
this->ntripClient->setActivated(true);
break; break;
} }
} }
+6 -2
View File
@@ -15,6 +15,8 @@
#include <SparkFun_u-blox_GNSS_Arduino_Library.h> #include <SparkFun_u-blox_GNSS_Arduino_Library.h>
#include "menuControl.h" #include "menuControl.h"
#include "driveModi/driveManager.h"
#include "ntripClient.h"
/** /**
* @brief A class to print informations about the GPS object * @brief A class to print informations about the GPS object
@@ -27,7 +29,7 @@ class MenuGPS : public MenuControl {
* *
* @param gps * @param gps
*/ */
MenuGPS(SFE_UBLOX_GNSS* gps); MenuGPS(DriveManager* driveManager);
/** /**
@@ -77,9 +79,11 @@ class MenuGPS : public MenuControl {
private: private:
const uint8_t countPages = 7; const uint8_t countPages = 7;
uint8_t currentPage = 0; uint8_t currentPage = 0;
void printPage(const uint8_t page) const; void printPage() const;
void runCommand() const;
SFE_UBLOX_GNSS* gps; SFE_UBLOX_GNSS* gps;
NTRIPClient* ntripClient;
const uint16_t delay = 5000; const uint16_t delay = 5000;
uint32_t lastMillis = 0; uint32_t lastMillis = 0;
+4 -1
View File
@@ -17,7 +17,10 @@ Modi& operator++(Modi& m, int) {
DriveManager::DriveManager(MoveControl *moveControl, bool wifi) { DriveManager::DriveManager(MoveControl *moveControl, bool wifi) {
this->moveControl = moveControl; this->moveControl = moveControl;
this->navigation = new Navigation();
SPIClass spiPort(HSPI);
spiPort.begin(UBLOX_GNSS_SPI_SCK, UBLOX_GNSS_SPI_CIPO, UBLOX_GNSS_SPI_COPI, UBLOX_GNSS_SPI_CS);
this->navigation = new Navigation(spiPort, UBLOX_GNSS_SPI_CS);
if (wifi) if (wifi)
this->navigation->initNtrip(NTRIP_HOST, NTRIP_PORT, NTRIP_MOUNT_POINT, NTRIP_USER, NTRIP_PASSWORD); this->navigation->initNtrip(NTRIP_HOST, NTRIP_PORT, NTRIP_MOUNT_POINT, NTRIP_USER, NTRIP_PASSWORD);
// if (wifi) // if (wifi)
+2 -5
View File
@@ -12,16 +12,13 @@
#ifndef DRIVE_MANAGER_H #ifndef DRIVE_MANAGER_H
#define DRIVE_MANAGER_H #define DRIVE_MANAGER_H
//GPS Serial Pins
#define GPS_RX 17
#define GPS_TX 16
#define GPS_BAUD 9600
#include <Arduino.h> #include <Arduino.h>
#include <SPI.h>
#include "moveControl.h" #include "moveControl.h"
#include "driveModi/driveModi.h" #include "driveModi/driveModi.h"
#include "navigation.h" #include "navigation.h"
#include "config.h"
#include "networkConfig.h" #include "networkConfig.h"
#include "debugTimes.h" #include "debugTimes.h"
+1 -1
View File
@@ -253,7 +253,7 @@ void makeMenu() {
MenuCaptureRoute* cap_m = new MenuCaptureRoute(driveManager); MenuCaptureRoute* cap_m = new MenuCaptureRoute(driveManager);
MenuAutopilot* auto_m = new MenuAutopilot(driveManager); MenuAutopilot* auto_m = new MenuAutopilot(driveManager);
MenuTestMode* test_m = new MenuTestMode(driveManager); MenuTestMode* test_m = new MenuTestMode(driveManager);
MenuGPS* gps_m = new MenuGPS(driveManager->getNavigation()->getGPS()); MenuGPS* gps_m = new MenuGPS(driveManager);
MenuAkku* akku_m = new MenuAkku(mainBattery); MenuAkku* akku_m = new MenuAkku(mainBattery);
// Set Menus on LCD // Set Menus on LCD