From f236d98be2a57fdae23ef8460af0a7d305cbce8a Mon Sep 17 00:00:00 2001 From: Alexander Klein Date: Tue, 8 Aug 2023 22:59:28 +0200 Subject: [PATCH] - added calc azimuth to autopilot menu - getters in navigation for calc azimuth - wrapper for manualControl for automatic orintaion change --- doc/TODO allgemein.txt | 1 + include/Version.h | 4 +- lib/Navigation/navigation.h | 2 + .../driveModi/Autopilot/menuAutopilot.cpp | 41 ++++++++++++++++--- src/driveModi/Modi/Autopilot/autopilot.cpp | 22 +++++++++- src/driveModi/Modi/Autopilot/autopilot.h | 11 +++++ version | 2 +- 7 files changed, 73 insertions(+), 10 deletions(-) diff --git a/doc/TODO allgemein.txt b/doc/TODO allgemein.txt index c33ae7c..37eaf10 100644 --- a/doc/TODO allgemein.txt +++ b/doc/TODO allgemein.txt @@ -8,4 +8,5 @@ Besser zügig: Speedometer buffer ergibt kaum Sinn Abweichung max 25 cm bevor zu ungenau damit nie mehr als 50 cm gesamt. Doxygen Kommentare aktualisieren + Motortreiber vielleicht bei wenigster Leistung ohne Kurve diff --git a/include/Version.h b/include/Version.h index 6672895..79e1506 100644 --- a/include/Version.h +++ b/include/Version.h @@ -1,9 +1,9 @@ // AUTO GENERATED FILE, DO NOT EDIT #ifndef VERSION - #define VERSION "0.8.20" + #define VERSION "0.8.21" #endif #ifndef BUILD_TIMESTAMP - #define BUILD_TIMESTAMP "2023-08-08 14:33:17.266785" + #define BUILD_TIMESTAMP "2023-08-08 22:55:37.389313" #endif \ No newline at end of file diff --git a/lib/Navigation/navigation.h b/lib/Navigation/navigation.h index 0cb4b86..b44abae 100644 --- a/lib/Navigation/navigation.h +++ b/lib/Navigation/navigation.h @@ -194,6 +194,8 @@ class Navigation { */ 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; } Point::Accuracy getMinAccuracy() const { return this->minAccuracy; } void setMinAccuracy(Point::Accuracy accuracy) { this->minAccuracy = accuracy; } diff --git a/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp b/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp index 94d3828..b5dcd8b 100644 --- a/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp +++ b/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp @@ -166,10 +166,41 @@ void MenuAutopilot::printPage() const { lineTwo = "accuracy is low"; break; - default: - this->printDefault(); - return; - } + case 11: + lineOne = "CalcAzi: "; + 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; + } + break; + + default: + this->printDefault(); + return; + } this->print(lineOne, lineTwo); } @@ -219,7 +250,7 @@ void MenuAutopilot::update() { } void MenuAutopilot::init() { - this->setCountPages(11); + this->setCountPages(12); this->driveManager->changeModus(Modi::Autopilot); this->autopilot = (Autopilot*) this->driveManager->getDriveModiPtr(); this->routeInfo = this->autopilot->getRouteInfo(); diff --git a/src/driveModi/Modi/Autopilot/autopilot.cpp b/src/driveModi/Modi/Autopilot/autopilot.cpp index fe5ddbd..c3d413f 100644 --- a/src/driveModi/Modi/Autopilot/autopilot.cpp +++ b/src/driveModi/Modi/Autopilot/autopilot.cpp @@ -12,13 +12,31 @@ #include "driveModi/Modi/Autopilot/autopilot.h" #include "autopilot.h" +DirectionChangeSignal::DirectionChangeSignal(Navigation* navigation) { + this->navigation = navigation; + this->action(); +} + +DirectionChangeSignal::~DirectionChangeSignal() { + navigation->dissableCalcAzimuth(); +} + +void DirectionChangeSignal::action() { + this->navigation->drivingDirectionChange(); +} + + Autopilot::Autopilot(MoveControl* moveControl, const ControlPadInput *input, Navigation* navigation) : ManualControl(moveControl, input) { + this->setInputMode(ManualControl::InputMode::Digital); + this->setDirectionChangeCallback(this->directionChangeSignal); + this->directionChangeSignal = new DirectionChangeSignal(navigation); this->navigation = navigation; this->init(); } Autopilot::~Autopilot() { + delete this->directionChangeSignal; // this->navigation->getNTRIPClient()->setActivated(false); } @@ -121,8 +139,8 @@ void Autopilot::rotate() { if (this->courseCorrection.correction > 0) this->moveControl->setRotationSpeed(-this->rotationSpeed); else - - this->moveControl->setRotationSpeed(this->rotationSpeed); + this->moveControl->setRotationSpeed(this->rotationSpeed); + this->navigation->drivingDirectionChange(); } void Autopilot::checkButtonInput() { diff --git a/src/driveModi/Modi/Autopilot/autopilot.h b/src/driveModi/Modi/Autopilot/autopilot.h index a64c87b..fa33412 100644 --- a/src/driveModi/Modi/Autopilot/autopilot.h +++ b/src/driveModi/Modi/Autopilot/autopilot.h @@ -17,6 +17,16 @@ #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 * @@ -120,6 +130,7 @@ class Autopilot : public ManualControl { State state = State::None; State lastState = State::None; Navigation::Status lastOrderStatus; + DirectionChangeSignal* directionChangeSignal; bool updateDisplay = false; diff --git a/version b/version index e12118d..49d791b 100644 --- a/version +++ b/version @@ -1 +1 @@ -0.8.20 \ No newline at end of file +0.8.21 \ No newline at end of file