From 4e2b5bd3472834312ec29c1b6992303d16192733 Mon Sep 17 00:00:00 2001 From: Alexander Klein Date: Sat, 2 Sep 2023 17:51:16 +0200 Subject: [PATCH 1/7] delete old debug python files --- debugMqtt/hw1/main.py | 25 ------------------------- debugMqtt/hw1/main_debug.py | 23 ----------------------- debugMqtt/rhede/main.py | 27 --------------------------- debugMqtt/rhede/main_debug.py | 24 ------------------------ 4 files changed, 99 deletions(-) delete mode 100644 debugMqtt/hw1/main.py delete mode 100644 debugMqtt/hw1/main_debug.py delete mode 100644 debugMqtt/rhede/main.py delete mode 100644 debugMqtt/rhede/main_debug.py diff --git a/debugMqtt/hw1/main.py b/debugMqtt/hw1/main.py deleted file mode 100644 index a11416c..0000000 --- a/debugMqtt/hw1/main.py +++ /dev/null @@ -1,25 +0,0 @@ -import paho.mqtt.client as mqtt - - -def on_connect(client, userdata, flags, rc): - print("Connected with result code "+str(rc)) - - # Subscribing in on_connect() means that if we lose the connection and - # reconnect then subscriptions will be renewed. - client.subscribe("Rover/Info") - client.subscribe("Rover/Warn") - client.subscribe("Rover/Error") - - -def on_message(client, userdata, msg): - print(msg.topic+" -> "+str(msg.payload)[2:-1]) - - -if __name__ == '__main__': - client = mqtt.Client() - client.on_connect = on_connect - client.on_message = on_message - - client.connect("172.22.64.216", 1883, 60) - - client.loop_forever() diff --git a/debugMqtt/hw1/main_debug.py b/debugMqtt/hw1/main_debug.py deleted file mode 100644 index 70957cd..0000000 --- a/debugMqtt/hw1/main_debug.py +++ /dev/null @@ -1,23 +0,0 @@ -import paho.mqtt.client as mqtt - - -def on_connect(client, userdata, flags, rc): - print("Connected with result code "+str(rc)) - - # Subscribing in on_connect() means that if we lose the connection and - # reconnect then subscriptions will be renewed. - client.subscribe("Rover/Debug") - - -def on_message(client, userdata, msg): - print(msg.topic+" -> "+str(msg.payload)[2:-1]) - - -if __name__ == '__main__': - client = mqtt.Client() - client.on_connect = on_connect - client.on_message = on_message - - client.connect("172.22.64.216", 1883, 60) - - client.loop_forever() diff --git a/debugMqtt/rhede/main.py b/debugMqtt/rhede/main.py deleted file mode 100644 index af65384..0000000 --- a/debugMqtt/rhede/main.py +++ /dev/null @@ -1,27 +0,0 @@ -import paho.mqtt.client as mqtt - - -def on_connect(client, userdata, flags, rc): - print("Connected with result code "+str(rc)) - - # Subscribing in on_connect() means that if we lose the connection and - # reconnect then subscriptions will be renewed. - client.subscribe("Rover/Info") - client.subscribe("Rover/Warn") - client.subscribe("Rover/Error") - client.subscribe("Rover/Info") - - -def on_message(client, userdata, msg): - print(msg.topic+" -> "+str(msg.payload)[2:-1]) - - -if __name__ == '__main__': - client = mqtt.Client() - client.on_connect = on_connect - client.on_message = on_message - - client.username_pw_set("kleiax", password="p?{$_~5%hBM7wrcFkr55KWr#") - client.connect("192.168.1.7", 1883, 60) - - client.loop_forever() diff --git a/debugMqtt/rhede/main_debug.py b/debugMqtt/rhede/main_debug.py deleted file mode 100644 index 27599f1..0000000 --- a/debugMqtt/rhede/main_debug.py +++ /dev/null @@ -1,24 +0,0 @@ -import paho.mqtt.client as mqtt - - -def on_connect(client, userdata, flags, rc): - print("Connected with result code "+str(rc)) - - # Subscribing in on_connect() means that if we lose the connection and - # reconnect then subscriptions will be renewed. - client.subscribe("Rover/Debug") - - -def on_message(client, userdata, msg): - print(msg.topic+" -> "+str(msg.payload)[2:-1]) - - -if __name__ == '__main__': - client = mqtt.Client() - client.on_connect = on_connect - client.on_message = on_message - - client.username_pw_set("kleiax", password="p?{$_~5%hBM7wrcFkr55KWr#") - client.connect("192.168.1.7", 1883, 60) - - client.loop_forever() From d7a9e9cfd83321bce48c78305be2e7caf2d6d292 Mon Sep 17 00:00:00 2001 From: Alexander Klein Date: Sat, 2 Sep 2023 18:34:06 +0200 Subject: [PATCH 2/7] delete everthing for bachelore --- lib/Navigation/navigation.cpp | 238 -------------- lib/Navigation/navigation.h | 219 ------------- lib/NtripClient/ntripClient.cpp | 290 ------------------ lib/NtripClient/ntripClient.h | 130 -------- lib/Route/route.cpp | 181 ----------- lib/Route/route.h | 237 -------------- .../driveModi/Autopilot/menuAutopilot.cpp | 254 --------------- .../driveModi/Autopilot/menuAutopilot.h | 59 ---- .../CaptureRoute/menuCaptureRoute.cpp | 138 --------- .../driveModi/CaptureRoute/menuCaptureRoute.h | 53 ---- src/driveModi/Modi/Autopilot/autopilot.cpp | 250 --------------- src/driveModi/Modi/Autopilot/autopilot.h | 134 -------- .../Modi/CaptureRoute/captureRoute.cpp | 50 --- .../Modi/CaptureRoute/captureRoute.h | 85 ----- 14 files changed, 2318 deletions(-) delete mode 100644 lib/Navigation/navigation.cpp delete mode 100644 lib/Navigation/navigation.h delete mode 100644 lib/NtripClient/ntripClient.cpp delete mode 100644 lib/NtripClient/ntripClient.h delete mode 100644 lib/Route/route.cpp delete mode 100644 lib/Route/route.h delete mode 100644 src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp delete mode 100644 src/SpecialMenus/driveModi/Autopilot/menuAutopilot.h delete mode 100644 src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp delete mode 100644 src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.h delete mode 100644 src/driveModi/Modi/Autopilot/autopilot.cpp delete mode 100644 src/driveModi/Modi/Autopilot/autopilot.h delete mode 100644 src/driveModi/Modi/CaptureRoute/captureRoute.cpp delete mode 100644 src/driveModi/Modi/CaptureRoute/captureRoute.h diff --git a/lib/Navigation/navigation.cpp b/lib/Navigation/navigation.cpp deleted file mode 100644 index 5c505a4..0000000 --- a/lib/Navigation/navigation.cpp +++ /dev/null @@ -1,238 +0,0 @@ -/** - * @file navigation.cpp - * @author Alexander Klein (alex@kleiax.de) - * @brief Contains the implementation of the class Navigation - * @version 0.1 - * @date 2022-01-31 - * - * @copyright Copyright (c) 2022 - * - */ - -#include "navigation.h" - -bool Navigation::outputStatusPrintPVTdata = false; -bool Navigation::newData = false; -uint32_t Navigation::ubxUpdateTimeStatic = 0; -UBX_NAV_PVT_data_t* Navigation::ubxDataStatic = nullptr; - -Navigation::Navigation(Route* route) { - this->init(route); -} - -void Navigation::init(Route* route) { - - - if (route) - this->route = route; - else - this->route = new Route(); - - Component::loopDelay = Navigation::loopDelay; -} - -Navigation::~Navigation() { - delete this->route; - if (this->ntripClient) - delete this->ntripClient; -} - -void Navigation::initNtrip(String host, uint16_t port, String mountPoint, String user, String password) { - this->ntripClient = new NTRIPClient(this->gps, host.c_str(), port, mountPoint.c_str(), user.c_str(), password.c_str()); - this->ntripClient->gpsConfiguration(); - this->ntripClient->loop(); - this->ntripClient->setActivated(false); - this->isNtripInit = true; - this->addChildComponent(this->ntripClient); -} - -void Navigation::run() { - this->updateMagneticDeclination(); -} - - -void Navigation::newRoute() { - if (this->route) - delete this->route; - this->route = new Route(); -} - -bool Navigation::startNavigation() { - Point newTargetPoint = this->route->startRoute(); - this->navigationStarted = this->setTargetPoint(newTargetPoint); - if (this->navigationStarted) - this->navigationFinished = false; - return this->navigationStarted; -} - -void Navigation::drivingDirectionChange() { - Point tmp = this->currentPosition; - if (tmp.isInit() && tmp.isValid()) { - this->directionChangeMode = true; - this->lastPointDrivingDirectionChange = tmp; - this->calcAzimuthState = CalcAzimuthState::Invalid; - } -} - -Navigation::Status Navigation::getCourseCorrection(CourseCorrection& correction, bool forceUpdate) { - if (this->navigationFinished) - return Status::Complete; - - if (this->currentPosition.getAccuracy() <= this->minAccuracy) - return Status::InsufficientAccuracy; - - if (this->currentPosition.distanceTo(this->lastPointCalcCorrection) < (this->minDistanceToReachPoint / 2.0) - && !forceUpdate) { - correction.correction = this->calculateCourseCorrection(this->lastPointCalcCorrection); - correction.distance = this->lastPointCalcCorrection.distanceTo(this->targetPoint); - return Status::Unchanged; - } - - double distance = this->currentPosition.distanceTo(this->targetPoint); - - // Check if I need a new Point - if (distance < this->minDistanceToReachPoint && this->preventNextPoint == false) { - if (!this->nextPoint()) { - this->navigationFinished = true; - this->navigationStarted = false; - return Status::Complete; // End of navigation - } - distance = this->currentPosition.distanceTo(this->targetPoint); - } - - correction.correction = this->calculateCourseCorrection(this->currentPosition); - correction.distance = distance; - this->lastPointCalcCorrection = this->currentPosition; - return Status::Updated; -} - -Navigation::Status Navigation::addCurrentPosToRoute() { - if (this->currentPosition.getAccuracy() <= this->minAccuracy) - return Status::InsufficientAccuracy; - - // First Point - if (this->route->getRouteInfo().totalPoints == 0) { - this->route->addPointToRoute(this->currentPosition); - this->lastPointRouteInsert = this->currentPosition; - return Status::Updated; - } - - // Every Point after the first - double distance = this->currentPosition.distanceTo(this->lastPointRouteInsert); - if (Navigation::minDisBetweenPoints <= distance - && Navigation::maxDisBetweenPoints >= distance){ - this->route->addPointToRoute(this->currentPosition); - this->lastPointRouteInsert = this->currentPosition; - return Status::Updated; - } - return Status::Unchanged; -} - -void Navigation::updateCurrentLocation() { - if (Navigation::ubxUpdateTimeStatic == this->ubxUpdateTime) - return; - - this->ubxData = Navigation::ubxDataStatic; - this->ubxUpdateTime = Navigation::ubxUpdateTimeStatic; - - Point::Coordinates coords; - coords.lat = this->ubxData->lat / 10000000.0; - coords.lon = this->ubxData->lon / 10000000.0; - - this->currentPosition = Point(coords, this->ubxData->hAcc); -} - -void Navigation::updateMagneticDeclination() { - if (!this->directionChangeMode - || this->lastPointDrivingDirectionChange.distanceTo(this->currentPosition) < 1.0) - { - this->calcAzimuthState = CalcAzimuthState::Invalid; - this->calcAzimuth = 999; - return; - } - - this->calcAzimuth = this->lastPointDrivingDirectionChange.courseTo(this->currentPosition); - - // Map point accuracy to CalcAzimuthState - if (this->lastPointDrivingDirectionChange.getAccuracy() == Point::Accuracy::oneDigOfCM - || this->currentPosition.getAccuracy() == Point::Accuracy::oneDigOfCM) - { - this->calcAzimuthState = CalcAzimuthState::Good; - } - else if (this->lastPointDrivingDirectionChange.getAccuracy() == Point::Accuracy::twoDigOfCM - || this->currentPosition.getAccuracy() == Point::Accuracy::twoDigOfCM) - { - this->calcAzimuthState = CalcAzimuthState::Ok; - } - else if (this->lastPointDrivingDirectionChange.getAccuracy() == Point::Accuracy::threeDigOfCM - || this->currentPosition.getAccuracy() == Point::Accuracy::threeDigOfCM) - { - this->calcAzimuthState = CalcAzimuthState::Bad; - } - else - { - this->calcAzimuthState = CalcAzimuthState::Invalid; - } - - // Upgrade quality if the range grows up - if (this->lastPointDrivingDirectionChange.distanceTo(this->currentPosition) > 2.0) { - switch (this->calcAzimuthState) { - case CalcAzimuthState::Bad : - this->calcAzimuthState = CalcAzimuthState::Ok; - break; - - case CalcAzimuthState::Ok : - this->calcAzimuthState = CalcAzimuthState::Good; - break; - - case CalcAzimuthState::Good : - this->calcAzimuthState = CalcAzimuthState::Super; - break; - - default: - break; - } - } - -} - -int16_t Navigation::calculateCourseCorrection(Point& point) { - int16_t targetCourse = point.courseTo(this->targetPoint); - int16_t correctionCourse; - - if (this->calcAzimuthState == CalcAzimuthState::Good - || this->calcAzimuthState == CalcAzimuthState::Super) - { - correctionCourse = targetCourse - this->calcAzimuth; - this->lastUsedCalcAzimuth = true; - } else { - correctionCourse = targetCourse - this->realAzimuth; - this->lastUsedCalcAzimuth = false; - } - - return Navigation::fixDegree(correctionCourse); -} - -bool Navigation::nextPoint() { - if (!this->navigationStarted) - return false; - return this->setTargetPoint(this->route->getNextPoint()); -} - -bool Navigation::setTargetPoint(Point target) { - if (target.isInit()) { - this->targetPoint = target; - return true; - } - return false; -} - -int16_t Navigation::fixDegree(int16_t degree) { - while (degree < -180 || degree > 180) { - if (degree > 180) - degree -= 360; - else if (degree < -180) - degree += 360; - } - return degree; -} diff --git a/lib/Navigation/navigation.h b/lib/Navigation/navigation.h deleted file mode 100644 index 006e7da..0000000 --- a/lib/Navigation/navigation.h +++ /dev/null @@ -1,219 +0,0 @@ -/** - * @file navigation.h - * @author Alexander Klein (alex@kleiax.de) - * @brief Contains a class which navigate an object by the given route - * @version 0.1 - * @date 2022-01-10 - * - * @copyright Copyright (c) 2022 - * - */ - -#ifndef NAVIGATION_H -#define NAVIGATION_H - -#include -#include - -#include "route.h" -#include "NTRIPClient.h" - -#include "component.h" - -/** - * @brief This struct inherits the result of the navigation - * - * The drive get objects of this struct and should - * correct the direction in dependency on this. - * - */ -struct CourseCorrection { - int16_t correction; - double distance; -}; - -/** - * @brief This class navigate an object - * - * The class use the given Route and the gps device - * to tell the driver in which direction he have to - * be drive and the distance to the next checkpoint. - * - */ -class Navigation : public Component { - public: - enum Status { - InsufficientAccuracy, - Unchanged, - Updated, - Complete - }; - - /** - * @brief Construct a new Navigation object and using I2C - * - * @param route with which to navigate - */ - Navigation(Route* route = nullptr); - - /** - * @brief Destroy the Navigation object - * - */ - ~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 creates a new empty route - * - */ - void newRoute(); - - /** - * @brief Tries to start the route - * - * For example the route can not be started - * if there are no Points or wrong Points. - * - * @return true route is started - * @return false route can not be started - */ - bool startNavigation(); - void freezeTargetPoint(bool val = true) { this->preventNextPoint = val; }; - void drivingDirectionChange(); - void disableCalcAzimuth() { this->directionChangeMode = false; } - - double increaseMinDistanceToReachPoint() { return this->minDistanceToReachPoint += 0.1; } - double decreaseMinDistanceToReachPoint() { return this->minDistanceToReachPoint -= 0.1; } - - // TODO: Dokumentation korrigieren. - /** - * @brief Get the Course Correction object - * - * This should be called by the driver to get new instructions. - * - * @param correction passed as refernce to get the data - * @return true if new correction data provided - * @return false if route is finished - */ - Status getCourseCorrection(CourseCorrection& correction, bool forceUpdate = false); - - - // TODO: Dokumentation korrigieren. - /** - * @brief Tries to add the current Position to the route - * - * This can be go wrong if there is no valid GPS signal - * - * @return true successful added point - * @return false no point added to route - */ - Status addCurrentPosToRoute(); - - /** - * @brief Get the Ubx Data object - * - * This struct includes the most Data from the GNSS-Module. - * - * @return UBX_NAV_PVT_data_t* - */ - UBX_NAV_PVT_data_t* getUbxData() { return this->ubxData; } - - /** - * @brief Returns the NTRIPClient object - * - * @return NTRIPClient* - */ - NTRIPClient* getNTRIPClient() { return this->ntripClient; } - - /** - * @brief Get the Route Info object - * - * This object contains information about the route. - * For example the stored points. - * - * @return RouteInfo - */ - RouteInfo getRouteInfo() const { return this->route->getRouteInfo(); } - Route* getRoute() const { return this->route; } - Point getCurrentPosition() const { return this->currentPosition; } - - /** - * @brief Get realAzimuth - * - * This value represents the angle between north and - * the line of sight. Clockwise. - * - * @return uint16_t degree - */ - int16_t getAzimuth() const { return this->realAzimuth; } - QMC5883LCompass* getCompass() const { return this->compass; } - int16_t getCalcAzimuth() const { return this->calcAzimuth; } - CalcAzimuthState getCalcAzimuthState() const { return this->calcAzimuthState; } - bool getLastUsedCalcAzimuth() const { return this->lastUsedCalcAzimuth; } - - Point::Accuracy getMinAccuracy() const { return this->minAccuracy; } - void setMinAccuracy(Point::Accuracy accuracy) { this->minAccuracy = accuracy; } - - // map input in range from -180 to 180 degree - static int16_t fixDegree(int16_t degree); - - private: - void run() override; - void updateMagneticDeclination(); - void init(Route* route); - bool nextPoint(); - bool setTargetPoint(Point target); - int16_t calculateCourseCorrection(Point& point); - - static constexpr uint8_t loopDelay = 20; - static constexpr uint8_t maxDisBetweenPoints = 10; - static constexpr float minDisBetweenPoints = 0.3; - - - UBX_NAV_PVT_data_t* ubxData = nullptr; - Route* route = nullptr; - NTRIPClient* ntripClient = nullptr; - - - Point lastPointRouteInsert; - Point lastPointCalcCorrection; - Point lastPointDrivingDirectionChange; - Point targetPoint; - Point currentPosition; - Point::Accuracy minAccuracy = Point::Accuracy::twoDigOfCM; - - - bool navigationStarted = false; - bool navigationFinished = false; - bool isNtripInit = false; - bool preventNextPoint = false; - bool directionChangeMode = false; - bool lastUsedCalcAzimuth = false; - - char* host; - char* mountPoint; - char* user; - char* password; - - int16_t calcAzimuth = INT16_MAX; - - uint8_t timeToWait = 200; - uint16_t port; - uint32_t lastMillis = 0; - uint32_t ubxUpdateTime = 0; - - double minDistanceToReachPoint = 0.5; -}; - -#endif // NAVIGATION_H diff --git a/lib/NtripClient/ntripClient.cpp b/lib/NtripClient/ntripClient.cpp deleted file mode 100644 index 847f877..0000000 --- a/lib/NtripClient/ntripClient.cpp +++ /dev/null @@ -1,290 +0,0 @@ -/** - * @file NTRIPClient.cpp - * @author Alexander Klein (alex@kleiax.de) - * @brief Contains the implementation of the class NTRIPClient. - * @version 0.1 - * @date 2022-09-18 - * - * @copyright Copyright (c) 2022 - * - */ - -#include "ntripClient.h" - - -NTRIPClient::NTRIPClient(SFE_UBLOX_GNSS* gps, const char* host, uint16_t port, const char* mountPoint, const char* user, const char* password) { - this->gps = gps; - strcpy(this->host, host); - this->port = port; - strcpy(this->mountPoint, mountPoint); - strcpy(this->user, user); - strcpy(this->password, password); - - this->ntripClient = new WiFiClient; - this->state = NTRIPClientStates::closeConnection; - - this->loopDelay = 20; -} - -NTRIPClient::~NTRIPClient() { - delete this->ntripClient; -} - -void NTRIPClient::run() { - switch (this->state) { - case NTRIPClientStates::openConnection: - if (!this->activated) { - this->state = NTRIPClientStates::closeConnection; - break; - } - - std::cout << "Connecting to the NTRIP caster..." << std::endl; - if (this->beginClient()) { - std::cout << "Connected to the NTRIP caster!" << std::endl; - this->state = NTRIPClientStates::pushData; - } else { - std::cout << "Failed!" << std::endl; - this->state = NTRIPClientStates::wait; - this->activated = false; - } - break; - - case NTRIPClientStates::pushData: - if (!processConnection() || !this->activated) - this->state = NTRIPClientStates::closeConnection; - break; - - case NTRIPClientStates::closeConnection: - std::cout << "Closing the connection to the NTRIP caster..." << std::endl; - this->closeConnection(); - state = NTRIPClientStates::wait; - break; - - case NTRIPClientStates::wait: - if (this->activated) - this->state = NTRIPClientStates::openConnection; - else - this->checkAutoReconnect(); - break; - - case NTRIPClientStates::notAvailable: - break; - - default: - std::cout << "Wrong state in NTRIPClient.cpp..." << std::endl; - this->state = NTRIPClientStates::closeConnection; - break; - } -} - -void NTRIPClient::runAsChild() { - this->pushGPGGA(); -} - -void NTRIPClient::gpsConfiguration() { - this->gps->setSPIOutput(COM_TYPE_UBX | COM_TYPE_NMEA); - this->gps->setPortInput(COM_PORT_SPI, COM_TYPE_UBX | COM_TYPE_NMEA | COM_TYPE_RTCM3); - // Set the differential mode - ambiguities are fixed whenever possible - this->gps->setDGNSSConfiguration(SFE_UBLOX_DGNSS_MODE_FIXED); - this->gps->setMainTalkerID(SFE_UBLOX_MAIN_TALKER_ID_GP); - this->gps->enableNMEAMessage(UBX_NMEA_GGA, COM_PORT_SPI, 10); -} - -bool NTRIPClient::setActivated(bool state) { - // std::cout << "NTRIPClient::setActivated: b - " << b << std::endl; - if (state && this->state != NTRIPClientStates::notAvailable) - this->activated = true; - else if (state) - return false; - else { - this->activated = false; - this->autoReconnect = false; - } - return true; -} - -void NTRIPClient::setAutoReconnect(bool state) { - if (state) { - this->reconnectAttemps = 0; - this->autoReconnect = true; - return; - } - - this->autoReconnect = false; -} - -bool NTRIPClient::beginClient() { - std::cout << "Opening socket to " << this->host << std::endl; - - char serverRequest[this->bufferSize]; - char credentials[this->bufferSize]; - - if (!this->ntripClient->connect(this->host, this->port)) { - std::cout << "Connection to caster failed" << std::endl; - return false; - } else { - std::cout << "Connected to " << this->host << " : " << this->port << std::endl; - std::cout << "Requesting NTRIP Data from mount point " << this->mountPoint << std::endl; - - // Generate the server request (GET) - snprintf(serverRequest, - this->bufferSize, - "GET /%s HTTP/1.0\r\nUser-Agent: NTRIP SparkFun u-blox Client v1.0\r\n", - this->mountPoint); - - // Credentials - uint8_t userCredentialsLength = strlen(this->user) + strlen(this->password) + 2; - char* userCredentials = new char[userCredentialsLength]; - snprintf(userCredentials, userCredentialsLength, "%s:%s", this->user, this->password); - - std::cout << "Sending credentials: " << userCredentials << std::endl; - - //Encode - base64 b; - String strEncodedCredentials = b.encode(userCredentials); - delete userCredentials; - char encodedCredentials[strEncodedCredentials.length() + 1]; - strEncodedCredentials.toCharArray(encodedCredentials, sizeof(encodedCredentials)); - - snprintf(credentials, sizeof(credentials), "Authorization: Basic %s\r\n", encodedCredentials); - } - - // Add the encoded credentials to the server request - strncat(serverRequest, credentials, this->bufferSize); - strncat(serverRequest, "\r\n", this->bufferSize); - - std::cout << "serverRequest size: " - << strlen(serverRequest) - << " of " - << this->bufferSize - << " bytes available" - << std::endl; - - // Send the server request - std::cout << "Sending server request: " << serverRequest << std::endl; - this->ntripClient->write(serverRequest, strlen(serverRequest)); - - //Wait up to 5 seconds for response - uint32_t lastMillis = millis(); - while (!ntripClient->available()) { - if (millis() - lastMillis > this->timeOut) { - std::cout << "Caster timed out!" << std::endl; - this->ntripClient->stop(); - return false; - } - delay(10); - } - - //Check reply - uint16_t httpStatusCode = 0; - char response[this->bufferSize]; - uint16_t responseIndex = 0; - while (this->ntripClient->available()) { - if (responseIndex == sizeof(response)) - break; - - response[responseIndex++] = ntripClient->read(); - - if (httpStatusCode == 0) { - if (strstr(response, "200") != nullptr) - httpStatusCode = 200; - if (strstr(response, "401") != nullptr) - httpStatusCode = 401; - } - } - response[responseIndex] = '\0'; - - // std::cout << "Caster response: " << response << std::endl; - - if (httpStatusCode != 200) { - std::cout << "Failed to connect to " << this->host << " - HTTP Code: " << (int) httpStatusCode - << " Length of Response: " << responseIndex << std::endl; - - if (httpStatusCode == 0) - std::cout << "Response: " << response << std::endl; - else if (httpStatusCode == 401) - std::cout << "Statuscode 401 - Unauthorized" << std::endl; - return false; - } - - std::cout << "Connected to: " << this->host << std::endl; - this->lastReceivedRtcmTime = millis(); - return true; -} - -void NTRIPClient::closeConnection() { - if (this->ntripClient->connected()) - this->ntripClient->stop(); - this->activated = false; - std::cout << "NtripClient disconnected from: " << this->host << std::endl; -} - -bool NTRIPClient::processConnection() { - if (this->ntripClient->connected()) { - uint8_t rtcmData[this->bufferSize * 8]; - uint16_t rtcmCount = 0; - - while (this->ntripClient->available()) { - rtcmData[rtcmCount++] = ntripClient->read(); - if (rtcmCount == sizeof(rtcmData)) - break; - } - - if (rtcmCount > 0) { - this->lastReceivedRtcmTime = millis(); - this->gps->pushRawData(rtcmData, rtcmCount); - // std::cout << "Pushed " << rtcmCount << " RTCM bytes to ZED." << std::endl; - } - } else { - std::cout << "Connection to " << this->host << " dropped!" << std::endl; - return false; - } - - if (millis() - this->lastReceivedRtcmTime > this->timeOut) { - std::cout << "RTCM timeout!" << std::endl; - return false; - } - - return true; -} - -void NTRIPClient::checkAutoReconnect() { - if (!this->autoReconnect) - return; - - if (millis() - this->lastReconnectTime < this->reconnectDelayTime) - return; - this->lastReconnectTime = millis(); - - if (this->reconnectAttemps >= this->maxReconnectAttemps) { - this->autoReconnect = false; - return; - } - - this->activated = true; - this->reconnectAttemps++; -} - -void NTRIPClient::pushGPGGA() { - if (!this->transmitLocation && !this->activated) - return; - - if (millis() - this->lastGPGGAPushTime < this->pushGPGGATime) - return; - this->lastGPGGAPushTime = millis(); - - if (!this->ntripClient->connected()) - std::cout << "Failed to pushing GGA to server: " << std::endl; - - NMEA_GGA_data_t *data = new NMEA_GGA_data_t; - uint8_t res = this->gps->getLatestNMEAGPGGA(data); - if (res == 2) - this->ntripClient->print((const char *)data); - delete data; -} - -bool NTRIPClient::isConnected() { - if (this->state == NTRIPClientStates::pushData) - return true; - return false; -} diff --git a/lib/NtripClient/ntripClient.h b/lib/NtripClient/ntripClient.h deleted file mode 100644 index 577bbfa..0000000 --- a/lib/NtripClient/ntripClient.h +++ /dev/null @@ -1,130 +0,0 @@ -/** - * @file ntripClient.h - * @author Alexander Klein (alex@kleiax.de) - * @brief Contains the class NTRIPClient - * @version 0.1 - * @date 2023-02-13 - * - * @copyright Copyright (c) 2023 - * - */ - -#ifndef NTRIP_CLIENT -#define NTRIP_CLIENT - -#include -#include -#include -#include -#include - -#include "debugTimes.h" -#include "component.h" - -/** - * @brief States for the state machine. - * - */ -enum NTRIPClientStates { - openConnection, - pushData, - closeConnection, - wait, - notAvailable -}; - -/** - * @brief Ntrip Client - * - * This class can connect to a ntrip server to pull correction - * data and push it to a given gnss module. This module have to be compatible - * with the SparkFun u-blox GNSS Arduino Library. - */ -class NTRIPClient : public Component { - public: - /** - * @brief Construct a new NTRIPClient object - * - * @param gps The Gnss module - * @param host - * @param port - * @param mountPoint - * @param user - * @param password - */ - NTRIPClient(SFE_UBLOX_GNSS* gps, const char* host, uint16_t port, const char* mountPoint, const char* user, const char* password); - ~NTRIPClient(); - - /** - * @brief Configure the Gnss module to accept correction data - * - */ - void gpsConfiguration(); - - /** - * @brief Activate or deactivate the location transmission - * - * Some server need the position of the Gnss module to send the - * right correction data. - * - * @param b - */ - void setTransmitLocation(bool b) { this->transmitLocation = b; } - - /** - * @brief Activate or deactivate the connection to the server. - * - * @param state - * @return true success - * @return false failure - */ - bool setActivated(bool state); - void setAutoReconnect(bool state); - - bool isConnected(); - - /** - * @brief Get the Client State object - * - * Returns the state of the State machine - * - * @return NTRIPClientStates - */ - NTRIPClientStates getClientState() { return this->state; } - - private: - void run() override; - void runAsChild() override; - void pushGPGGA(); - bool beginClient(); - void closeConnection(); - bool processConnection(); - void checkAutoReconnect(); - - SFE_UBLOX_GNSS* gps; - WiFiClient* ntripClient; - NTRIPClientStates state = NTRIPClientStates::notAvailable; - - bool transmitLocation = false; - bool activated = true; - bool autoReconnect = false; - - uint8_t reconnectAttemps = 0; - uint16_t port; - uint32_t lastReceivedRtcmTime = 0; - // uint32_t lastNtripConnectTime = 0; // can deleted? - uint32_t lastGPGGAPushTime = 0; - uint32_t lastReconnectTime = 0; - - char host[128]; - char mountPoint[128]; - char user[128]; - char password[128]; - const uint8_t maxReconnectAttemps = 10; - const uint16_t reconnectDelayTime = 1000; - const uint16_t timeOut = 10000; - const uint16_t bufferSize = 512; - const uint16_t pushGPGGATime = 10000; -}; - -#endif diff --git a/lib/Route/route.cpp b/lib/Route/route.cpp deleted file mode 100644 index a9039fe..0000000 --- a/lib/Route/route.cpp +++ /dev/null @@ -1,181 +0,0 @@ -/** - * @file route.cpp - * @author Alexander Klein (alex@kleiax.de) - * @brief Implements the class Route and Point - * @version 0.1 - * @date 2022-01-31 - * - * @copyright Copyright (c) 2022 - * - */ - -#include "route.h" - -Point::Point(double lat, double lon, uint32_t horizontalAccuracy, uint32_t creationTime) { - this->coordinates.lat = lat; - this->coordinates.lon = lon; - this->init(horizontalAccuracy, creationTime); -} - -Point::Point(int32_t lat, int32_t lon, uint32_t horizontalAccuracy, uint32_t creationTime) { - this->coordinates.lat = lat / 10000000.0; - this->coordinates.lon = lon / 10000000.0; - this->init(horizontalAccuracy, creationTime); -} - -Point::Point(Coordinates coords, uint32_t horizontalAccuracy, uint32_t creationTime) { - this->coordinates = coords; - this->init(horizontalAccuracy, creationTime); -} - -Point::Point(Coordinates coords, bool imported) { - this->coordinates = coords; - if (imported) - this->init(UINT32_MAX, 0); - else - this->init(0, 0); -} - -Point::Point() { - this->coordinates.lat = 0; - this->coordinates.lon = 0; - this->init(0, 0); -} - -bool Point::operator==(const Point& rhs) const { - return this->coordinates == rhs.getCoordinates(); -} - - // distance = sqrt(dx * dx + dy * dy) - // mit distance: Entfernung in km - // dx = 111.3 * cos(lat) * (lon1 - lon2) - // lat = (lat1 + lat2) / 2 * 0.01745 - // dy = 111.3 * (lat1 - lat2) - // lat1, lat2, lon1, lon2: Breite, Länge in Grad -double Point::distanceTo(const Coordinates& point) const { - Coordinates begin = this->coordinates; - Coordinates end = point; - - double lat = (begin.lat + end.lat) / 2 * ROUTE_DEGREE_TO_RADIANT; - double dy = ROUTE_DISTANCE_BETWEEN_LATITUDE * (begin.lat - end.lat); - double dx = ROUTE_DISTANCE_BETWEEN_LATITUDE * cos(lat) * (begin.lon - end.lon); - - return sqrt(dx * dx + dy * dy); -} - -double Point::distanceTo(const Point &point) const { - return this->distanceTo(point.getCoordinates()); -} - -int16_t Point::courseTo(const Coordinates& point) const { - Coordinates begin = this->coordinates; - Coordinates end = point; - - double phi = log( tan(end.lat * ROUTE_DEGREE_TO_RADIANT / 2 + M_PI / 4) / tan(begin.lat * ROUTE_DEGREE_TO_RADIANT / 2 + M_PI / 4) ); - double lon = (begin.lon * ROUTE_DEGREE_TO_RADIANT - end.lon * ROUTE_DEGREE_TO_RADIANT); - - int16_t res = static_cast(atan2(lon, phi) / ROUTE_DEGREE_TO_RADIANT) * -1; - - // if (res < 0) - // res += 360; - - return res; -} - -int16_t Point::courseTo(const Point &point) const { - return this->courseTo(point.getCoordinates()); -} - -void Point::init(uint32_t horizontalAccuracy, uint32_t creationTime) { - this->creationTime = creationTime; - - if (horizontalAccuracy == UINT32_MAX) - this->accuracy = Accuracy::imported; - else if (horizontalAccuracy > 9999) - this->accuracy = Accuracy::fourDigOfCM; - else if (horizontalAccuracy > 999) - this->accuracy = Accuracy::threeDigOfCM; - else if (horizontalAccuracy > 99) - this->accuracy = Accuracy::twoDigOfCM; - else if (horizontalAccuracy > 1) - this->accuracy = Accuracy::oneDigOfCM; - else - this->accuracy = Accuracy::none; - -} - -Route::Route() { - -} - -void Route::addPointToRoute(Point point) { - this->points.push_back(point); -} - -void Route::clear() { - this->points.clear(); - this->currentPoint = 0; - this->started = false; -} - -Point Route::startRoute() { - if (this->points.size() < 1) { - this->started = false; - return Point(); - } - - this->it = this->points.begin(); - this->currentPoint = 1; - this->started = true; - return *this->it; -} - -Point Route::endRoute() { - if (this->points.size() < 1) { - this->started = false; - return Point(); - } - - this->it = this->points.end(); - // TODO: Understand why i have to decrement the iterator first to get realy the last element. - this->it--; - this->currentPoint = this->points.size(); - this->started = true; - return *this->it; -} - -Point Route::getNextPoint() { - if (!this->started) - return Point(); - - if (this->it != --this->points.end()) { - this->it++; - this->currentPoint++; - return *this->it; - // } else if (this->it == this->points.end() && this->currentPoint != this->points.size()) { - // this->currentPoint++; - // return *this->it; - } - - return Point(); -} - -Point Route::getPreviousPoint() { - if (!this->started) - return Point(); - - if (this->it != this->points.begin()) { - this->it--; - this->currentPoint--; - return *this->it; - } else { - return Point(); - } -} - -RouteInfo Route::getRouteInfo() { - RouteInfo info; - info.totalPoints = this->points.size(); - info.currentPoint = this->currentPoint; - return info; -} diff --git a/lib/Route/route.h b/lib/Route/route.h deleted file mode 100644 index 3aceff3..0000000 --- a/lib/Route/route.h +++ /dev/null @@ -1,237 +0,0 @@ -/** - * @file route.h - * @author Alexander Klein (alex@kleiax.de) - * @brief Contains the class Point and Route - * @version 0.1 - * @date 2022-01-31 - * - * @copyright Copyright (c) 2022 - * - */ - -#ifndef ROUTE_H -#define ROUTE_H - -#include -#include -#include - -#define ROUTE_DEGREE_TO_RADIANT 0.01745 -#define ROUTE_DISTANCE_BETWEEN_LATITUDE 111300 - -/** - * @brief A to handle points on the earth - * - * The points inherits latidue and longitude as doubles - * - */ -class Point{ - public: - /** - * @brief Hold the data longitude and latitude - * - */ - struct Coordinates { - double lon; - double lat; - - bool operator==(const Coordinates rhs) const { - return ( this->lon == rhs.lon ) && ( this->lon == rhs.lon ); - } - }; - - /** - * @brief The Accuracy is set by the constructor - * - */ - enum Accuracy { - none, - fourDigOfCM, - threeDigOfCM, - twoDigOfCM, - oneDigOfCM, - imported - }; - - - /** - * @brief Construct a new Point object - * - * @param lat latitude - * @param lon longitude - * @param horizontalAccuracy mm - * @param coords Coordinates - * @param imported if true than highest accuracy - */ - Point(double lat, double lon, uint32_t horizontalAccuracy = 0, uint32_t creationTime = 0); - Point(int32_t lat, int32_t lon, uint32_t horizontalAccuracy = 0, uint32_t creationTime = 0); - Point(Coordinates coords, uint32_t horizontalAccuracy = 0, uint32_t creationTime = 0); - Point(Coordinates coords, bool imported); - Point(); - - /** - * @brief Checks if to points are equal. - * - * @param rhs - * @return true - * @return false - */ - bool operator==(const Point& rhs) const; - - /** - * @brief Checks if the point is initalized. - * - * @return true - * @return false - */ - bool isInit() const { return this->coordinates.lat + this->coordinates.lon; } - - /** - * @brief Checks if the point is valid. - * - * If the accuracy is higher than zero, true will be returned. - * - * @return true - * @return false - */ - bool isValid() const { return (this->accuracy > 0) ? true : false; } - - /** - * @brief Calculates the distance between to points. - * - * @param point - * @return double meter - */ - double distanceTo(const Coordinates& point) const; - double distanceTo(const Point& point) const; - - /** - * @brief Calculates the course to an other point. - * - * @param point - * @return int16_t degree - */ - int16_t courseTo(const Coordinates& point) const; - int16_t courseTo(const Point& point) const; - - uint32_t getCreationTime() const { return this->creationTime; } - double getLongitude() const { return this->coordinates.lon; } - double getLatitude() const { return this->coordinates.lat; } - Coordinates getCoordinates() const { return this->coordinates; } - - /** - * @brief Get the Accuracy object - * - * The higher the value, the greater the accuracy. - * You can check it by Accuracy. - * - * @return Accuracy - */ - Accuracy getAccuracy() const { return this->accuracy; } - - private: - void init(uint32_t horizontalAccuracy, uint32_t creationTime); - - Accuracy accuracy = Accuracy::none; - Coordinates coordinates; - - uint32_t creationTime = 0; -}; - -/** - * @brief Holds some route information - * - */ -struct RouteInfo{ - /** - * @brief Selected number of Points - */ - uint16_t currentPoint; - - /** - * @brief Total points stored in route - */ - uint16_t totalPoints; -}; - -/** - * @brief A class to manage multiple points - * - * The list of point presents a route which can be driven - */ -class Route { - public: - /** - * @brief Construct a new Route object. - */ - Route(); - - /** - * @brief Adds a point to the list. - * - * @param point - */ - void addPointToRoute(Point point); - - /** - * @brief Delete all points. - * - */ - void clear(); - - /** - * @brief Select the first point as target. - * - * @return Point - */ - Point startRoute(); - - /** - * @brief Select the last point as target. - * - * @return Point - */ - Point endRoute(); - - /** - * @brief Get the next point and set it as target. - * - * @return Point is zero if there are no more Points. - */ - Point getNextPoint(); - - /** - * @brief Get the previous point and set it as target. - * - * @return Point - */ - Point getPreviousPoint(); - - /** - * @brief Get the Route Info object - * - * @return RouteInfo - */ - RouteInfo getRouteInfo(); - - /** - * @brief Get the Started object - * - * The Route will be marked as started when startRoute or - * endRoute has been called. - * - * @return true - * @return false - */ - bool getStarted() const { return this->started; } - - private: - uint16_t currentPoint = 0; - bool started = false; - - std::list points; - std::list::iterator it; - -}; - -#endif // ROUTE_H diff --git a/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp b/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp deleted file mode 100644 index 523e532..0000000 --- a/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp +++ /dev/null @@ -1,254 +0,0 @@ -/** - * @file menuAutopilot.cpp - * @author Alexander Klein (alex@kleiax.de) - * @brief Contains an implementation of the class MenuAutopilot - * @version 0.1 - * @date 2022-02-03 - * - * @copyright Copyright (c) 2022 - * - */ - -#include "menuAutopilot.h" - -void MenuAutopilot::printPage() const { - CourseCorrection correction = this->autopilot->getCourseCorrection(); - UBX_NAV_PVT_data_t* gpsData = this->driveManager->getNavigation()->getUbxData(); - bool navigationStarted = this->autopilot->getState() >= Autopilot::State::NavigationStarted; - - String distanceString = ""; - if (navigationStarted) { - uint16_t distance = 0; - if (correction.distance < 1) { - distance = (uint16_t) (correction.distance * 100); - distanceString.concat(distance); - distanceString.concat("cm"); - } else if (correction.distance < 1000) { - distance = (uint16_t) correction.distance; - distanceString.concat(distance); - distanceString.concat("m"); - } else { - distance = (uint16_t) (correction.distance / 1000); - distanceString.concat(distance); - distanceString.concat("km"); - } - } - - String lineOne = "No information"; - String lineTwo = "available"; - - switch (this->getCurrentPage()) { - case 0: { - lineOne = "Status: "; - lineTwo = ""; - switch (this->autopilot->getState()) { - case Autopilot::State::InsufficientAccuracy : - lineTwo = "Err: LowAccuracy"; - break; - - case Autopilot::State::NoRoute : - lineTwo = "Err: No route"; - break; - - case Autopilot::State::NavigationStarted : - lineTwo = "Nav started"; - break; - - case Autopilot::State::GetToStartPoint : - lineTwo = "Drive to start"; - break; - - case Autopilot::State::SelfDrivingAvailable : - lineTwo = "Autopilot ready"; - break; - - case Autopilot::State::SelfDriving : - lineTwo = "Autopilot active"; - break; - - case Autopilot::State::SelfDrivingRotate : - lineTwo = "Rotating"; - break; - - case Autopilot::State::TargetReached : - lineTwo = "Target reached"; - break; - - default: - lineTwo = "UNKOWN - "; - lineTwo.concat(static_cast(this->autopilot->getState())); - - break; - } - break; - } - - case 1: - if (!navigationStarted) { - lineOne = "Navigation is"; - lineTwo = "not started"; - break; - } - lineOne = "Distance: "; - lineOne.concat(distanceString); - lineTwo = "Turn: "; - lineTwo.concat(correction.correction); - break; - - case 2: - lineOne = "Target waypoint"; - lineTwo = ""; - lineTwo.concat(this->autopilot->getRouteInfo().currentPoint); - lineTwo.concat(" from "); - lineTwo.concat(this->autopilot->getRouteInfo().totalPoints); - break; - - case 3: { - NTRIPClientStates status = this->driveManager->getNavigation()->getNTRIPClient()->getClientState(); - uint8_t carrSoln = gpsData->flags.bits.carrSoln; - lineOne = "GNSS: "; - - if (status == NTRIPClientStates::pushData) - if (carrSoln == 0) - lineOne.concat("None"); - else if (carrSoln == 1) - lineOne.concat("Floating"); - else if (carrSoln == 2) - lineOne.concat("Fixed"); - else - lineOne.concat("UNKNOWN"); - else if (status == NTRIPClientStates::notAvailable) - lineOne.concat("No WiFi"); - else - lineOne.concat("Offline"); - - lineTwo = "hAcc: "; - if (gpsData->fixType) - lineTwo.concat(gpsData->hAcc); - else - lineTwo.concat("0"); - break; - } - - case 4: - if (this->driveManager->getNavigation()->getCalcAzimuthState() == Navigation::CalcAzimuthState::Good - ||this->driveManager->getNavigation()->getCalcAzimuthState() == Navigation::CalcAzimuthState::Super) - { - lineOne = "Calc Azi: "; - lineTwo = "State: "; - lineOne.concat(this->driveManager->getNavigation()->getCalcAzimuth()); - switch (this->driveManager->getNavigation()->getCalcAzimuthState()) { - case Navigation::CalcAzimuthState::Bad : - lineTwo.concat("Bad"); - break; - - case Navigation::CalcAzimuthState::Good : - lineTwo.concat("Good"); - break; - - case Navigation::CalcAzimuthState::Invalid : - lineTwo.concat("Invalid"); - break; - - case Navigation::CalcAzimuthState::Ok : - lineTwo.concat("Ok"); - break; - - case Navigation::CalcAzimuthState::Super : - lineTwo.concat("Super"); - break; - - default: - lineTwo.concat("Unkown"); - break; - } - } else { - lineOne = "Real Azi: "; - lineTwo = ""; - lineOne.concat(this->driveManager->getNavigation()->getAzimuth()); - } - break; - - case 5: - lineOne = "Loop mode is"; - if (this->autopilot->getLoopMode()) - lineTwo = "enabled"; - else - lineTwo = "disabled"; - break; - - case 6: - lineOne = "Freeze target is"; - if (this->targetFreezed) - lineTwo = "activated"; - else - lineTwo = "deactivated"; - break; - - case 7: - lineOne = "MinDisToPoint:"; - lineTwo = "<- "; - lineTwo.concat(this->minDistance); - lineTwo.concat(" ->"); - break; - - default: - this->printDefault(); - return; - } - - this->print(lineOne, lineTwo); -} - -void MenuAutopilot::runCommand() const { - switch (this->getCurrentPage()) { - case 5: - this->autopilot->switchLoopMode(); - break; - - case 6: - if (this->targetFreezed) { - this->targetFreezed = false; - this->driveManager->getNavigation()->freezeTargetPoint(false); - } else { - this->targetFreezed = true; - this->driveManager->getNavigation()->freezeTargetPoint(); - } - break; - - case 7: - this->minDistance = this->driveManager->getNavigation()->increaseMinDistanceToReachPoint(); - break; - - default: - break; - } -} - -void MenuAutopilot::runCommandNo() const { - switch (this->getCurrentPage()) { - case 7: - this->minDistance = this->driveManager->getNavigation()->decreaseMinDistanceToReachPoint(); - break; - - default: - break; - } -} - -void MenuAutopilot::update() { - if (!this->autopilot->shouldUpdate()) - return; - - this->routeInfo = this->autopilot->getRouteInfo(); - this->printMenu(); -} - -void MenuAutopilot::init() { - this->setCountPages(8); - this->driveManager->changeModus(Modi::Autopilot); - this->autopilot = (Autopilot*) this->driveManager->getDriveModiPtr(); - this->routeInfo = this->autopilot->getRouteInfo(); - this->driveManager->getNavigation()->increaseMinDistanceToReachPoint(); - this->minDistance = this->driveManager->getNavigation()->decreaseMinDistanceToReachPoint(); -} diff --git a/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.h b/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.h deleted file mode 100644 index f662459..0000000 --- a/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.h +++ /dev/null @@ -1,59 +0,0 @@ -/** - * @file menuAutopilot.h - * @author Alexander Klein (alex@kleiax.de) - * @brief Contains a class to print informations about the Autopilot - * @version 0.1 - * @date 2022-02-03 - * - * @copyright Copyright (c) 2022 - * - */ - -#ifndef MENU_AUTOPILOT_DRIVE_H -#define MENU_AUTOPILOT_DRIVE_H - -#include "SpecialMenus/driveModi/menuDriveMode.h" - -/** - * @brief A class to print informations about the Autopilot - * - */ -class MenuAutopilot : public MenuDriveMode { - public: - /** - * @brief Construct a new Menu Autopilot object - * - * @param driveManager for MenuDriveMode - */ - MenuAutopilot(DriveManager* driveManager) : MenuDriveMode(driveManager) {} - - /** - * @brief Prints the Information to display and console - * - * The informations are only printed to the display if it - * set. - * - * Changes the DriveModi to Autopilot if it is the first time called - * and save the Autopilot object. - */ - void printPage() const override; - - - /** - * @brief can be called to update shown data - */ - void update() override; - - private: - void init() override; - void runCommand() const override; - void runCommandNo() const override; - - bool mutable targetFreezed = false; - double mutable minDistance; - - Autopilot* autopilot; - RouteInfo routeInfo; -}; - -#endif // MENU_AUTOPILOT_DRIVE_H diff --git a/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp b/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp deleted file mode 100644 index 94da0a9..0000000 --- a/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/** - * @file menuCaptureRoute.cpp - * @author Alexander Klein (alex@kleiax.de) - * @brief Contains an implementation of the class MenuCaptureRoute - * @version 0.1 - * @date 2022-01-31 - * - * @copyright Copyright (c) 2022 - * - */ -#include "menuCaptureRoute.h" - -void MenuCaptureRoute::printPage() const { - RouteInfo routeInfo = this->captureRoute->getRouteInfo(); - UBX_NAV_PVT_data_t* gpsData = this->driveManager->getNavigation()->getUbxData(); - - String lineOne = ""; - String lineTwo = ""; - - switch (this->getCurrentPage()) { - case 0: - lineOne = "Capture Route"; - lineTwo = "You can drive"; - break; - - case 1: - lineOne = "Saved waypoints"; - lineTwo.concat(routeInfo.totalPoints); - break; - - case 2: - lineOne = "Last status:"; - switch (this->captureRoute->getLastStatus()) { - case Navigation::Status::InsufficientAccuracy: - lineTwo = "Poor Accuracy"; - break; - - case Navigation::Status::Updated: - lineTwo = "Point added"; - break; - - case Navigation::Status::Unchanged: - lineTwo = "Point too close"; - break; - - default: - lineTwo = "---"; - break; - } - break; - - case 3: - lineOne = "Distance to last"; - lineTwo = "point: "; - lineTwo.concat(this->captureRoute->getDistanceToLastPoint()); - break; - - case 4: { - NTRIPClientStates status = this->driveManager->getNavigation()->getNTRIPClient()->getClientState(); - lineOne = "NTRIP Client is"; - - if (status == NTRIPClientStates::pushData) - lineTwo = "enabled"; - else if (status == NTRIPClientStates::notAvailable) - lineTwo = "not available"; - else - lineTwo = "disabled"; - break; - } - - case 5: { - lineOne = "Carrier Solution"; - uint8_t carrSoln = gpsData->flags.bits.carrSoln; - if (carrSoln == 0) - lineTwo = "None"; - else if (carrSoln == 1) - lineTwo = "Floating"; - else if (carrSoln == 2) - lineTwo = "Fixed"; - else - lineTwo = "UNKNOWN"; - break; - } - - case 6: - lineOne = "hAccuracy: "; - lineTwo = "Azimuth: "; - lineTwo.concat(this->driveManager->getNavigation()->getAzimuth()); - if (gpsData->fixType) - lineOne.concat(gpsData->hAcc); - else - lineOne.concat("0"); - break; - - case 7: - lineOne = "Current minimal"; - if (this->driveManager->getNavigation()->getMinAccuracy() >= Point::Accuracy::twoDigOfCM) - lineTwo = "accuracy is high"; - else - lineTwo = "accuracy is low"; - break; - - default: - this->printDefault(); - return; - } - - this->print(lineOne, lineTwo); -} - -void MenuCaptureRoute::update() { - if (!this->captureRoute->shouldUpdate()) - return; - this->printMenu(); -} - -void MenuCaptureRoute::runCommand() const { - switch (this->getCurrentPage()) - { - case 7: - if (this->driveManager->getNavigation()->getMinAccuracy() >= Point::Accuracy::twoDigOfCM) - this->driveManager->getNavigation()->setMinAccuracy(Point::Accuracy::none); - else - this->driveManager->getNavigation()->setMinAccuracy(Point::Accuracy::twoDigOfCM); - break; - - default: - break; - } -} - -void MenuCaptureRoute::init() { - this->setCountPages(8); - this->updateDelay = 500; - this->driveManager->changeModus(Modi::CaptureRoute); - this->captureRoute = (CaptureRoute*) this->driveManager->getDriveModiPtr(); - -} diff --git a/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.h b/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.h deleted file mode 100644 index 3f321ea..0000000 --- a/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.h +++ /dev/null @@ -1,53 +0,0 @@ -/** - * @file menuCaptureRoute.h - * @author Alexander Klein (alex@kleiax.de) - * @brief Contains a class to print informations about CaptureRoute - * @version 0.1 - * @date 2022-01-31 - * - * @copyright Copyright (c) 2022 - * - */ -#ifndef MENU_CAPTURE_ROUTE_H -#define MENU_MANUAL_DRIVE_H - -#include "SpecialMenus/driveModi/menuDriveMode.h" - -/** - * @brief A class to print informations about the Autopilot - * - */ -class MenuCaptureRoute : public MenuDriveMode { - public: - /** - * @brief Construct a new Menu Capture Route object - * - * @param driveManager - */ - MenuCaptureRoute(DriveManager* driveManager) : MenuDriveMode(driveManager) {} - - /** - * @brief Prints the Information to display and console - * - * The informations are only printed to the display if it - * set. - * - * Changes the DriveModi to CaptureRoute if it is the first time called - * and save the CaptureRoute object. - */ - void printPage() const override; - - /** - * @brief can be called to update shown data - */ - void update() override; - - void runCommand() const override; - - private: - void init() override; - - CaptureRoute* captureRoute; -}; - -#endif // MENU_MANUAL_DRIVE_H diff --git a/src/driveModi/Modi/Autopilot/autopilot.cpp b/src/driveModi/Modi/Autopilot/autopilot.cpp deleted file mode 100644 index 2b40228..0000000 --- a/src/driveModi/Modi/Autopilot/autopilot.cpp +++ /dev/null @@ -1,250 +0,0 @@ -/** - * @file autopilot.cpp - * @author Alexander Klein (alex@kleiax.de) - * @brief Contains the implementation of the class Autopilot - * @version 0.1 - * @date 2022-02-02 - * - * @copyright Copyright (c) 2022 - * - */ - -#include "driveModi/Modi/Autopilot/autopilot.h" -#include "autopilot.h" - -DirectionChangeSignal::DirectionChangeSignal(Navigation* navigation) { - this->navigation = navigation; - this->action(); -} - -DirectionChangeSignal::~DirectionChangeSignal() { - navigation->disableCalcAzimuth(); -} - -void DirectionChangeSignal::action() { - this->navigation->drivingDirectionChange(); -} - - -Autopilot::Autopilot(MoveControl* moveControl, const ControlPadInput *input, Navigation* navigation) - : ManualControl(moveControl, input) { - this->setInputMode(ManualControl::InputMode::Digital); - this->directionChangeSignal = new DirectionChangeSignal(navigation); - this->setDirectionChangeCallback(this->directionChangeSignal); - this->navigation = navigation; - this->init(); -} - -Autopilot::~Autopilot() { - delete this->directionChangeSignal; - // this->navigation->getNTRIPClient()->setActivated(false); -} - -void Autopilot::run() { - this->routeInfo = this->navigation->getRouteInfo(); - - switch (this->state) { - case State::InsufficientAccuracy: - this->askNavigationForOrder(); - return; - - case State::NoRoute: - return; - - case State::None: - return; - - case State::NavigationStarted: - this->askNavigationForOrder(); - this->checkButtonInput(); - break; - - case State::GetToStartPoint: - ManualControl::run(); - this->askNavigationForOrder(); - if (this->routeInfo.currentPoint >= 2) - this->state = State::SelfDrivingAvailable; - break; - - case State::SelfDrivingAvailable: - ManualControl::run(); - this->askNavigationForOrder(); - this->checkButtonInput(); - break; - - case State::SelfDriving: - this->askNavigationForOrder(); - this->checkButtonInput(); - this->selfDriving(); - break; - - case SelfDrivingRotate: - this->checkButtonInput(); - this->rotate(); - break; - - case State::TargetReached: - if (this->loopMode) - this->restartLoop(); - break; - - default: - break; - } -} - -void Autopilot::restart() { - this->init(); -} - -bool Autopilot::shouldUpdate() { - if (this->updateDisplay) { - this->updateDisplay = false; - return true; - } - return false; -} - -void Autopilot::testRotate(int16_t degree) { - if (!degree) - return; - - this->courseCorrection.correction = degree; - this->beginRotate(); -} - -void Autopilot::init() { - if (this->navigation->startNavigation()) - this->state = State::NavigationStarted; - else - this->state = State::NoRoute; - this->routeInfo = this->navigation->getRouteInfo(); - this->navigation->getNTRIPClient()->setAutoReconnect(true); - - this->lastOrderStatus = this->navigation->getCourseCorrection(this->courseCorrection, true); - - this->courseCorrection.correction = 0; - this->courseCorrection.distance = 0; - this->updateDisplay = true; - - this->maxRotationSpeed = 7; - this->maxForwardSpeed = 1.5; -} - -void Autopilot::drive() { - this->moveControl->setRotationSpeed(0); - if (this->courseCorrection.distance >= this->minRemainingDistance) - this->moveControl->setSpeed(this->maxForwardSpeed); - else - this,moveControl->setSpeed(0); -} - -void Autopilot::beginRotate() { - if (this->state != State::SelfDrivingRotate) { - this->lastState = this->state; - this->state = State::SelfDrivingRotate; - this->rotationAimAzimuth = this->navigation->getAzimuth() + this->courseCorrection.correction; - this->rotationAimAzimuth = Navigation::fixDegree(this->rotationAimAzimuth); - - this->moveControl->setSpeed(0); - if (this->courseCorrection.correction > 0) - this->moveControl->setRotationSpeed(-this->maxRotationSpeed); - else - this->moveControl->setRotationSpeed(this->maxRotationSpeed); - } -} - -void Autopilot::rotate() { - if (abs(this->navigation->getAzimuth() - this->rotationAimAzimuth) < this->maxCourseDeviationBeforeAct) { - this->endRotate(); - return; - } - - if ((abs(this->navigation->getAzimuth() - this->rotationAimAzimuth) < this->maxCourseDeviationBeforeAct * 3) - && - ((this->courseCorrection.correction > 0 - && this->rotationAimAzimuth < this->navigation->getAzimuth()) - || (this->courseCorrection.correction < 0 - && this->rotationAimAzimuth > this->navigation->getAzimuth()))) - { - this->endRotate(); - std::cout << "Autopilot::rotate: Rover rotated too far" << std::endl; - } -} - -void Autopilot::endRotate() { - if (this->state != State::SelfDrivingRotate) - return; - - this->state = this->lastState; - this->navigation->drivingDirectionChange(); - this->moveControl->setRotationSpeed(0); - this->moveControl->emergencyStop(); - this->moveControl->setDrivingStatus(MoveControl::Status::Drive); -} - -void Autopilot::checkButtonInput() { - if (ControlPadButton::isControlPadButtonPressed(this->input, ControlPadButton::PadButton::Action) - && millis() - this->lastAutopilotChangeMillis > this->autopilotChangeDelayMillis) { - - if (this->state == State::SelfDrivingAvailable) - this->state = State::SelfDriving; - else if (this->state == State::SelfDriving || this->state == State::SelfDrivingRotate) - this->state = State::SelfDrivingAvailable; - else if (this->state == State::NavigationStarted) - this->state = State::GetToStartPoint; - this->updateDisplay = true; - this->lastAutopilotChangeMillis = millis(); - } -} - -void Autopilot::askNavigationForOrder() { - this->lastOrderStatus = this->navigation->getCourseCorrection(this->courseCorrection); - switch (this->lastOrderStatus) { - case Navigation::Status::Complete: - this->state = State::TargetReached; - this->moveControl->setSpeed(0); - this->moveControl->setRotationSpeed(0); - break; - - case Navigation::Status::InsufficientAccuracy: - if (this->state == State::InsufficientAccuracy) - break; - this->lastState = this->state; - this->state = State::InsufficientAccuracy; - this->moveControl->setSpeed(0); - this->moveControl->setRotationSpeed(0); - break; - - case Navigation::Status::Unchanged: - if (this->state == State::InsufficientAccuracy) - this->state = this->lastState; - break; - - case Navigation::Status::Updated: - if (this->state == State::InsufficientAccuracy) - this->state = this->lastState; - break; - - default: - break; - } -} - -void Autopilot::selfDriving() { - if (this->state != State::SelfDriving) - return; - - if (abs(this->courseCorrection.correction) >= this->maxCourseDeviationBeforeAct) - this->beginRotate(); - else - this->drive(); -} - -void Autopilot::restartLoop() { - this->navigation->startNavigation(); - this->state = State::SelfDriving; - this->routeInfo = this->navigation->getRouteInfo(); - this->lastOrderStatus = this->navigation->getCourseCorrection(this->courseCorrection, true); - this->updateDisplay = true; -} diff --git a/src/driveModi/Modi/Autopilot/autopilot.h b/src/driveModi/Modi/Autopilot/autopilot.h deleted file mode 100644 index c3697f6..0000000 --- a/src/driveModi/Modi/Autopilot/autopilot.h +++ /dev/null @@ -1,134 +0,0 @@ -/** - * @file autopilot.h - * @author Alexander Klein (alex@kleiax.de) - * @brief Contains a class which use the navigate class to drive automaticaly - * @version 0.1 - * @date 2022-02-02 - * - * @copyright Copyright (c) 2022 - * - */ - -#ifndef AUTOPILOT_H -#define AUTOPILOT_H - - -#include "navigation.h" -#include "moveControl.h" -#include "driveModi/Modi/ManualControl/manualControl.h" - -class DirectionChangeSignal : public DirectionChangeWrapper { - public: - DirectionChangeSignal(Navigation* navigation); - ~DirectionChangeSignal(); - void action() override; - - private: - Navigation* navigation; -}; - -/** - * @brief This class use the navigate class to drive automaticaly - * - * This class get the information from the navigate class. When an - * object of this class is constructed the rover can be driven manually. - * When the Rover is near to the first position of the Route, you can - * switch to automatic drive. - * - */ -class Autopilot : public ManualControl { - public: - enum State { - InsufficientAccuracy = -2, - NoRoute = -1, - None = 0, - NavigationStarted, - GetToStartPoint, - SelfDrivingAvailable, - SelfDriving, - SelfDrivingRotate, - TargetReached - }; - - /** - * @brief Construct a new Autopilot object - * - * @param moveControl for ManualControl - * @param navigation for route instructions - */ - Autopilot(MoveControl* moveControl, const ControlPadInput *input, Navigation* navigation); - - /** - * @brief Destroy the Autopilot object - * - * Disconnect the NTRIP-Client - */ - ~Autopilot(); - - void restart(); - - /** - * @brief Get the Route Info object - * - * @return RouteInfo - */ - RouteInfo getRouteInfo() const { return this->routeInfo; } - - /** - * @brief Get the Course Correction object - * - * @return CourseCorrection - */ - CourseCorrection getCourseCorrection() const { return this->courseCorrection; } - - /** - * @brief Get the State object - * - * @return State - */ - State getState() const { return this->state; } - - /** - * @brief Tells if there are new informations to display - * - * @return true - * @return false - */ - bool shouldUpdate(); - void testRotate(int16_t degree); - void endRotate(); - void switchLoopMode() { this->loopMode = !this->loopMode; } - bool getLoopMode() const { return this->loopMode; } - - private: - void init(); - void drive(); - void beginRotate(); - void rotate(); - void run() override; - void checkButtonInput(); - void askNavigationForOrder(); - void selfDriving(); - void restartLoop(); - - Navigation* navigation; - CourseCorrection courseCorrection; - RouteInfo routeInfo; - State state = State::None; - State lastState = State::None; - Navigation::Status lastOrderStatus; - DirectionChangeSignal* directionChangeSignal; - - bool updateDisplay = false; - bool loopMode = false; - - uint8_t maxCourseDeviationBeforeAct = 5; - uint16_t autopilotChangeDelayMillis = 500; - uint32_t lastAutopilotChangeMillis = 0; - - int16_t rotationAimAzimuth; - - double minRemainingDistance = 0.25; -}; - -#endif // AUTOPILOT_H diff --git a/src/driveModi/Modi/CaptureRoute/captureRoute.cpp b/src/driveModi/Modi/CaptureRoute/captureRoute.cpp deleted file mode 100644 index b334e19..0000000 --- a/src/driveModi/Modi/CaptureRoute/captureRoute.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @file captureRoute.cpp - * @author Alexander Klein (alex@kleiax.de) - * @brief Contains the implementation of the class CaptureRoute - * @version 0.1 - * @date 2022-02-15 - * - * @copyright Copyright (c) 2022 - * - */ - -#include "driveModi/Modi/CaptureRoute/captureRoute.h" - -CaptureRoute::CaptureRoute(MoveControl* moveControl, const ControlPadInput *input, Navigation* navigation) - : ManualControl(moveControl, input) { - this->navigation = navigation; - this->navigation->getRoute()->clear(); - this->navigation->getNTRIPClient()->setAutoReconnect(true); - this->routeInfo = navigation->getRouteInfo(); -} - -CaptureRoute::~CaptureRoute() { - // this->navigation->getNTRIPClient()->setActivated(false); -} - -void CaptureRoute::run() { - ManualControl::run(); - if (ControlPadButton::isControlPadButtonPressed(this->input, ControlPadButton::PadButton::Action)) { - this->status = this->navigation->addCurrentPosToRoute(); - if (this->status == Navigation::Status::Updated) { - this->lastSavedPoint = this->navigation->getCurrentPosition(); - this->routeInfo = navigation->getRouteInfo(); - this->updateDisplay = true; - } - } -} - -double CaptureRoute::getDistanceToLastPoint() const { - if (!this->lastSavedPoint.isInit()) - return 0; - return this->lastSavedPoint.distanceTo(this->navigation->getCurrentPosition()); -} - -bool CaptureRoute::shouldUpdate() { - if (this->updateDisplay) { - this->updateDisplay = false; - return true; - } - return false; -} diff --git a/src/driveModi/Modi/CaptureRoute/captureRoute.h b/src/driveModi/Modi/CaptureRoute/captureRoute.h deleted file mode 100644 index c262a98..0000000 --- a/src/driveModi/Modi/CaptureRoute/captureRoute.h +++ /dev/null @@ -1,85 +0,0 @@ -/** - * @file captureRoute.h - * @author Alexander Klein (alex@kleiax.de) - * @brief Contains a class to capture a driven route - * @version 0.1 - * @date 2022-02-15 - * - * @copyright Copyright (c) 2022 - * - */ - -#ifndef CAPTURE_ROUTE_H -#define CAPTURE_ROUTE_H - -#include - -#include "driveModi/Modi/ManualControl/manualControl.h" -#include "navigation.h" - -/** - * @brief A class to capture a driven class - * - * This class inherits ManualControl so you can drive - * normally as in ManualControl. If GPS signal is valid - * you can add a Point everytime you want. - * - */ -class CaptureRoute : public ManualControl { - public: - /** - * @brief Construct a new Capture Route object - * - * @param moveControl for ManualControl - * @param navigation to add Points - */ - CaptureRoute(MoveControl* moveControl, const ControlPadInput *input, Navigation* navigation); - - /** - * @brief Destroy the Capture Route object - * - * Disconnect the NTRIP-Client - */ - ~CaptureRoute(); - - // /** - // * @brief Get the Navigation object - // * - // * @return Navigation* - // */ - // Navigation* getNavigation() const { return this->navigation; } - - /** - * @brief Get the Route Info object - * - * @return RouteInfo - */ - RouteInfo getRouteInfo() const { return this->routeInfo; } - Navigation::Status getLastStatus() const { return this->status; } - - /** - * @brief Get the distance to the last saved oint - * - * @return double in meters - */ - double getDistanceToLastPoint() const; - - /** - * @brief Tells if there are new informations to display - * - * @return true - * @return false - */ - bool shouldUpdate(); - private: - void run() override; - - Navigation* navigation; - RouteInfo routeInfo; - Point lastSavedPoint; - Navigation::Status status = Navigation::Status::Complete; - - bool updateDisplay = false; -}; - -#endif // CAPTURE_ROUTE_H From f78804d836b7f5cbed26e09bb4f3ef7b6f96e4a1 Mon Sep 17 00:00:00 2001 From: Alexander Klein Date: Mon, 4 Sep 2023 14:13:14 +0200 Subject: [PATCH 3/7] first build --- lib/Sensors/sensorData.cpp | 14 - lib/Sensors/sensorData.h | 13 - src/SpecialMenus/GPS/menuGPS.cpp | 37 +-- src/SpecialMenus/GPS/menuGPS.h | 3 - src/SpecialMenus/Route/menuRoute.cpp | 306 --------------------- src/SpecialMenus/Route/menuRoute.h | 158 ----------- src/SpecialMenus/Route/menuRoutePoints.cpp | 76 ----- src/SpecialMenus/Route/menuRoutePoints.h | 50 ---- src/driveModi/Modi/TestMode/testMode.cpp | 6 +- src/driveModi/Modi/TestMode/testMode.h | 7 +- src/driveModi/driveManager.cpp | 23 +- src/driveModi/driveManager.h | 18 -- src/main.cpp | 11 - 13 files changed, 11 insertions(+), 711 deletions(-) delete mode 100644 src/SpecialMenus/Route/menuRoute.cpp delete mode 100644 src/SpecialMenus/Route/menuRoute.h delete mode 100644 src/SpecialMenus/Route/menuRoutePoints.cpp delete mode 100644 src/SpecialMenus/Route/menuRoutePoints.h diff --git a/lib/Sensors/sensorData.cpp b/lib/Sensors/sensorData.cpp index 5ca4809..adde8ca 100644 --- a/lib/Sensors/sensorData.cpp +++ b/lib/Sensors/sensorData.cpp @@ -20,20 +20,6 @@ SensorData::SensorData() { this->loopDelay = 50; } -SensorData::~SensorData() { - if (this->ntripClient) - delete this->ntripClient; -} - -void SensorData::enableNtrip(String host, uint16_t port, String mountPoint, String user, String password) { - this->ntripClient = new NTRIPClient(this->gnss, host.c_str(), port, mountPoint.c_str(), user.c_str(), password.c_str()); - this->ntripClient->gpsConfiguration(); - this->ntripClient->loop(); - this->ntripClient->setActivated(false); - this->isNtripInit = true; - this->addChildComponent(this->ntripClient); -} - void SensorData::enableGnss(SPIClass* spiPort, uint8_t csPin) { this->gnss = new SFE_UBLOX_GNSS(); if (this->gnss->begin(*spiPort, csPin, 4000000) == false) { diff --git a/lib/Sensors/sensorData.h b/lib/Sensors/sensorData.h index fb4abe1..52bac26 100644 --- a/lib/Sensors/sensorData.h +++ b/lib/Sensors/sensorData.h @@ -22,7 +22,6 @@ #include // Gyroskop #include "calcAzimuth.h" -#include "ntripClient.h" #include "point.h" class Sensors; @@ -30,9 +29,7 @@ class Sensors; class SensorData : public Component { public: SensorData(); - ~SensorData(); - void enableNtrip(String host, uint16_t port, String mountPoint, String user, String password); void enableGnss(SPIClass* spiPort, uint8_t csPin); void enableGnss(); void enableRealCompass(); @@ -50,7 +47,6 @@ class SensorData : public Component { CalcAzimuth* getCalcCompass() const { return this->calcCompass; } QMC5883LCompass* getRealCompass() const { return this->realCompass; } - NTRIPClient* getNtripClient() const { return this->ntripClient; } // static /** @@ -71,19 +67,10 @@ class SensorData : public Component { QMC5883LCompass* realCompass = nullptr; CalcAzimuth* calcCompass = nullptr; SFE_UBLOX_GNSS* gnss = nullptr; - NTRIPClient* ntripClient = nullptr; UBX_NAV_PVT_data_t* gnssData; Point currentPosition; - char* host; - char* mountPoint; - char* user; - char* password; - - bool isNtripInit = false; - - uint16_t port; int16_t realAzimuth = INT16_MAX; int16_t calcAzimuth = INT16_MAX; diff --git a/src/SpecialMenus/GPS/menuGPS.cpp b/src/SpecialMenus/GPS/menuGPS.cpp index 878fd13..f255155 100644 --- a/src/SpecialMenus/GPS/menuGPS.cpp +++ b/src/SpecialMenus/GPS/menuGPS.cpp @@ -14,7 +14,6 @@ MenuGPS::MenuGPS(SensorData* sensorData) : MenuInformationSites(10) { this->sensorData = sensorData; - // this->ntripClient = this->navigation->getNTRIPClient(); } void MenuGPS::printPage() const { @@ -65,20 +64,7 @@ void MenuGPS::printPage() const { break; - case 3: { - // NTRIPClientStates status = this->ntripClient->getClientState(); - // lineOne = "NTRIP Client is"; - - // if (status == NTRIPClientStates::pushData) - // lineTwo = "enabled"; - // else if (status == NTRIPClientStates::notAvailable) - // lineTwo = "not available"; - // else - // lineTwo = "disabled"; - } - break; - - case 4: + case 3: lineOne = "Fix type:"; if (fixType == 0) lineTwo = "None"; @@ -96,7 +82,7 @@ void MenuGPS::printPage() const { lineTwo = "UNKNOWN"; break; - case 5: { + case 4: { lineOne = "Carrier Solution"; uint8_t carrSoln = gpsData->flags.bits.carrSoln; if (carrSoln == 0) @@ -110,7 +96,7 @@ void MenuGPS::printPage() const { } break; - case 6: + case 5: lineOne = "Hrizntl Accuracy"; if (fixType) { lineTwo = ""; @@ -119,7 +105,7 @@ void MenuGPS::printPage() const { lineTwo = "0"; break; - case 7: + case 6: lineOne = "magDec: "; lineTwo = "magAcc: "; if (fixType) { @@ -131,7 +117,7 @@ void MenuGPS::printPage() const { } break; - case 8: + case 7: lineOne = "Azimuth: "; lineTwo = ""; lineTwo.concat(this->sensorData->getRealAzimuth()); @@ -144,16 +130,3 @@ void MenuGPS::printPage() const { this->print(lineOne, lineTwo); } - -void MenuGPS::runCommand() const { - switch (this->getCurrentPage()) { - case 3: { - // // std::cout << "MenuGPS::runCommand " << this->ntripClient->getClientState() << std::endl; - // if (this->ntripClient->getClientState() == NTRIPClientStates::pushData) - // this->ntripClient->setActivated(false); - // else if (this->ntripClient->getClientState() != NTRIPClientStates::notAvailable) - // this->ntripClient->setActivated(true); - } - break; - } -} diff --git a/src/SpecialMenus/GPS/menuGPS.h b/src/SpecialMenus/GPS/menuGPS.h index e88f6fe..902c673 100644 --- a/src/SpecialMenus/GPS/menuGPS.h +++ b/src/SpecialMenus/GPS/menuGPS.h @@ -16,7 +16,6 @@ #include "menuInformationSites.h" #include "sensorData.h" -#include "ntripClient.h" /** * @brief A class to print informations about the GPS object @@ -33,9 +32,7 @@ class MenuGPS : public MenuInformationSites { private: void printPage() const override; - void runCommand() const override; - // NTRIPClient* ntripClient; SensorData* sensorData; }; diff --git a/src/SpecialMenus/Route/menuRoute.cpp b/src/SpecialMenus/Route/menuRoute.cpp deleted file mode 100644 index 772c23a..0000000 --- a/src/SpecialMenus/Route/menuRoute.cpp +++ /dev/null @@ -1,306 +0,0 @@ -/** - * @file menuRoute.cpp - * @author Alexander Klein (alex@kleiax.de) - * @brief Contains the implementation of the classes MenuActionRoute, MenuRoute and MenuRouteWrapper. - * @version 0.1 - * @date 2022-12-28 - * - * @copyright Copyright (c) 2022 - * - */ - -#include "menuRoute.h" - -MenuActionRoute::MenuActionRoute(MenuRoute* menuRoute, DataFunction dataFunction) { - this->menuRoute = menuRoute; - this->dataFunction = dataFunction; -} - -void MenuActionRoute::action() { - (this->menuRoute->*this->dataFunction)(0); -} - -MenuRoute::MenuRoute(Route* route) { - this->route = route; -} - -MenuRoute::~MenuRoute() { - if (isInit) - delete this->mainMenu; -} - -void MenuRoute::printMenu() { - if (!this->isInit) { - this->isInit = true; - this->init(); - } - - this->mainMenu->printMenu(); -} - - -void MenuRoute::down() { - if (blockInput) return; - this->mainMenu->down(); -} - -void MenuRoute::up() { - if (blockInput) return; - this->mainMenu->up(); -} - -void MenuRoute::right() { - if (blockInput) return; - this->mainMenu->right(); -} - -void MenuRoute::left() { - if (blockInput) return; - if (this->mainMenu->isInSubmenu()) - this->mainMenu->left(); - else - this->parentMenu->printMenu(); -} - -void MenuRoute::yes() { - if (blockInput) return; - this->mainMenu->yes(); -} - -void MenuRoute::no() { - if (blockInput) return; - if (this->mainMenu->isInSubmenu()) - this->mainMenu->no(); - else - this->left(); -} - - -void MenuRoute::init() { - // auto dummy = []() { - // std::cout << "Dummy in Action" <mainMenu = new Menu; - MenuRoutePoints* pointsMenu = new MenuRoutePoints(this->route); - - this->mainMenu->setLcd(this->lcd); - pointsMenu->setLcd(this->lcd); - - MenuIntInput* importWrapper = new MenuIntInput(1, new MenuRouteWrapper(this, &MenuRoute::importRoute)); - MenuIntInput* exportWrapper = new MenuIntInput(1, new MenuRouteWrapper(this, &MenuRoute::exportRoute)); - MenuIntInput* deleteWrapper = new MenuIntInput(1, new MenuRouteWrapper(this, &MenuRoute::deleteRoute)); - MenuActionRoute* clearWrapper = new MenuActionRoute(this, &MenuRoute::clearRoute); - - importWrapper->setLcd(this->lcd); - importWrapper->setMinMax(0, 100); - importWrapper->setPrintParentMenu(false); - importWrapper->setEntry(0, "Import Route"); - - exportWrapper->setLcd(this->lcd); - exportWrapper->setMinMax(0, 100); - exportWrapper->setPrintParentMenu(false); - exportWrapper->setEntry(0, "Export Route"); - - deleteWrapper->setLcd(this->lcd); - deleteWrapper->setMinMax(0, 100); - deleteWrapper->setPrintParentMenu(false); - deleteWrapper->setEntry(0, "Delete Route"); - - this->mainMenu->addEntry(new MenuAction("Points", pointsMenu)); - this->mainMenu->addEntry(new MenuAction("Clear", clearWrapper)); - this->mainMenu->addEntry(new MenuAction("Import", importWrapper)); - this->mainMenu->addEntry(new MenuAction("Export", exportWrapper)); - this->mainMenu->addEntry(new MenuAction("Delete", deleteWrapper)); -} - -void MenuRoute::importRoute(uint8_t routeNumber) { - this->blockInput = true; - - String lineOne = ""; - String lineTwo = ""; - - if (WiFi.status() != WL_CONNECTED) { - lineOne = "Not connected to"; - lineTwo = "the WiFi."; - this->print(lineOne, lineTwo); - this->blockInput = false; - return; - } - - if (ESP.getMaxAllocHeap() < JSON_DOCUMENT_SIZE_ROUTE) { - lineOne = "Not enough mem"; - lineTwo = "for Json obj"; - this->print(lineOne, lineTwo); - this->blockInput = false; - return; - } - - WiFiClient client; - HTTPClient http; - DynamicJsonDocument doc(JSON_DOCUMENT_SIZE_ROUTE); - - String host = "http://rover.kleiax.de/api/"; - host.concat(routeNumber); - http.begin(client, host); - int httpResponseCode = http.GET(); - - lineOne = "Import complete"; - lineTwo = "Code: "; - - if (httpResponseCode == 202) - deserializeJson(doc, http.getStream()); - else - lineOne = "HTTP Error"; - - lineTwo.concat(httpResponseCode); - this->print(lineOne, lineTwo); - - if (httpResponseCode <= 0) { - this->blockInput = false; - return; - } - - uint16_t totalPoints = doc["amountPoints"]; - - this->route->clear(); - for (uint16_t i = 0; i < totalPoints; i++) { - Point::Coordinates coords; - coords.lat = doc["points"][i][0].as(); - coords.lon = doc["points"][i][1].as(); - this->route->addPointToRoute(Point(coords, true)); - } - - this->blockInput = false; - http.end(); -} - -void MenuRoute::exportRoute(uint8_t routeNumber) { - this->blockInput = true; - uint16_t totalPoints = this->route->getRouteInfo().totalPoints; - - String lineOne = ""; - String lineTwo = ""; - - if (WiFi.status() != WL_CONNECTED) { - lineOne = "Not connected to"; - lineTwo = "the WiFi."; - this->print(lineOne, lineTwo); - this->blockInput = false; - return; - } - - if (ESP.getMaxAllocHeap() < JSON_DOCUMENT_SIZE_ROUTE) { - lineOne = "Not enough mem"; - lineTwo = "for Json obj"; - this->print(lineOne, lineTwo); - this->blockInput = false; - return; - } - - DynamicJsonDocument doc(JSON_DOCUMENT_SIZE_ROUTE); - doc["number"] = routeNumber; - doc["amountPoints"] = totalPoints; - - Point::Coordinates coords = this->route->startRoute().getCoordinates(); - doc["points"][0][0] = coords.lat; - doc["points"][0][1] = coords.lon; - for (uint16_t i = 1; i < totalPoints; i++) { - coords = this->route->getNextPoint().getCoordinates(); - doc["points"][i][0] = coords.lat; - doc["points"][i][1] = coords.lon; - } - String jsonData; - serializeJson(doc, jsonData); - - WiFiClient client; - HTTPClient http; - - http.begin(client, "http://rover.kleiax.de/api/"); - http.addHeader("Content-Type", "application/json"); - int httpResponseCode = http.POST(jsonData); - - if (httpResponseCode == 201) - lineOne = "Export complete"; - else - lineOne = "HTTP Error"; - lineTwo = "Code: "; - lineTwo.concat(httpResponseCode); - this->print(lineOne, lineTwo); - this->blockInput = false; - - http.end(); -} - -void MenuRoute::deleteRoute(uint8_t routeNumber) { - this->blockInput = true; - - String lineOne = ""; - String lineTwo = ""; - - if (WiFi.status() != WL_CONNECTED) { - lineOne = "Not connected to"; - lineTwo = "the WiFi."; - this->print(lineOne, lineTwo); - this->blockInput = false; - return; - } - - if (ESP.getMaxAllocHeap() < JSON_DOCUMENT_SIZE_ROUTE) { - lineOne = "Not enough mem"; - lineTwo = "for Json obj"; - this->print(lineOne, lineTwo); - this->blockInput = false; - return; - } - - WiFiClient client; - HTTPClient http; - DynamicJsonDocument doc(JSON_DOCUMENT_SIZE_ROUTE); - - String host = "http://rover.kleiax.de/api/"; - host.concat(routeNumber); - http.begin(client, host); - int httpResponseCode = http.sendRequest("DELETE"); - - lineOne = "Delete complete"; - lineTwo = "Code: "; - - if (httpResponseCode == 202) - deserializeJson(doc, http.getStream()); - else - lineOne = "HTTP Error"; - - lineTwo.concat(httpResponseCode); - this->print(lineOne, lineTwo); - - this->blockInput = false; - http.end(); -} - -void MenuRoute::clearRoute(uint8_t none) { - this->route->clear(); - this->print("Currente route", "deleted..."); -} - -MenuRouteWrapper::MenuRouteWrapper(MenuRoute* menuRoute, DataFunction dataFunction) { - this->menuRoute = menuRoute; - this->dataFunction = dataFunction; -} - -void MenuRouteWrapper::action(int16_t* values, uint8_t length) { - if (length < 1) { - std::cout << "Error in MenuRouteWrapper::action" << std::endl; - return; - } - - if (values[0] < 0) - values[0] = 0; - - if (values[0] > UINT8_MAX) - values[0] = UINT8_MAX; - - (this->menuRoute->*this->dataFunction)(values[0]); -} - - diff --git a/src/SpecialMenus/Route/menuRoute.h b/src/SpecialMenus/Route/menuRoute.h deleted file mode 100644 index b8cdae8..0000000 --- a/src/SpecialMenus/Route/menuRoute.h +++ /dev/null @@ -1,158 +0,0 @@ -/** - * @file menuRoute.h - * @author Alexander Klein (alex@kleiax.de) - * @brief Contains a classes to handles routes with the user input. - * @version 0.1 - * @date 2022-12-28 - * - * @copyright Copyright (c) 2022 - * - */ - -#ifndef MENU_ROUTE_H -#define MENU_ROUTE_H - -#include -#include -#include -#include - -#include "route.h" -#include "menu.h" -#include "menuControl.h" -#include "menuIntInput.h" -#include "menuRoutePoints.h" - -#define JSON_DOCUMENT_SIZE_ROUTE 4096 - -class MenuRoute; -typedef void (MenuRoute::*DataFunction)(uint8_t); - -/** - * @brief MenuActionWrapper to call DataFunctions - * - * This class should be used to call importRoute, - * exportRoute and clearRoute over the Menu. - */ -class MenuActionRoute : public MenuActionWrapper { - public: - /** - * @brief Construct a new Menu Action Route object - * - * @param menuRoute - * @param dataFunction like exportRoute - */ - MenuActionRoute(MenuRoute* menuRoute, DataFunction dataFunction); - - /** - * @brief Runs the given DataFunction - */ - void action() override; - - private: - MenuRoute* menuRoute; - DataFunction dataFunction; -}; - -/** - * @brief Handles routes - * - * With this menu the user can import, export and delete routes. - */ -class MenuRoute : public MenuControl { - public: - /** - * @brief Construct a new Menu Route object - * - * @param route - */ - MenuRoute(Route* route); - ~MenuRoute(); - - /** - * @brief Prints the last informations - * - * On first call this function calls the init function. - * On every call this functions call the printMenu function from - * the mainMenu of this class. - */ - void printMenu() override; - - /** - * @name User Inputs - * @brief Inputs given by the parentMenu - */ - ///@{ - void down() override; - void up() override; - void right() override; - void left() override; - void yes() override; - void no() override; - ///@} - - /** - * @brief Import a Route. - * - * The functions tries to pull the given route id from the RoverApi. - * - * @param routeNumber id - */ - void importRoute(uint8_t routeNumber); - - /** - * @brief Export a Route. - * - * The functions tries to push the current route to the RoverApi. - * - * @param routeNumber id - */ - void exportRoute(uint8_t routeNumber); - - void deleteRoute(uint8_t routeNumber); - - /** - * @brief Delete the current Route. - * - * @param none this param is not be used. - */ - void clearRoute(uint8_t none); - - private: - void init(); - - Route* route; - Menu* mainMenu; - - bool isInit = false; - bool blockInput = false; -}; - -/** - * @brief MenuRouteWrapper to call DataFunctions with numeric user input - * - */ -class MenuRouteWrapper : public MenuIntInputWrapper { - public: - /** - * @brief Construct a new Menu Route Wrapper object. - * - * @param menuRoute - * @param dataFunction - */ - MenuRouteWrapper(MenuRoute* menuRoute, DataFunction dataFunction); - - /** - * @brief Calls the given DataFunction. - * - * @param values The value to be given to the DataFunction. - * @param length Number of values, should be 1. - */ - void action(int16_t* values, uint8_t length) override; - - private: - MenuRoute* menuRoute; - DataFunction dataFunction = nullptr; -}; - -#endif // MENU_ROUTE_H diff --git a/src/SpecialMenus/Route/menuRoutePoints.cpp b/src/SpecialMenus/Route/menuRoutePoints.cpp deleted file mode 100644 index 3fd14f4..0000000 --- a/src/SpecialMenus/Route/menuRoutePoints.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/** - * @file menuRoutePoints.cpp - * @author Alexander Klein (alex@kleiax.de) - * @brief Contains the implementation of the class MenuRoutePoints. - * @version 0.1 - * @date 2022-12-28 - * - * @copyright Copyright (c) 2022 - * - */ - -#include "menuRoutePoints.h" - -MenuRoutePoints::MenuRoutePoints(Route *route) : MenuInformationSites() { - this->route = route; -} - -void MenuRoutePoints::init() { - uint16_t amountPoints = this->route->getRouteInfo().totalPoints; - if (amountPoints > UINT8_MAX) - this->error = true; - else - this->setCountPages(amountPoints); -} - -void MenuRoutePoints::printPage() const { - uint8_t currentPage = this->getCurrentPage(); - if (this->lastPageNumber == currentPage) - return; - - String lineOne = "N "; - String lineTwo = "E "; - - if (this->error) { - lineOne = "Error: To much"; - lineTwo = "points are given"; - this->print(lineOne, lineTwo); - return; - } - - RouteInfo info = this->route->getRouteInfo(); - if (info.totalPoints == 0) { - lineOne = "No Points are"; - lineTwo = "available"; - this->print(lineOne, lineTwo); - return; - } - - Point p; - if (currentPage == 0) - p = this->route->startRoute(); - else if (this->lastPageNumber - 1 == currentPage) - p = this->route->getPreviousPoint(); - else if (this->lastPageNumber + 1 == currentPage) - p = this->route->getNextPoint(); - else if (currentPage == this->getCountPages() - 1) - p = this->route->endRoute(); - else - std::cout << "Error in: MenuRoutePoints::printPage()" << std::endl; - - char buf[20]; - char* string; - - info = this->route->getRouteInfo(); - string = dtostrf(p.getLatitude(), 9, 7, buf); - lineOne.concat(string); - lineOne.concat(" "); - lineOne.concat(info.currentPoint); - // lineOne.concat(currentPage); - string = dtostrf(p.getLongitude(), 9, 7, buf); - lineTwo.concat(string); - lineTwo.concat(" "); - lineTwo.concat(info.totalPoints); - // std::cout << "MenuRoutePoints::printPage currentPage: " << (int) currentPage << std::endl; - this->print(lineOne, lineTwo); -} diff --git a/src/SpecialMenus/Route/menuRoutePoints.h b/src/SpecialMenus/Route/menuRoutePoints.h deleted file mode 100644 index 58b60c7..0000000 --- a/src/SpecialMenus/Route/menuRoutePoints.h +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @file menuRoutePoints.h - * @author Alexander Klein (alex@kleiax.de) - * @brief Contains a class to print the coordinates of a Route. - * @version 0.1 - * @date 2022-12-28 - * - * @copyright Copyright (c) 2022 - * - */ - -#ifndef MENU_ROUTE_POINTS_H -#define MENU_ROUTE_POINTS_H - -#include "navigation.h" -#include "route.h" -#include "menuInformationSites.h" - -/** - * @brief Prints coordinates of Route side by side. - * - */ -class MenuRoutePoints : public MenuInformationSites { - public: - /** - * @brief Construct a new Menu Route Points object - * - * @param route - */ - MenuRoutePoints(Route *route); - - /** - * @brief Configure the base class MenuInformationSites - * - * Set the amount of pages. - */ - void init () override; - - /** - * @brief Prints the the coordinates of the current Point. - */ - void printPage() const override; - - private: - Route* route; - bool error = false; - -}; - -#endif // MENU_ROUTE_POINTS_H diff --git a/src/driveModi/Modi/TestMode/testMode.cpp b/src/driveModi/Modi/TestMode/testMode.cpp index 921e45e..7bd13a0 100644 --- a/src/driveModi/Modi/TestMode/testMode.cpp +++ b/src/driveModi/Modi/TestMode/testMode.cpp @@ -10,10 +10,8 @@ */ #include "testMode.h" -TestMode::TestMode(DriveModiParams params, Navigation* navigation) - : DriveModi(params) { - this->navigation = navigation; -} +TestMode::TestMode(DriveModiParams params) + : DriveModi(params) {} TestMode::~TestMode() { this->moveControl->setDrivingStatus(MoveControl::Status::Stop); diff --git a/src/driveModi/Modi/TestMode/testMode.h b/src/driveModi/Modi/TestMode/testMode.h index abfe21f..844d9d4 100644 --- a/src/driveModi/Modi/TestMode/testMode.h +++ b/src/driveModi/Modi/TestMode/testMode.h @@ -14,7 +14,6 @@ #include #include "moveControl.h" -#include "navigation.h" #include "driveModi/driveModi.h" @@ -41,10 +40,9 @@ class TestMode : public DriveModi { /** * @brief Construct a new Test Mode object * - * @param moveControl - * @param navigation + * @param moveControl */ - TestMode(DriveModiParams params, Navigation* navigation); + TestMode(DriveModiParams params); ~TestMode(); bool drive(int16_t cm = 0, int16_t degree = 0); @@ -106,7 +104,6 @@ class TestMode : public DriveModi { void run() override; bool engineInit(int16_t powerPercentage, int16_t seconds); - Navigation* navigation; Maneuver maneuver = Maneuver::None; int16_t maneuverValueOne = 0; int16_t maneuverValueTwo = 0; diff --git a/src/driveModi/driveManager.cpp b/src/driveModi/driveManager.cpp index 5d7dc0f..bce31f0 100644 --- a/src/driveModi/driveManager.cpp +++ b/src/driveModi/driveManager.cpp @@ -25,10 +25,6 @@ DriveManager::DriveManager(DriveModiParams params){ this->init(); } -DriveManager::~DriveManager() { - delete this->navigation; -} - void DriveManager::changeModus(Modi modus) { this->currentModus = modus; @@ -36,8 +32,6 @@ void DriveManager::changeModus(Modi modus) { this->removeChildComponent(this->currentModusPtr); delete this->currentModusPtr; } - //Reset Route to first point - this->navigation->startNavigation(); switch (modus) { case Modi::Off: @@ -49,18 +43,8 @@ void DriveManager::changeModus(Modi modus) { } break; - case Modi::CaptureRoute: { - this->currentModusPtr = new CaptureRoute(this->driveModiParams, this->navigation); - } - break; - - case Modi::Autopilot: { - this->currentModusPtr = new Autopilot(this->driveModiParams, this->navigation); - } - break; - case Modi::TestMode: { - this->currentModusPtr = new TestMode(driveModiParams, this->navigation); + this->currentModusPtr = new TestMode(driveModiParams); } break; @@ -73,11 +57,8 @@ void DriveManager::changeModus(Modi modus) { this->addChildComponent(this->currentModusPtr); } -void DriveManager::init() { - this->navigation = new Navigation(this->driveModiParams.sensorData); - +void DriveManager::init() { this->addChildComponent(this->driveModiParams.moveControl); - this->addChildComponent(this->navigation); this->activateOnlyChilds(); } diff --git a/src/driveModi/driveManager.h b/src/driveModi/driveManager.h index b0e3215..9a6e2d4 100644 --- a/src/driveModi/driveManager.h +++ b/src/driveModi/driveManager.h @@ -17,7 +17,6 @@ #include "moveControl.h" #include "driveModi/driveModi.h" -#include "navigation.h" #include "config.h" #include "networkConfig.h" #include "debugTimes.h" @@ -27,8 +26,6 @@ // All Drive Modi #include "driveModi/Modi/ManualControl/manualControl.h" -#include "driveModi/Modi/CaptureRoute/captureRoute.h" -#include "driveModi/Modi/Autopilot/autopilot.h" #include "driveModi/Modi/TestMode/testMode.h" /** @@ -46,13 +43,6 @@ enum class Modi { class DriveManager : public Component { public: - /** - * @brief Construct a new Drive Manager object - * - * Creates a Navigation object - * - * @param moveControl - */ DriveManager(MoveControl *moveControl, const SensorData* sensorData, const ControlPadInput *input); DriveManager(DriveModiParams params); @@ -72,13 +62,6 @@ class DriveManager : public Component { */ void changeModus(Modi modus); - /** - * @brief Get the Navigation object - * - * @return Navigation* - */ - Navigation* getNavigation() const {return this->navigation;} - /** * @brief Get the DriveModi Ptr object * @@ -104,7 +87,6 @@ class DriveManager : public Component { Modi currentModus = Modi::Off; DriveModi *currentModusPtr = nullptr; - Navigation* navigation; DriveModiParams driveModiParams; }; diff --git a/src/main.cpp b/src/main.cpp index 0044b6f..b006764 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -38,13 +38,10 @@ #include "menu.h" #include "menuAction.h" #include "SpecialMenus/driveModi/ManualDrive/menuManualDrive.h" -#include "SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.h" -#include "SpecialMenus/driveModi/Autopilot/menuAutopilot.h" #include "SpecialMenus/driveModi/TestMode/menuTestMode.h" #include "SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.h" #include "SpecialMenus/Systeminformation/menuSysteminformation.h" #include "SpecialMenus/PID/menuPidSettings.h" -#include "SpecialMenus/Route/menuRoute.h" #include "SpecialMenus/GPS/menuGPS.h" MoveControl moveController; @@ -218,33 +215,25 @@ void makeMenu() { MenuIntInput* pidl_m = new MenuIntInput(3, new MenuPidSettings(moveController.getPID(0))); MenuIntInput* pidr_m = new MenuIntInput(3, new MenuPidSettings(moveController.getPID(1))); MenuManualControl* man_m = new MenuManualControl(driveManager); - MenuCaptureRoute* cap_m = new MenuCaptureRoute(driveManager); - MenuAutopilot* auto_m = new MenuAutopilot(driveManager); MenuTestMode* testM_m = new MenuTestMode(driveManager); MenuCalibrateCompass* comp_m = new MenuCalibrateCompass(driveManager); MenuGPS* gps_m = new MenuGPS(sensorData); MenuSysteminformation* sys_m = new MenuSysteminformation(mainBattery); - MenuRoute* rout_m = new MenuRoute(driveManager->getNavigation()->getRoute()); - auto_m->setUpdateDelay(1000); gps_m->setUpdateDelay(1000); sys_m->setUpdateDelay(1500); // Entry for the main menu main_m->addEntry(new MenuAction("Mode", mode_m)); main_m->addEntry(new MenuAction("GPS", gps_m)); - main_m->addEntry(new MenuAction("Route", rout_m)); main_m->addEntry(new MenuAction("PID", pid_m)); main_m->addEntry(new MenuAction("Systeminfo", sys_m)); main_m->addEntry(new MenuAction("Restart", restart)); // Entry for the mode Menu mode_m->addEntry(new MenuAction("Manual Control", man_m)); - mode_m->addEntry(new MenuAction("Capture Route", cap_m)); - mode_m->addEntry(new MenuAction("Autopilot", auto_m)); mode_m->addEntry(new MenuAction("Gauge Compass", comp_m)); mode_m->addEntry(new MenuAction("Test Mode", testM_m)); - mode_m->addEntry(new MenuAction("Consol Control", dummy)); // Entry for the PID Menu pid_m->addEntry(new MenuAction("Left", pidl_m)); From 12c338def1478fc11d8a2111e5ef0e73bf1e5076 Mon Sep 17 00:00:00 2001 From: Alexander Klein Date: Thu, 12 Oct 2023 20:50:59 +0200 Subject: [PATCH 4/7] fix merge bugs --- .vscode/settings.json | 1 + lib/Component/component.cpp | 2 +- lib/Sensors/sensorData.cpp | 56 ------------------- lib/Sensors/sensorData.h | 44 --------------- .../SensorData/menuSensorData.cpp | 46 --------------- src/main.cpp | 35 ++++-------- 6 files changed, 13 insertions(+), 171 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index d055b55..78046d2 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -150,6 +150,7 @@ "Punica", "RHEDE", "Rtcm", + "Sats", "Schalke", "Soln", "Systeminformation", diff --git a/lib/Component/component.cpp b/lib/Component/component.cpp index 0595c77..8bf2ab5 100644 --- a/lib/Component/component.cpp +++ b/lib/Component/component.cpp @@ -19,7 +19,7 @@ void Component::loop() (*it)->loop(); } } - this->runAsChild();F + this->runAsChild(); if (this->onlyChilds) { diff --git a/lib/Sensors/sensorData.cpp b/lib/Sensors/sensorData.cpp index 23db0ef..97c731f 100644 --- a/lib/Sensors/sensorData.cpp +++ b/lib/Sensors/sensorData.cpp @@ -68,46 +68,6 @@ void SensorData::enableCalcCompass() // TODO: !!! implementieren } -void SensorData::enableGyroscope() -{ - this->gyroscope = new MPU6050(); - this->gyroscope->initialize(); - if (!this->gyroscope->testConnection()) - { - std::cout << "SensorData::enableGyroscope: Gyroskop is not conntected. Freeze!" << std::endl; - while (true) - { - } - } - - const uint8_t deviceStatus = this->gyroscope->dmpInitialize(); - - // TODO: !!! MagicNumer 6x - this->gyroscope->setXGyroOffset(220); - this->gyroscope->setYGyroOffset(76); - this->gyroscope->setZGyroOffset(-85); - this->gyroscope->setZAccelOffset(1788); - - if (deviceStatus == 0) - { - this->gyroscope->CalibrateAccel(6); - this->gyroscope->CalibrateGyro(6); - this->gyroscope->PrintActiveOffsets(); - this->gyroscope->setDMPEnabled(true); - } - else - { - // ERROR! - // 1 = initial memory load failed - // 2 = DMP configuration updates failed - // (if it's going to break, usually the code will be 1) - std::cout << "SensorData::enableGyroscope: DMP Initialization failed (code" << static_cast(deviceStatus) << "). Freeze!" << std::endl; - while (true) - { - } - } -} - CalcAzimuth::State SensorData::getCalcAzimuthState() const { if (static_cast(this->calcCompass)) @@ -117,15 +77,6 @@ CalcAzimuth::State SensorData::getCalcAzimuthState() const return CalcAzimuth::State::Invalid; } -NTRIPClientStates SensorData::getNtripState() const -{ - if (static_cast(this->ntripClient)) - { - return this->ntripClient->getClientState(); - } - return NTRIPClientStates::notAvailable; -} - void SensorData::printPVTdata(UBX_NAV_PVT_data_t *ubxDataStruct) { static constexpr uint8_t stringSize = 32; @@ -220,13 +171,6 @@ void SensorData::run() this->realCompass->read(); this->realAzimuth = this->realCompass->getAzimuth(); } - - if (static_cast(this->gyroscope) && this->gyroscope->dmpGetCurrentFIFOPacket(static_cast(this->gyroBuffer))) - { - this->gyroscope->dmpGetQuaternion(&this->quaternion, static_cast(this->gyroBuffer)); - this->gyroscope->dmpGetGravity(&this->gravity, &this->quaternion); - this->gyroscope->dmpGetYawPitchRoll(static_cast(this->yawPitchRoll), &this->quaternion, &this->gravity); - } } void SensorData::runAsChild() diff --git a/lib/Sensors/sensorData.h b/lib/Sensors/sensorData.h index f3bcdb6..f22e5b5 100644 --- a/lib/Sensors/sensorData.h +++ b/lib/Sensors/sensorData.h @@ -21,7 +21,6 @@ #include #include -#include #include "calcAzimuth.h" #include "point.h" @@ -37,8 +36,6 @@ public: SensorData(); ~SensorData(); - void enableNtrip(String host, uint16_t port, String mountPoint, String user, String password); - /** * @brief Enable the gnss module over spi * @@ -54,7 +51,6 @@ public: void enableRealCompass(); void enableCalcCompass(); - void enableGyroscope(); // Interface Const /** @@ -84,19 +80,6 @@ public: Point getCurrentPos() const { return this->currentPosition; } const UBX_NAV_PVT_data_t *getGnssData() const { return this->gnssData; }; - NTRIPClientStates getNtripState() const; - - /** - * @brief Get the data from the gyroscope - * - * The returned float pointer is an array of 3 floats - * - Yaw - * - Pitch - * - Roll - * - * @return const float* - */ - const float *getGyroData() const { return this->yawPitchRoll; } /** * @brief Get the CalcCompass object @@ -110,18 +93,6 @@ public: */ QMC5883LCompass *getRealCompass() const { return this->realCompass; } - /** - * @brief Get the NTRIPClient object - * @return NTRIPClient* - */ - NTRIPClient *getNtripClient() const { return this->ntripClient; } - - /** - * @brief Get the Gyroscope object - * @return MPU6050* - */ - MPU6050 *getGyroscope() const { return this->gyroscope; } - // static /** * @brief Set the output status for PVTdata. @@ -142,29 +113,14 @@ private: QMC5883LCompass *realCompass = nullptr; CalcAzimuth *calcCompass = nullptr; SFE_UBLOX_GNSS *gnss = nullptr; - NTRIPClient *ntripClient = nullptr; - MPU6050 *gyroscope = nullptr; UBX_NAV_PVT_data_t *gnssData = nullptr; Point currentPosition; - Quaternion quaternion; - VectorFloat gravity; - char *host = nullptr; - char *mountPoint = nullptr; - char *user = nullptr; - char *password = nullptr; - - bool isNtripInit = false; - - uint8_t gyroBuffer[64]; - uint16_t port = 0; int16_t realAzimuth = INT16_MAX; int16_t calcAzimuth = INT16_MAX; uint32_t lastUbxUpdate = 0; - float yawPitchRoll[3]{0, 0, 0}; - // static static void printPVTdata(UBX_NAV_PVT_data_t *ubxDataStruct); static void savePVTdata(UBX_NAV_PVT_data_t *ubxDataStruct); diff --git a/src/SpecialMenus/SensorData/menuSensorData.cpp b/src/SpecialMenus/SensorData/menuSensorData.cpp index 19ec032..8cf4340 100644 --- a/src/SpecialMenus/SensorData/menuSensorData.cpp +++ b/src/SpecialMenus/SensorData/menuSensorData.cpp @@ -30,15 +30,6 @@ void MenuSensorData::printPage() const switch (this->getCurrentPage()) { - case 0: - lineOne = " Y P R :"; - lineTwo.concat(this->sensorData->getGyroData()[0]); - lineTwo.concat(" "); - lineTwo.concat(this->sensorData->getGyroData()[1]); - lineTwo.concat(" "); - lineTwo.concat(this->sensorData->getGyroData()[2]); - break; - case 1: lineOne = "Real Azimuth:"; lineTwo.concat(this->sensorData->getRealAzimuth()); @@ -91,43 +82,6 @@ void MenuSensorData::printPage() const break; - case 5: - { - lineOne = "CarSol: "; - lineTwo = "Ntrip: "; - const uint8_t carrSoln = gpsData->flags.bits.carrSoln; - if (carrSoln == 0) - { - lineOne.concat("None"); - } - else if (carrSoln == 1) - { - lineOne.concat("Floating"); - } - else if (carrSoln == 2) - { - lineOne.concat("Fixed"); - } - else - { - lineOne = "UNKNOWN"; - } - const NTRIPClientStates status = this->sensorData->getNtripState(); - if (status == NTRIPClientStates::pushData) - { - lineTwo.concat("enabled"); - } - else if (status == NTRIPClientStates::notAvailable) - { - lineTwo.concat(" N/A"); - } - else - { - lineTwo.concat("disabled"); - } - } - break; - case 6: lineOne = "HAcc: "; lineTwo = "Sats: "; diff --git a/src/main.cpp b/src/main.cpp index 0224e73..e4a49f4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -43,7 +43,6 @@ #include "SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.h" #include "SpecialMenus/Systeminformation/menuSysteminformation.h" #include "SpecialMenus/PID/menuPidSettings.h" -#include "SpecialMenus/Route/menuRoute.h" #include "SpecialMenus/SensorData/menuSensorData.h" #include "SpecialMenus/CalibrateBattery/menuCalibrateBattery.h" @@ -123,12 +122,6 @@ void setup() sensorData = new SensorData(); sensorData->enableGnss(spiPort, PinNumbers::gnssSpiCs); sensorData->enableRealCompass(); - sensorData->enableNtrip(static_cast(NtripConfig::host), - NtripConfig::port, - static_cast(NtripConfig::mountPoint), - static_cast(NtripConfig::user), - static_cast(NtripConfig::password)); - // sensorData->enableGyroscope(); driveManager = new DriveManager(&moveController, sensorData, controlPad->getControlPadDataPtr()); char wifiIndicator = 'X'; @@ -158,7 +151,7 @@ void loop() lcdWrapper->loop(); mainBattery->loop(); - // new Value ervery 0.5s + // new Value every 0.5s if (mainBattery->isNewValue()) { static uint8_t batteryLowCounter = 0; @@ -191,14 +184,14 @@ void loop() void i2cScanner() { constexpr uint8_t checkForLength = 16; - constexpr uint8_t maxAdresses = UINT8_MAX / 2; + constexpr uint8_t maxAddresses = UINT8_MAX / 2; std::cout << "\nI2C Scanner" << std::endl; byte error = 0; byte address = 0; int nDevices = 0; std::cout << "Scanning..." << std::endl; - for (address = 1; address < maxAdresses; address++) + for (address = 1; address < maxAddresses; address++) { Wire.beginTransmission(address); error = Wire.endTransmission(); @@ -252,24 +245,18 @@ void makeMenu() auto *pidr_m = new MenuIntInput(3, new MenuPidSettings(moveController.getPID(1))); auto *speed_m = new MenuIntInput(2, new MenuSpeed(driveManager->getDrivingSpeedsRef())); auto *man_m = new MenuManualControl(driveManager); - auto *cap_m = new MenuCaptureRoute(driveManager); - auto *auto_m = new MenuAutopilot(driveManager); auto *testM_m = new MenuTestMode(driveManager); auto *comp_m = new MenuCalibrateCompass(driveManager); auto *sys_m = new MenuSysteminformation(mainBattery); auto *sen_m = new MenuSensorData(sensorData); - // TODO: Wie bekommt jeder die dumme Route? - auto *rout_m = new MenuRoute(new Route()); auto *bat_m = new MenuCalibrateBattery(mainBattery); - auto_m->setUpdateDelay(displayUpdateDelay); sys_m->setUpdateDelay(displayUpdateDelay); sen_m->setUpdateDelay(displayUpdateDelay); // Entry for the main menu main_m->addEntry(new MenuAction("Mode", mode_m)); main_m->addEntry(new MenuAction("Sensor", sen_m)); - main_m->addEntry(new MenuAction("Route", rout_m)); main_m->addEntry(new MenuAction("Settings", set_m)); main_m->addEntry(new MenuAction("Systeminfo", sys_m)); main_m->addEntry(new MenuAction("Restart", restart)); @@ -353,16 +340,16 @@ void lcdWrapperCallback(const char data[][LcdWrapper::totalRows], uint8_t lines, NetworkAddresses setIPs() { - NetworkAddresses adresses; - adresses.localIP.fromString(static_cast(NetworkConfig::ip)); - adresses.subnet.fromString(static_cast(NetworkConfig::subnet)); - adresses.gateway.fromString(static_cast(NetworkConfig::gateway)); - adresses.dnsServer.fromString(static_cast(NetworkConfig::dns)); + NetworkAddresses addresses; + addresses.localIP.fromString(static_cast(NetworkConfig::ip)); + addresses.subnet.fromString(static_cast(NetworkConfig::subnet)); + addresses.gateway.fromString(static_cast(NetworkConfig::gateway)); + addresses.dnsServer.fromString(static_cast(NetworkConfig::dns)); if (NetworkConfig::mqtt) { - adresses.mqttServer.fromString(static_cast(MqttConfig::server)); - adresses.mqttPort = MqttConfig::port; + addresses.mqttServer.fromString(static_cast(MqttConfig::server)); + addresses.mqttPort = MqttConfig::port; } - return adresses; + return addresses; } From f0474027be0bad1aca6dee3af9080b8eb16d3a7d Mon Sep 17 00:00:00 2001 From: Alexander Klein Date: Thu, 12 Oct 2023 20:58:30 +0200 Subject: [PATCH 5/7] remove CalcAzimuth --- lib/CalcAzimuth/calcAzimuth.cpp | 121 ------------------ lib/CalcAzimuth/calcAzimuth.h | 93 -------------- lib/MotorControl/motorControl.cpp | 3 - lib/Sensors/sensorData.cpp | 15 --- lib/Sensors/sensorData.h | 27 ---- .../SensorData/menuSensorData.cpp | 15 +-- src/driveModi/Modi/TestMode/testMode.cpp | 2 - 7 files changed, 4 insertions(+), 272 deletions(-) delete mode 100644 lib/CalcAzimuth/calcAzimuth.cpp delete mode 100644 lib/CalcAzimuth/calcAzimuth.h diff --git a/lib/CalcAzimuth/calcAzimuth.cpp b/lib/CalcAzimuth/calcAzimuth.cpp deleted file mode 100644 index f7f3c4a..0000000 --- a/lib/CalcAzimuth/calcAzimuth.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/** - * @file calcAzimuth.cpp - * @author Alexander Klein (alex@kleiax.de) - * @brief - * @version 0.1 - * @date 2023-09-03 - * - * @copyright Copyright (c) 2023 - * - */ - -#include "calcAzimuth.h" - -CalcAzimuth::CalcAzimuth(Point point) - : lastChangePoint{point}, currentPosition{point} -{ - Component::loopDelay = CalcAzimuth::loopDelay; -} - -void CalcAzimuth::drivingDirectionChange(Point point) -{ - if (point.isInit() && point.isValid()) - { - this->directionChangeMode = true; - this->lastChangePoint = point; - this->state = State::Invalid; - } -} - -void CalcAzimuth::updateCurrentPosition(Point point) -{ - this->currentPosition = point; - this->positionChanged = true; -} - -String CalcAzimuth::stateToString(State state) -{ - switch (state) - { - case State::Invalid: - return "Invalid"; - - case State::Bad: - return "Bad"; - - case State::Ok: - return "Ok"; - - case State::Good: - return "Good"; - - case State::Super: - return "Super"; - - default: - return "UNKOWN"; - } -} - -void CalcAzimuth::run() -{ - if (!this->positionChanged) - { - return; - } - - this->positionChanged = false; - this->updateAzimuth(); -} - -void CalcAzimuth::updateAzimuth() -{ - if (!this->directionChangeMode || this->lastChangePoint.distanceTo(this->currentPosition) < 1.0) - { - this->state = State::Invalid; - this->calcAzimuth = INT16_MIN; - return; - } - - this->calcAzimuth = this->lastChangePoint.courseTo(this->currentPosition); - - // Map point accuracy to State - if (this->lastChangePoint.getAccuracy() == Point::Accuracy::oneDigOfCM || this->currentPosition.getAccuracy() == Point::Accuracy::oneDigOfCM) - { - this->state = State::Good; - } - else if (this->lastChangePoint.getAccuracy() == Point::Accuracy::twoDigOfCM || this->currentPosition.getAccuracy() == Point::Accuracy::twoDigOfCM) - { - this->state = State::Ok; - } - else if (this->lastChangePoint.getAccuracy() == Point::Accuracy::threeDigOfCM || this->currentPosition.getAccuracy() == Point::Accuracy::threeDigOfCM) - { - this->state = State::Bad; - } - else - { - this->state = State::Invalid; - } - - // Upgrade quality if the range grows up - if (this->lastChangePoint.distanceTo(this->currentPosition) > this->minDistanceForBetterQuality) - { - switch (this->state) - { - case State::Bad: - this->state = State::Ok; - break; - - case State::Ok: - this->state = State::Good; - break; - - case State::Good: - this->state = State::Super; - break; - - default: - break; - } - } -} diff --git a/lib/CalcAzimuth/calcAzimuth.h b/lib/CalcAzimuth/calcAzimuth.h deleted file mode 100644 index 4b18315..0000000 --- a/lib/CalcAzimuth/calcAzimuth.h +++ /dev/null @@ -1,93 +0,0 @@ -/** - * @file calcAzimuth.h - * @author Alexander Klein (alex@kleiax.de) - * @brief Contains a class that calculates the azimuth from a last and a current position - * @version 0.1 - * @date 2023-09-03 - * - * @copyright Copyright (c) 2023 - * - */ - -#ifndef CALC_AZIMUTH_H -#define CALC_AZIMUTH_H - -#include "component.h" -#include "point.h" - -/** - * @brief A class to calculate an azimuth - * - * This class calculates the current Azimuth with the last position - * where the rover has been rotated and the current position - */ -class CalcAzimuth : public Component -{ -public: - /** - * @brief States which represent the quality of the current calculated azimuth - */ - enum State - { - Invalid, - Bad, - Ok, - Good, - Super - }; - - /** - * @brief Construct a new Calc Azimuth object - * - * @param point current position - */ - CalcAzimuth(Point point); - - /** - * @brief Have to be called if the rover rotates - * - * @param point current position - */ - void drivingDirectionChange(Point point); - - /** - * @brief update the current position - * - * This function should be called if the rover has moved in - * a straight direction, to calculated the current Azimuth. - * More distance to the point given to drivingDirectionChange() - * increase the accuracy of the calculation. - * - * @param point current position - */ - void updateCurrentPosition(Point point); - void disableCalcAzimuth() { this->directionChangeMode = false; } - - int16_t getAzimuth() const { return this->calcAzimuth; } - - /** - * @brief Get the State struct - * - * @return State current quality of the calculation - */ - State getState() const { return this->state; } - - static String stateToString(State state); - -private: - void run() override; - void updateAzimuth(); - - State state = State::Invalid; - Point lastChangePoint; - Point currentPosition; - - bool positionChanged = false; - bool directionChangeMode = false; - int16_t calcAzimuth = INT16_MAX; - double minDistanceForBetterQuality = 2; - - static constexpr uint8_t loopDelay = 50; -}; - -#endif // CALC_AZIMUTH_H diff --git a/lib/MotorControl/motorControl.cpp b/lib/MotorControl/motorControl.cpp index 6ff901f..82a82ba 100644 --- a/lib/MotorControl/motorControl.cpp +++ b/lib/MotorControl/motorControl.cpp @@ -158,7 +158,6 @@ bool MotorControl::isAccelerationNegative() const void MotorControl::setRealPower(int8_t power) { - // TODO: Exceptionhandling if (power <= 100 && power >= -100) { this->power = power; @@ -199,8 +198,6 @@ void MotorControl::setRealPower(int8_t power) void MotorControl::increasePower(int8_t power) { - // TODO: Exceptionhandling - // TODO: make a stop befor a direction change if (abs(power) > 2 * MotorControl::powerSteps) { Serial.println("Invalid Argument in MotorControl::increasePower"); diff --git a/lib/Sensors/sensorData.cpp b/lib/Sensors/sensorData.cpp index 97c731f..622a554 100644 --- a/lib/Sensors/sensorData.cpp +++ b/lib/Sensors/sensorData.cpp @@ -53,7 +53,6 @@ void SensorData::enableRealCompass() this->realCompass = new QMC5883LCompass(); // Init Compass Wire.beginTransmission(address); - // TODO: describe Bytes !!! Wire.write(0x0b); Wire.write(0x01); Wire.endTransmission(); @@ -63,20 +62,6 @@ void SensorData::enableRealCompass() caliCompass.useData(); } -void SensorData::enableCalcCompass() -{ - // TODO: !!! implementieren -} - -CalcAzimuth::State SensorData::getCalcAzimuthState() const -{ - if (static_cast(this->calcCompass)) - { - return this->calcCompass->getState(); - } - return CalcAzimuth::State::Invalid; -} - void SensorData::printPVTdata(UBX_NAV_PVT_data_t *ubxDataStruct) { static constexpr uint8_t stringSize = 32; diff --git a/lib/Sensors/sensorData.h b/lib/Sensors/sensorData.h index f22e5b5..d95cae7 100644 --- a/lib/Sensors/sensorData.h +++ b/lib/Sensors/sensorData.h @@ -21,7 +21,6 @@ #include #include -#include "calcAzimuth.h" #include "point.h" @@ -60,33 +59,9 @@ public: */ int16_t getRealAzimuth() const { return this->realAzimuth; } - /** - * @brief Get the azimuth calculated by CalcAzimuth - * - * Consider to call getCalcAzimuthState() to check, if the data is valid. - * - * @return int16_t - */ - int16_t getCalcAzimuth() const { return this->calcAzimuth; } - - /** - * @brief Get the CalcAzimuth::State object - * - * Needed to check the quality of calculated azimuth - * - * @return CalcAzimuth::State - */ - CalcAzimuth::State getCalcAzimuthState() const; - Point getCurrentPos() const { return this->currentPosition; } const UBX_NAV_PVT_data_t *getGnssData() const { return this->gnssData; }; - /** - * @brief Get the CalcCompass object - * @return CalcAzimuth* - */ - CalcAzimuth *getCalcCompass() const { return this->calcCompass; } - /** * @brief Get the RealCompass object * @return QMC5883LCompass* @@ -111,14 +86,12 @@ private: void updateUbxData(); QMC5883LCompass *realCompass = nullptr; - CalcAzimuth *calcCompass = nullptr; SFE_UBLOX_GNSS *gnss = nullptr; UBX_NAV_PVT_data_t *gnssData = nullptr; Point currentPosition; int16_t realAzimuth = INT16_MAX; - int16_t calcAzimuth = INT16_MAX; uint32_t lastUbxUpdate = 0; // static diff --git a/src/SpecialMenus/SensorData/menuSensorData.cpp b/src/SpecialMenus/SensorData/menuSensorData.cpp index 8cf4340..7148cf0 100644 --- a/src/SpecialMenus/SensorData/menuSensorData.cpp +++ b/src/SpecialMenus/SensorData/menuSensorData.cpp @@ -30,19 +30,12 @@ void MenuSensorData::printPage() const switch (this->getCurrentPage()) { - case 1: + case 0: lineOne = "Real Azimuth:"; lineTwo.concat(this->sensorData->getRealAzimuth()); break; - case 2: - lineOne = "Calc Azimuth:"; - lineTwo.concat(this->sensorData->getCalcAzimuth()); - lineTwo.concat(" "); - lineTwo.concat(CalcAzimuth::stateToString(this->sensorData->getCalcAzimuthState())); - break; - - case 3: + case 1: { lineOne = "Lat:"; lineTwo = "Lon:"; @@ -52,7 +45,7 @@ void MenuSensorData::printPage() const } break; - case 4: + case 2: lineOne = "Time: "; lineTwo = ""; if (static_cast(fixType)) @@ -82,7 +75,7 @@ void MenuSensorData::printPage() const break; - case 6: + case 3: lineOne = "HAcc: "; lineTwo = "Sats: "; if (static_cast(fixType)) diff --git a/src/driveModi/Modi/TestMode/testMode.cpp b/src/driveModi/Modi/TestMode/testMode.cpp index afda3dd..e7845e2 100644 --- a/src/driveModi/Modi/TestMode/testMode.cpp +++ b/src/driveModi/Modi/TestMode/testMode.cpp @@ -82,8 +82,6 @@ bool TestMode::drive(int16_t cmDistance, int16_t degree) } else { - // forward or backward and left or right - // TODO: Calculate roationspeed if (cmDistance < 0) { this->moveControl->setSpeed(-this->maxSpeeds.x); From a7930e291523def4abf9ba66ce91eda3641ba34c Mon Sep 17 00:00:00 2001 From: Alexander Klein Date: Fri, 13 Oct 2023 14:17:51 +0200 Subject: [PATCH 6/7] more refactor bug fixes --- .vscode/settings.json | 1 + doc/Diagrams/classdiagramm.uxf | 157 ------- doc/Diagrams/statesAutopilot.uxf | 390 ------------------ doc/TODO allgemein.txt | 39 -- include/moveControl.h | 1 + include/networkConfig.h | 4 +- lib/Menu | 1 + lib/MotorControl/motorControl.cpp | 29 +- lib/MotorControl/motorControl.h | 18 +- lib/Sensors/sensorData.h | 1 - platformio.ini | 24 +- src/SpecialMenus/driveModi/menuDriveMode.cpp | 1 - .../Modi/ManualControl/manualControl.cpp | 2 +- src/main.cpp | 8 +- 14 files changed, 21 insertions(+), 655 deletions(-) delete mode 100644 doc/Diagrams/classdiagramm.uxf delete mode 100644 doc/Diagrams/statesAutopilot.uxf create mode 160000 lib/Menu diff --git a/.vscode/settings.json b/.vscode/settings.json index 78046d2..733df74 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -129,6 +129,7 @@ "carr", "CIPO", "COPI", + "deadzone", "Doxygen", "Dutycycle", "gast", diff --git a/doc/Diagrams/classdiagramm.uxf b/doc/Diagrams/classdiagramm.uxf deleted file mode 100644 index 19ccf23..0000000 --- a/doc/Diagrams/classdiagramm.uxf +++ /dev/null @@ -1,157 +0,0 @@ -10UMLClass75010220650<<hardware>> -MotorControl --- -- target_power: int8_t -- power: int8_t -- direction: uint8_t - - -- pwm_pin: uint8_t -- pwm_channel: uint8_t -- pwm_res: uint8_t -- dutycycle_min: uint8_t -- dutycycle_max: uint8_t -- direction_1: uint8_t -- direction_2: uint8_t -- delay: uint8_t -- powersteps: uint8_t - -- last_millis: uint32_t --- -+ MotorControl() -+ init(pwm_pin: uint8_t, -   pwm_channel: uint8_t, -   dir_1: uint8_t, dir_2: uint8_t) -+ loop(): uint16_t -+ runMotorControl() - -+ setMinPwm(uint8_t) -+ setMaxPwm(uint8_t) -+ setPowerSteps(uint8_t): uint16_t -+ setTargetPower(uint8_t) -+ setDelay(uint8_t): uint16_t - -+ stop() -+ emergencyStop() -+ toString() -+ getPower(): int8_t -+ getTargetPower(): int8_t -+ isTargetPowerReached(): bool -+ isAccelerationPositive(): bool -+ isAccelerationNegative(): bool - -- setRealPower(power: int8_t) -- increasePower(power: int8_t) - -UMLClass80380220330<<hardware>> -Speedometer --- -- encoder: ESP32Encoder -- debug: DebugMqtt* -- name: String -- speed: double = 0 -- last_millis: uint64_t = 0; -- bufPos: uint8_t -- buf: int16_t[BUF_SIZE] --- -+ Speedometer() -+ init(pinA: uint8_t, -    pinB: uint8_t, -    name: String) -+ runSpeedometer() -+ setTargetPower(power: int8_t) -+ getSpeed(): double -+ getDirection(): uint8_t -- addValToBuf(val: int16_t) -- getAverage(): int16_tUMLClass700270370MoveControl --- -- debug: DebugMqtt* -- left_motor: MotorControl* -- right_motor: MotorControl* -- left_speedometer: Speedometer* -- right_speedometer: Speedometer* -- driving_status: DrivingStatus = stop -- x_speed: double = 0 -- rotation_speed: double = 0 -- wheelspeed_left_target: double = 0 -- wheelspeed_right_target: double = 0 --- -+ MoveControl() -+ init(left_motor: MotorControl*, -    right_motor: MotorControl*, -    left_speedometer: Speedometer*, -    right_speedometer: Speedometer*) -+ runMoveControl() -+ setDrivingStatus(status: DrivingStatus) -+ setSpeed(speed: double) -+ setRotationspeed(speed: double) -- calcWheelSpeed() -- regulateMotors()UMLClass37010220330<<driveModi>> -ManualControl --- -- encoder: ESP32Encoder -- debug: DebugMqtt* -- name: String -- speed: double = 0 -- last_millis: uint64_t = 0; -- bufPos: uint8_t -- buf: int16_t[BUF_SIZE] --- -+ Speedometer() -+ init(pinA: uint8_t, -    pinB: uint8_t, -    name: String) -+ runSpeedometer() -+ setTargetPower(power: int8_t) -+ getSpeed(): double -+ getDirection(): uint8_t -- addValToBuf(val: int16_t) -- getAverage(): int16_tUMLClass127010210240MenuControl --- -# parentMenu: MenuControl* -# lcd: LiquidCrystal_I2C* --- -/+down()/ -/+up()/ -/+right()/ -/+left()/ -/+yes()/ -/+no()/ - -/+update()/ -/+printMenu()/ - -+ setParentMenu(MenuControl*) -+ setLcd(LiquidCrystal_I2C*)UMLClass98010280270MenuAction --- -- name: char* - -- *function: void -- *callback: void - -- isMenu: bool -- menu: MenuControl --- -+ MenuAction(const char*, (*function), (*callback)) -+ MenuAction(const char*, (*function)) -+ MenuAction(const char*, MenuControl* menu) - -+ runAction() - -+ getName(): const char* -+ getIsMenu(): bool -+ getMenu(): MenuControl* -UMLClass1220360280160Menu --- -- inSubmenu: bool - -- entrys: list<MenuAction*> -- selectedEntry: list<MenuAction*>::iterator - -- isMenu: bool -- menu: MenuControl --- -+ addEntry(MenuAction* entry) -Relation135024030140lt=<<-10;10;10;120Relation1080270160190lt=- -m1=* -m2=0..110;10;10;160;140;160 \ No newline at end of file diff --git a/doc/Diagrams/statesAutopilot.uxf b/doc/Diagrams/statesAutopilot.uxf deleted file mode 100644 index 21f880d..0000000 --- a/doc/Diagrams/statesAutopilot.uxf +++ /dev/null @@ -1,390 +0,0 @@ - - - 10 - - UMLSpecialState - - 40 - 20 - 20 - 20 - - type=initial - - - - Relation - - 40 - 20 - 130 - 30 - - lt=<- - 110.0;10.0;10.0;10.0 - - - UMLState - - 150 - 10 - 100 - 40 - - search next point -bg=green - - - - UMLSpecialState - - 180 - 90 - 40 - 40 - - bg=green -type=decision - - - - Relation - - 190 - 40 - 30 - 70 - - lt=<- - 10.0;50.0;10.0;10.0 - - - UMLState - - 150 - 180 - 100 - 40 - - detect alignment -bg=green - - - - Relation - - 190 - 120 - 130 - 80 - - lt=<- -[distance <= 5m] - 10.0;60.0;10.0;10.0 - - - UMLObject - - 20 - 0 - 840 - 590 - - Autopilot - -valign=top - - - - Relation - - 210 - 90 - 140 - 40 - - lt=<- -[distance > 5m] - 120.0;20.0;10.0;20.0 - - - UMLState - - 330 - 90 - 100 - 40 - - Error -bg=red - - - - UMLState - - 150 - 270 - 100 - 40 - - correct alignment -bg=green - - - - UMLState - - 150 - 360 - 100 - 40 - - drive to point -bg=green - - - - Relation - - 190 - 210 - 30 - 80 - - lt=<- - 10.0;60.0;10.0;10.0 - - - Relation - - 190 - 300 - 30 - 80 - - lt=<- - 10.0;60.0;10.0;10.0 - - - Relation - - 90 - 280 - 80 - 120 - - lt=<- - 60.0;10.0;10.0;10.0;10.0;100.0;60.0;100.0 - - - UMLState - - 440 - 10 - 410 - 300 - - detect alignment -valign=top - - - - UMLSpecialState - - 460 - 60 - 20 - 20 - - type=final - - - - Relation - - 470 - 60 - 90 - 30 - - lt=-> - 10.0;10.0;70.0;10.0 - - - UMLState - - 540 - 50 - 110 - 40 - - drive 1m forward - - - - UMLState - - 540 - 140 - 110 - 40 - - drive 2m backward - - - - UMLState - - 540 - 230 - 110 - 40 - - drive 1m forward - - - - UMLState - - 700 - 230 - 120 - 40 - - calculate straight line - - - - Relation - - 580 - 80 - 30 - 80 - - lt=<- - 10.0;60.0;10.0;10.0 - - - Relation - - 580 - 170 - 30 - 80 - - lt=<- - 10.0;60.0;10.0;10.0 - - - UMLSpecialState - - 750 - 150 - 20 - 20 - - type=termination - - - - Relation - - 750 - 160 - 30 - 90 - - lt=<- - 10.0;10.0;10.0;70.0 - - - UMLState - - 440 - 320 - 410 - 260 - - correct alignment -valign=top - - - - UMLState - - 540 - 370 - 190 - 40 - - calculate relativ target position - - - - Relation - - 470 - 380 - 90 - 30 - - lt=-> - 10.0;10.0;70.0;10.0 - - - UMLSpecialState - - 460 - 380 - 20 - 20 - - type=final - - - - UMLState - - 580 - 460 - 120 - 40 - - rotate x degree - - - - Relation - - 630 - 400 - 30 - 80 - - lt=<- - 10.0;60.0;10.0;10.0 - - - Relation - - 630 - 490 - 30 - 80 - - lt=<- - 10.0;60.0;10.0;10.0 - - - UMLSpecialState - - 630 - 550 - 20 - 20 - - type=termination - - - diff --git a/doc/TODO allgemein.txt b/doc/TODO allgemein.txt index a3fc74a..4f549fa 100644 --- a/doc/TODO allgemein.txt +++ b/doc/TODO allgemein.txt @@ -1,45 +1,6 @@ -Maybe: - -> Time Measurement in component interface - -> Time warnings - -Do later: - -> Program underfloorLighting - -> Add an beeper - -> Program the beeper - -> Engine slow down without curve in motorControl - -> Network clean up (Mqtt remove?) - -> Extra class for maneuver, autopilot should inherit from int16_t - -> Remote Control - - Leds for gnss rtk etc - - what happens exactly when no data is arriving - -> Test Menu for big curve driving - -> Api with Names and show on Maps in Browser - -> Menu structure mit add functions for each menu mit pointer return to config (additional not replace) - -> Menu Display from parent as run() to make Menu as Component - -> Racing Mode - -> ConsolControl - -> Menü für Einstellungen - - WiFi (save in Flash) - -> Battery - - tabelle mit eigenen Werten übergeben und nicht in header (wiederverwendbarkeit) - - kalibrierungsmethode mit Menü - - Daten in flash speichern können - -> Check speration between Ui and Route (RouteMenu) - -> update sparkfun gnss auf v3 für SPI korrekturdatenüvbetragung - -> Rover Objekt mit Error zustand freeze, damit das wenn möglich auch auf dem Display angezeigt wird. - -> ESP und Sensoren in den DeepSleep für Auschalten oder Akkuschutz - -> Doxygen comments - - navigation - - autopilot - - Do now: Code: - Fernbedienung! - Latex: - Anhang: Liste mit allen Komponenten und Kurzbeschreibung - Unterschied funktionale und nicht funktionale Anforderungen Overfull H-Boxen Test Motor, Zeiten kontrolieren. Wenn einfach so dann bezug auf fehler bei Timing und freeRtos Was mit den nicht erfüllten Anforderungen machen? diff --git a/include/moveControl.h b/include/moveControl.h index a10c8a2..27a91bf 100644 --- a/include/moveControl.h +++ b/include/moveControl.h @@ -87,6 +87,7 @@ public: * @param status */ void setDrivingStatus(Status status); + Status getDrivingStatus() const { return this->driving_status; } /** * @brief Stops the engine immediately diff --git a/include/networkConfig.h b/include/networkConfig.h index 13aac37..b594ad6 100644 --- a/include/networkConfig.h +++ b/include/networkConfig.h @@ -14,12 +14,12 @@ #include -#define HW1 +#define HOTSPOT #ifdef HOTSPOT namespace NetworkConfig { - const char ssid[] = "Kleiax Handy"; + const char ssid[] = "KleiaxHandy"; const char password[] = "12345677"; const char ip[] = "192.168.43.4"; const char subnet[] = "255.255.255.0"; diff --git a/lib/Menu b/lib/Menu new file mode 160000 index 0000000..35b1478 --- /dev/null +++ b/lib/Menu @@ -0,0 +1 @@ +Subproject commit 35b147866604e9c95120814a121d7a8df84921e8 diff --git a/lib/MotorControl/motorControl.cpp b/lib/MotorControl/motorControl.cpp index 82a82ba..f112d11 100644 --- a/lib/MotorControl/motorControl.cpp +++ b/lib/MotorControl/motorControl.cpp @@ -33,6 +33,7 @@ void MotorControl::init(uint8_t pwmPin, uint8_t pwmChannel, uint8_t dir_1, uint8 ledcSetup(this->pwmChannel, MotorControl::pwmFreq, MotorControl::pwmRes); ledcAttachPin(this->pwmPin, this->pwmChannel); ledcWrite(this->pwmChannel, 0); + std::cout << "Init pwm" << std::endl; } void MotorControl::run() @@ -56,7 +57,7 @@ void MotorControl::run() return; } - // Positive or negative tagret speed + // Positive or negative target speed if (this->targetPower >= 0) { // Positive or negative speed @@ -97,28 +98,6 @@ void MotorControl::run() } } -void MotorControl::setMinPwm(uint8_t min) -{ - if (min > MotorControl::maxPwmMin) - { - min = MotorControl::maxPwmMin; - } - // transform percentage to real pwm value - min = static_cast(((static_cast(1) << pwmRes) - 1) * (min / 100.0)); - this->dutycycleMin = min; -} - -void MotorControl::setMaxPwm(uint8_t max) -{ - if (max > 100) - { - max = 100; - } - // transform percentage to real pwm value - max = static_cast(((static_cast(1) << pwmRes) - 1) * (max / 100.0)); - this->dutycycleMax = max; -} - void MotorControl::setTargetPower(int8_t power) { if (power <= 100 && power >= -100) @@ -174,10 +153,11 @@ void MotorControl::setRealPower(int8_t power) digitalWrite(this->dir_2, LOW); ledcWrite(this->pwmChannel, 0); this->dutycycle = 0; + std::cout << "abort" << std::endl; return; } - const uint8_t pwm_val = map(abs(power), 0, 100, this->dutycycleMin, this->dutycycleMax); + const uint8_t pwm_val = map(abs(power), 0, 100, MotorControl::minPwmVal, MotorControl::maxPwmVal); if ((this->direction == 1 || this->direction == 0) && power < 0) { // new direction backward @@ -192,6 +172,7 @@ void MotorControl::setRealPower(int8_t power) digitalWrite(this->dir_2, LOW); } + std::cout << "MotorControl::setRealPower pwm_val: " << (int) pwm_val << " channel:" << (int) this->pwmChannel << std::endl; ledcWrite(this->pwmChannel, pwm_val); this->dutycycle = pwm_val; } diff --git a/lib/MotorControl/motorControl.h b/lib/MotorControl/motorControl.h index fc576cd..55c91e9 100644 --- a/lib/MotorControl/motorControl.h +++ b/lib/MotorControl/motorControl.h @@ -38,20 +38,6 @@ public: */ void init(uint8_t pwmPin, uint8_t pwmChannel, uint8_t dir_1, uint8_t dir_2); - /** - * @brief Set the minimum duty cycle - * - * @param min duty cycle in percent - */ - void setMinPwm(uint8_t min); - - /** - * @brief Set the maximum duty cycle - * - * @param max duty cycle in percent - */ - void setMaxPwm(uint8_t max); - /** * @brief Set the Target Power * @@ -103,6 +89,8 @@ private: static constexpr uint8_t pwmRes = 8; static constexpr uint8_t powerSteps = 2; // A total of 20 levels ( 100 / SPEED_STEPS ) * RUN_MOTOR_CONTROL_DELAY = 500ms static constexpr uint8_t maxPwmMin = 80; + static constexpr uint8_t maxPwmVal = 250; + static constexpr uint8_t minPwmVal = 55; // Max 98% of 2^PWM_RES int8_t targetPower = 0; int8_t power = 0; @@ -111,8 +99,6 @@ private: uint8_t pwmPin = 0; uint8_t pwmChannel = 0; uint16_t dutycycle = 0; - uint8_t dutycycleMin = 55; - uint8_t dutycycleMax = 98; // Max 98% of 2^PWM_RES uint8_t dir_1 = 0; uint8_t dir_2 = 0; }; diff --git a/lib/Sensors/sensorData.h b/lib/Sensors/sensorData.h index d95cae7..0e2cd1a 100644 --- a/lib/Sensors/sensorData.h +++ b/lib/Sensors/sensorData.h @@ -13,7 +13,6 @@ #define SENSOR_DATA_H #include -#include #include #include "component.h" diff --git a/platformio.ini b/platformio.ini index 9d9aec8..8aff3e3 100644 --- a/platformio.ini +++ b/platformio.ini @@ -15,16 +15,14 @@ board_build.partitions = no_ota.csv framework = arduino monitor_speed = 115200 upload_speed = 921600 -; monitor_port = COM6 +monitor_port = COM6 lib_deps = https://git.kleiax.de/PlatformIO-Libs/SparkFunGNSS.git knolleary/PubSubClient@^2.8 br3ttb/PID@^1.2.1 marcoschwartz/LiquidCrystal_I2C@^1.1.4 - bblanchon/ArduinoJson@^6.20.0 mprograms/QMC5883LCompass@^1.2.0 - jrowberg/I2Cdevlib-MPU6050@^1.0.0 -; upload_port = COM6 +upload_port = COM6 test_ignore = test_desktop build_type = debug monitor_filters = esp32_exception_decoder @@ -42,21 +40,3 @@ test_ignore = test_embedded [platformio] description = A Rover who should be drive a route by gps. - - -; Bei Möglichkeit folgendes aus clang tidy entfernen -; cppcoreguidelines-owning-memory -; -; -; -; -; -; -; -; -; -; -; -; -; -# diff --git a/src/SpecialMenus/driveModi/menuDriveMode.cpp b/src/SpecialMenus/driveModi/menuDriveMode.cpp index 527aeca..b949b1e 100644 --- a/src/SpecialMenus/driveModi/menuDriveMode.cpp +++ b/src/SpecialMenus/driveModi/menuDriveMode.cpp @@ -48,7 +48,6 @@ void MenuDriveMode::left() this->firstPrint = true; this->configureOnLeave(); - delete this->menuSpeed; this->driveManager->changeModus(); MenuInformationSites::left(); } diff --git a/src/driveModi/Modi/ManualControl/manualControl.cpp b/src/driveModi/Modi/ManualControl/manualControl.cpp index de54097..cb4bd62 100644 --- a/src/driveModi/Modi/ManualControl/manualControl.cpp +++ b/src/driveModi/Modi/ManualControl/manualControl.cpp @@ -47,7 +47,7 @@ void ManualControl::analogControl() void ManualControl::digitalControl() { - static constexpr uint8_t deadzone = 120; + static constexpr uint8_t deadzone = 110; const int16_t yAxis = this->input->x - 127; const int16_t xAxis = this->input->y - 127; diff --git a/src/main.cpp b/src/main.cpp index e4a49f4..6bca612 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -129,12 +129,16 @@ void setup() { wifiIndicator = '-'; } + + lcdWrapper = new LcdWrapper(lcd); + lcdWrapper->setCallback(lcdWrapperCallback); + lcdWrapper->loop(); + lcd->backlight(); + lcd->setCursor(0, 0); lcd->printf("%c Kleiax-Rover %c", wifiIndicator, wifiIndicator); lcd->setCursor(0, 1); lcd->printf("WiFi channel %u", Network::getCurrentChannel()); - lcdWrapper = new LcdWrapper(lcd); - lcdWrapper->setCallback(lcdWrapperCallback); makeMenu(); From f0f75d3fd3ed24d7748044309d8772da9eb78e41 Mon Sep 17 00:00:00 2001 From: Alexander Klein Date: Fri, 19 Jul 2024 15:33:50 +0200 Subject: [PATCH 7/7] - deactivate a debug print - activate init screen - update network config --- include/networkConfig.h | 6 +++--- lib/LcdWrapper/LcdWrapper.cpp | 2 +- lib/MotorControl/motorControl.cpp | 2 +- platformio.ini | 5 +++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/include/networkConfig.h b/include/networkConfig.h index b594ad6..4d9faea 100644 --- a/include/networkConfig.h +++ b/include/networkConfig.h @@ -19,11 +19,11 @@ #ifdef HOTSPOT namespace NetworkConfig { - const char ssid[] = "KleiaxHandy"; + const char ssid[] = "Nubsi"; const char password[] = "12345677"; - const char ip[] = "192.168.43.4"; + const char ip[] = "192.168.72.7"; const char subnet[] = "255.255.255.0"; - const char gateway[] = "192.168.43.1"; + const char gateway[] = "192.168.72.228"; const char dns[] = "8.8.8.8"; const bool mqtt = false; } diff --git a/lib/LcdWrapper/LcdWrapper.cpp b/lib/LcdWrapper/LcdWrapper.cpp index 80d66db..d3952a5 100644 --- a/lib/LcdWrapper/LcdWrapper.cpp +++ b/lib/LcdWrapper/LcdWrapper.cpp @@ -14,7 +14,7 @@ LcdWrapper::LcdWrapper(LiquidCrystal_I2C *lcd) : lcd{lcd}, changed{false} { - this->clear(); + // this->clear(); } void LcdWrapper::run() diff --git a/lib/MotorControl/motorControl.cpp b/lib/MotorControl/motorControl.cpp index f112d11..4f6ada5 100644 --- a/lib/MotorControl/motorControl.cpp +++ b/lib/MotorControl/motorControl.cpp @@ -153,7 +153,7 @@ void MotorControl::setRealPower(int8_t power) digitalWrite(this->dir_2, LOW); ledcWrite(this->pwmChannel, 0); this->dutycycle = 0; - std::cout << "abort" << std::endl; + // std::cout << "abort" << std::endl; return; } diff --git a/platformio.ini b/platformio.ini index 8aff3e3..06c772f 100644 --- a/platformio.ini +++ b/platformio.ini @@ -15,14 +15,15 @@ board_build.partitions = no_ota.csv framework = arduino monitor_speed = 115200 upload_speed = 921600 -monitor_port = COM6 +; monitor_port = COM6 lib_deps = https://git.kleiax.de/PlatformIO-Libs/SparkFunGNSS.git + https://git.kleiax.de/PlatformIO-Libs/Menu.git knolleary/PubSubClient@^2.8 br3ttb/PID@^1.2.1 marcoschwartz/LiquidCrystal_I2C@^1.1.4 mprograms/QMC5883LCompass@^1.2.0 -upload_port = COM6 +; upload_port = COM6 test_ignore = test_desktop build_type = debug monitor_filters = esp32_exception_decoder