doxygen finished

This commit is contained in:
2023-10-12 19:50:10 +02:00
parent db74898b72
commit 5eaeb2749b
39 changed files with 1283 additions and 1019 deletions
+1
View File
@@ -152,6 +152,7 @@
"Rtcm", "Rtcm",
"Schalke", "Schalke",
"Soln", "Soln",
"Systeminformation",
"TPMOBIL", "TPMOBIL",
"UBLOX", "UBLOX",
"wheelspeed", "wheelspeed",
+2
View File
@@ -30,12 +30,14 @@ Do later:
-> ESP und Sensoren in den DeepSleep für Auschalten oder Akkuschutz -> ESP und Sensoren in den DeepSleep für Auschalten oder Akkuschutz
-> Doxygen comments -> Doxygen comments
- navigation - navigation
- autopilot
Do now: Do now:
Code: Code:
Doxygen Kommentare aktualisieren Doxygen Kommentare aktualisieren
Fernbedienung! Fernbedienung!
Compass calibration überprüfen
Latex: Latex:
Anhang: Liste mit allen Komponenten und Kurzbeschreibung Anhang: Liste mit allen Komponenten und Kurzbeschreibung
+13 -13
View File
@@ -26,27 +26,28 @@
#include <BluetoothSerial.h> #include <BluetoothSerial.h>
/** /**
* @brief A alternativ streambuf for std::cout * @brief A alternative streambuf for std::cout
* *
* The streambuf is used to double the std::cout to consol * The streambuf is used to double the std::cout to consol
* and MQTT. * and MQTT.
* *
*/ */
class OutputBuf : public std::streambuf { class OutputBuf : public std::streambuf
public: {
public:
/** /**
* @brief Construct a new Output Buf Mqtt object * @brief Construct a new Output Buf Mqtt object
* *
* @param debugMqtt * @param debugMqtt
* @param serialBT * @param serialBT
*/ */
OutputBuf(DebugMqtt* debugMqtt = nullptr, BluetoothSerial* serialBT = nullptr); OutputBuf(DebugMqtt *debugMqtt = nullptr, BluetoothSerial *serialBT = nullptr);
/** /**
* @brief Activate the mqtt output * @brief Activate the mqtt output
* *
* This only works if the DebugMqtt is set by * This only works if the DebugMqtt is set by
* setDebugMqtt. * setDebugMqtt().
* *
* @param status * @param status
*/ */
@@ -56,17 +57,16 @@ class OutputBuf : public std::streambuf {
* @brief Active the output over the bluetooth serial consol * @brief Active the output over the bluetooth serial consol
* *
* This only works if BluetoothSerial is set by * This only works if BluetoothSerial is set by
* setSerialBT. * setSerialBT().
* *
* @param status * @param status
*/ */
void activateSerialBT(bool status); void activateSerialBT(bool status);
void setDebugMqtt(DebugMqtt* debugMqtt); void setDebugMqtt(DebugMqtt *debugMqtt);
void setSerialBT(BluetoothSerial* serialBT); void setSerialBT(BluetoothSerial *serialBT);
protected:
protected:
/** /**
* @brief * @brief
* *
@@ -75,12 +75,12 @@ class OutputBuf : public std::streambuf {
*/ */
virtual std::streambuf::int_type overflow(std::streambuf::int_type c); virtual std::streambuf::int_type overflow(std::streambuf::int_type c);
private: private:
bool isMqttActive = false; bool isMqttActive = false;
bool isSerialBTActive = false; bool isSerialBTActive = false;
DebugMqtt* debugMqtt; DebugMqtt *debugMqtt;
BluetoothSerial* serialBT; BluetoothSerial *serialBT;
}; };
#endif // OUTPUT_STREAM_MQTT_H #endif // OUTPUT_STREAM_MQTT_H
@@ -1,7 +1,7 @@
/** /**
* @file menuCalibrateBattery.h * @file menuCalibrateBattery.h
* @author Alexander Klein (alex@kleiax.de) * @author Alexander Klein (alex@kleiax.de)
* @brief * @brief Contains a Menu class to calibrate the Battery class
* @version 0.1 * @version 0.1
* @date 2023-09-26 * @date 2023-09-26
* *
@@ -15,13 +15,27 @@
#include "menuControl.h" #include "menuControl.h"
#include "battery.h" #include "battery.h"
/**
* @brief A Menu class to calibrate the Battery class
*/
class MenuCalibrateBattery : public MenuControl class MenuCalibrateBattery : public MenuControl
{ {
public: public:
/**
* @brief Construct a new MenuCalibrateBattery object
*
* Prepare the calibration.
*
* @param battery
*/
MenuCalibrateBattery(Battery *battery); MenuCalibrateBattery(Battery *battery);
/**
* @brief Prints the instructions for the calibration
*/
void printMenu() override; void printMenu() override;
// User Inputs
void left() override; void left() override;
void no() override { this->left(); } void no() override { this->left(); }
void right() override; void right() override;
+7 -7
View File
@@ -20,20 +20,20 @@
* @brief A class to tune the PID settings * @brief A class to tune the PID settings
* *
*/ */
class MenuPidSettings : public MenuIntInputWrapper { class MenuPidSettings : public MenuIntInputWrapper
public: {
public:
/** /**
* @brief Construct a new Menu Pid Settings object * @brief Construct a new Menu Pid Settings object
* *
* @param pid * @param pid
*/ */
MenuPidSettings(PID* pid); MenuPidSettings(PID *pid);
void action(int16_t* values, uint8_t length) override; void action(int16_t *values, uint8_t length) override;
private:
PID* pid;
private:
PID *pid;
}; };
#endif // PID_SETTINGS_H #endif // PID_SETTINGS_H
+7
View File
@@ -111,6 +111,13 @@ public:
*/ */
void exportRoute(uint8_t routeNumber); void exportRoute(uint8_t routeNumber);
/**
* @brief Delete a Route
*
* The functions tries to delete the current route from the RoverApi.
*
* @param routeNumber
*/
void deleteRoute(uint8_t routeNumber); void deleteRoute(uint8_t routeNumber);
/** /**
+6 -6
View File
@@ -20,8 +20,9 @@
* @brief Prints coordinates of Route side by side. * @brief Prints coordinates of Route side by side.
* *
*/ */
class MenuRoutePoints : public MenuInformationSites { class MenuRoutePoints : public MenuInformationSites
public: {
public:
/** /**
* @brief Construct a new Menu Route Points object * @brief Construct a new Menu Route Points object
* *
@@ -34,17 +35,16 @@ class MenuRoutePoints : public MenuInformationSites {
* *
* Set the amount of pages. * Set the amount of pages.
*/ */
void init () override; void init() override;
/** /**
* @brief Prints the the coordinates of the current Point. * @brief Prints the the coordinates of the current Point.
*/ */
void printPage() const override; void printPage() const override;
private: private:
Route* route; Route *route;
bool error = false; bool error = false;
}; };
#endif // MENU_ROUTE_POINTS_H #endif // MENU_ROUTE_POINTS_H
+16 -7
View File
@@ -1,7 +1,7 @@
/** /**
* @file menuSensorData.h * @file menuSensorData.h
* @author Alexander Klein (alex@kleiax.de) * @author Alexander Klein (alex@kleiax.de)
* @brief * @brief Contains a MenuInformationClass to print the SensorData
* @version 0.1 * @version 0.1
* @date 2023-09-04 * @date 2023-09-04
* *
@@ -15,14 +15,23 @@
#include "menuInformationSites.h" #include "menuInformationSites.h"
#include "sensorData.h" #include "sensorData.h"
class MenuSensorData : public MenuInformationSites { /**
public: * @brief A MenuInformationClass to print the SensorData
MenuSensorData(SensorData* SensorData); */
class MenuSensorData : public MenuInformationSites
{
public:
/**
* @brief Construct a new MenuSensorData object
*
* @param SensorData
*/
MenuSensorData(SensorData *SensorData);
private: private:
void printPage() const override; void printPage() const override;
SensorData* sensorData; SensorData *sensorData;
}; };
#endif //MENU_SENSOR_DATA_H #endif // MENU_SENSOR_DATA_H
+4 -2
View File
@@ -11,8 +11,10 @@
#include "menuSpeed.h" #include "menuSpeed.h"
void MenuSpeed::action(int16_t* values, uint8_t length) { void MenuSpeed::action(int16_t *values, uint8_t length)
if (length != 2) { {
if (length != 2)
{
return; return;
} }
this->speeds.x = values[0] / 10.0; this->speeds.x = values[0] / 10.0;
+17 -8
View File
@@ -1,7 +1,7 @@
/** /**
* @file menuSpeed.h * @file menuSpeed.h
* @author Alexander Klein (alex@kleiax.de) * @author Alexander Klein (alex@kleiax.de)
* @brief * @brief Contains a MenuIntInputWrapper to change speeds
* @version 0.1 * @version 0.1
* @date 2023-09-26 * @date 2023-09-26
* *
@@ -15,15 +15,24 @@
#include <menuIntInput.h> #include <menuIntInput.h>
#include "moveControl.h" #include "moveControl.h"
class MenuSpeed : public MenuIntInputWrapper { /**
public: * @brief A MenuIntInputWrapper class to change speeds
MenuSpeed(DrivingSpeeds& speeds) : speeds(speeds){}; */
class MenuSpeed : public MenuIntInputWrapper
{
public:
MenuSpeed(DrivingSpeeds &speeds) : speeds(speeds){};
void action(int16_t* values, uint8_t length) override; /**
* @brief Changes the speeds
private: *
DrivingSpeeds& speeds; * @param values
* @param length
*/
void action(int16_t *values, uint8_t length) override;
private:
DrivingSpeeds &speeds;
}; };
#endif // MENU_SPEED_H #endif // MENU_SPEED_H
@@ -11,15 +11,18 @@
#include "menuSysteminformation.h" #include "menuSysteminformation.h"
MenuSysteminformation::MenuSysteminformation(Battery* mainBattery) MenuSysteminformation::MenuSysteminformation(Battery *mainBattery)
: MenuInformationSites(8), mainBattery {mainBattery} { : MenuInformationSites(8), mainBattery{mainBattery}
{
this->noEqualLeft = true; this->noEqualLeft = true;
} }
void MenuSysteminformation::printPage() const { void MenuSysteminformation::printPage() const
{
String lineOne = ""; String lineOne = "";
String lineTwo = ""; String lineTwo = "";
switch (this->getCurrentPage()) { switch (this->getCurrentPage())
{
case 0: case 0:
lineOne = "Free Heap:"; lineOne = "Free Heap:";
lineTwo.concat(ESP.getFreeHeap()); lineTwo.concat(ESP.getFreeHeap());
@@ -71,4 +74,3 @@ void MenuSysteminformation::printPage() const {
this->print(lineOne, lineTwo); this->print(lineOne, lineTwo);
} }
@@ -26,19 +26,20 @@
* *
* The informations are about the batteries, memory and uptime. * The informations are about the batteries, memory and uptime.
*/ */
class MenuSysteminformation : public MenuInformationSites { class MenuSysteminformation : public MenuInformationSites
public: {
public:
/** /**
* @brief Construct a new Menu Systeminformation object * @brief Construct a new Menu Systeminformation object
* *
* @param mainBattery * @param mainBattery
*/ */
MenuSysteminformation(Battery* mainBattery); MenuSysteminformation(Battery *mainBattery);
private: private:
void printPage() const override; void printPage() const override;
Battery* mainBattery; Battery *mainBattery;
}; };
#endif // MENU_SYSTEMINFORMATION_H #endif // MENU_SYSTEMINFORMATION_H
@@ -19,14 +19,15 @@
* @brief A class to print informations about the Autopilot * @brief A class to print informations about the Autopilot
* *
*/ */
class MenuAutopilot : public MenuDriveMode { class MenuAutopilot : public MenuDriveMode
public: {
public:
/** /**
* @brief Construct a new Menu Autopilot object * @brief Construct a new Menu Autopilot object
* *
* @param driveManager for MenuDriveMode * @param driveManager for MenuDriveMode
*/ */
MenuAutopilot(DriveManager* driveManager) : MenuDriveMode(driveManager) {} MenuAutopilot(DriveManager *driveManager) : MenuDriveMode(driveManager) {}
/** /**
* @brief Prints the Information to display and console * @brief Prints the Information to display and console
@@ -39,13 +40,12 @@ class MenuAutopilot : public MenuDriveMode {
*/ */
void printPage() const override; void printPage() const override;
/** /**
* @brief can be called to update shown data * @brief can be called to update shown data
*/ */
void update() override; void update() override;
private: private:
void init() override; void init() override;
void runCommand() override; void runCommand() override;
void runCommandNo() override; void runCommandNo() override;
@@ -53,7 +53,7 @@ class MenuAutopilot : public MenuDriveMode {
bool mutable targetFreezed = false; bool mutable targetFreezed = false;
double mutable minDistance; double mutable minDistance;
Autopilot* autopilot; Autopilot *autopilot;
RouteInfo routeInfo; RouteInfo routeInfo;
}; };
@@ -10,18 +10,21 @@
*/ */
#include "menuCalibrateCompass.h" #include "menuCalibrateCompass.h"
MenuCalibrateCompass::MenuCalibrateCompass(DriveManager* driveManager) : MenuDriveMode(driveManager) {} MenuCalibrateCompass::MenuCalibrateCompass(DriveManager *driveManager) : MenuDriveMode(driveManager) {}
MenuCalibrateCompass::~MenuCalibrateCompass() { MenuCalibrateCompass::~MenuCalibrateCompass()
{
delete this->caliCompass; delete this->caliCompass;
this->caliCompassMode->setCalibrateCompass(); this->caliCompassMode->setCalibrateCompass();
} }
void MenuCalibrateCompass::printPage() const { void MenuCalibrateCompass::printPage() const
{
String lineOne = ""; String lineOne = "";
String lineTwo = ""; String lineTwo = "";
switch (this->getCurrentPage()) { switch (this->getCurrentPage())
{
case 0: case 0:
lineOne = "-Ready to drive-"; lineOne = "-Ready to drive-";
lineTwo = "Compass Mode"; lineTwo = "Compass Mode";
@@ -33,13 +36,14 @@ void MenuCalibrateCompass::printPage() const {
break; break;
case 2: case 2:
switch (this->caliCompass->getState()) { switch (this->caliCompass->getState())
case CalibrateCompass::State::Ready : {
case CalibrateCompass::State::Ready:
lineOne = "Start compass"; lineOne = "Start compass";
lineTwo = "calibration"; lineTwo = "calibration";
break; break;
case CalibrateCompass::State::Calibrating : case CalibrateCompass::State::Calibrating:
lineOne = "Calibrating..."; lineOne = "Calibrating...";
lineTwo = "Move around"; lineTwo = "Move around";
break; break;
@@ -108,7 +112,8 @@ void MenuCalibrateCompass::printPage() const {
this->print(lineOne, lineTwo); this->print(lineOne, lineTwo);
} }
void MenuCalibrateCompass::init() { void MenuCalibrateCompass::init()
{
this->firstPrint = false; this->firstPrint = false;
this->caliCompassMode = new CalibrateCompassM(); this->caliCompassMode = new CalibrateCompassM();
this->driveManager->changeModus(this->caliCompassMode); this->driveManager->changeModus(this->caliCompassMode);
@@ -117,11 +122,14 @@ void MenuCalibrateCompass::init() {
MenuDriveMode::updateDelay = MenuCalibrateCompass::updateDelay; MenuDriveMode::updateDelay = MenuCalibrateCompass::updateDelay;
} }
void MenuCalibrateCompass::runCommand() { void MenuCalibrateCompass::runCommand()
switch (this->getCurrentPage()) { {
switch (this->getCurrentPage())
{
case 2: case 2:
switch (this->caliCompass->getState()) { switch (this->caliCompass->getState())
case CalibrateCompass::State::Ready : {
case CalibrateCompass::State::Ready:
this->caliCompassMode->setCalibrateCompass(this->caliCompass); this->caliCompassMode->setCalibrateCompass(this->caliCompass);
this->caliCompass->start(); this->caliCompass->start();
break; break;
@@ -20,14 +20,15 @@
* @brief A class to print informations about the class ManualControl * @brief A class to print informations about the class ManualControl
* *
*/ */
class MenuCalibrateCompass : public MenuDriveMode { class MenuCalibrateCompass : public MenuDriveMode
public: {
public:
/** /**
* @brief Construct a new Menu Manual Control object * @brief Construct a new Menu Manual Control object
* *
* @param driveManager * @param driveManager
*/ */
MenuCalibrateCompass(DriveManager* driveManager); MenuCalibrateCompass(DriveManager *driveManager);
~MenuCalibrateCompass(); ~MenuCalibrateCompass();
/** /**
@@ -40,13 +41,12 @@ class MenuCalibrateCompass : public MenuDriveMode {
*/ */
void printPage() const override; void printPage() const override;
protected: private:
void init() override; void init() override;
void runCommand() override; void runCommand() override;
private: CalibrateCompassM *caliCompassMode = nullptr;
CalibrateCompassM* caliCompassMode = nullptr; CalibrateCompass *caliCompass = nullptr;
CalibrateCompass* caliCompass = nullptr;
static constexpr uint16_t updateDelay = 500; static constexpr uint16_t updateDelay = 500;
}; };
@@ -18,14 +18,15 @@
* @brief A class to print informations about the Autopilot * @brief A class to print informations about the Autopilot
* *
*/ */
class MenuCaptureRoute : public MenuDriveMode { class MenuCaptureRoute : public MenuDriveMode
public: {
public:
/** /**
* @brief Construct a new Menu Capture Route object * @brief Construct a new Menu Capture Route object
* *
* @param driveManager * @param driveManager
*/ */
MenuCaptureRoute(DriveManager* driveManager) : MenuDriveMode(driveManager) {} MenuCaptureRoute(DriveManager *driveManager) : MenuDriveMode(driveManager) {}
/** /**
* @brief Prints the Information to display and console * @brief Prints the Information to display and console
@@ -43,12 +44,11 @@ class MenuCaptureRoute : public MenuDriveMode {
*/ */
void update() override; void update() override;
private:
void runCommand() override; void runCommand() override;
private:
void init() override; void init() override;
CaptureRoute* captureRoute = nullptr; CaptureRoute *captureRoute = nullptr;
static constexpr uint16_t updateDelay = 500; static constexpr uint16_t updateDelay = 500;
}; };
@@ -10,26 +10,30 @@
*/ */
#include "menuManualDrive.h" #include "menuManualDrive.h"
MenuManualControl::MenuManualControl(DriveManager* driveManager) : MenuDriveMode(driveManager) { MenuManualControl::MenuManualControl(DriveManager *driveManager) : MenuDriveMode(driveManager)
{
this->noEqualLeft = true; this->noEqualLeft = true;
} }
void MenuManualControl::printPage() const
void MenuManualControl::printPage() const { {
String lineOne = ""; String lineOne = "";
String lineTwo = ""; String lineTwo = "";
switch (this->getCurrentPage()) { switch (this->getCurrentPage())
{
case 0: case 0:
lineOne = "-Ready to drive-"; lineOne = "-Ready to drive-";
break; break;
case 1: case 1:
lineOne = "Input mode:"; lineOne = "Input mode:";
if (this->manualControl->getInputMode() == ManualControl::InputMode::Analog) { if (this->manualControl->getInputMode() == ManualControl::InputMode::Analog)
{
lineTwo = "Analog"; lineTwo = "Analog";
} }
else { else
{
lineTwo = "Digital"; lineTwo = "Digital";
} }
break; break;
@@ -50,7 +54,8 @@ void MenuManualControl::printPage() const {
this->print(lineOne, lineTwo); this->print(lineOne, lineTwo);
} }
void MenuManualControl::init() { void MenuManualControl::init()
{
this->firstPrint = false; this->firstPrint = false;
this->manualControl = new ManualControl(); this->manualControl = new ManualControl();
this->driveManager->changeModus(this->manualControl); this->driveManager->changeModus(this->manualControl);
@@ -60,8 +65,10 @@ void MenuManualControl::init() {
MenuDriveMode::init(); MenuDriveMode::init();
} }
void MenuManualControl::runCommand() { void MenuManualControl::runCommand()
switch (this->getCurrentPage()) { {
switch (this->getCurrentPage())
{
case 1: case 1:
this->manualControl->switchInputMode(); this->manualControl->switchInputMode();
break; break;
@@ -19,14 +19,15 @@
* @brief A class to print informations about the class ManualControl * @brief A class to print informations about the class ManualControl
* *
*/ */
class MenuManualControl : public MenuDriveMode { class MenuManualControl : public MenuDriveMode
public: {
public:
/** /**
* @brief Construct a new Menu Manual Control object * @brief Construct a new Menu Manual Control object
* *
* @param driveManager * @param driveManager
*/ */
MenuManualControl(DriveManager* driveManager); MenuManualControl(DriveManager *driveManager);
/** /**
* @brief Prints the Information to display and console * @brief Prints the Information to display and console
@@ -38,13 +39,12 @@ class MenuManualControl : public MenuDriveMode {
*/ */
void printPage() const override; void printPage() const override;
protected: private:
void init() override; void init() override;
void runCommand() override; void runCommand() override;
private: ManualControl *manualControl = nullptr;
ManualControl* manualControl = nullptr; CalibrateCompass *caliCompass = nullptr;
CalibrateCompass* caliCompass = nullptr;
static constexpr uint16_t updateDelay = 500; static constexpr uint16_t updateDelay = 500;
}; };
@@ -10,19 +10,23 @@
*/ */
#include "menuTestMode.h" #include "menuTestMode.h"
MenuTestMode::MenuTestMode(DriveManager* driveManager) MenuTestMode::MenuTestMode(DriveManager *driveManager)
: driveManager {driveManager} : driveManager{driveManager}
{ {
} }
MenuTestMode::~MenuTestMode() { MenuTestMode::~MenuTestMode()
if (isInit) { {
if (isInit)
{
delete this->mainMenu; delete this->mainMenu;
} }
} }
void MenuTestMode::printMenu() { void MenuTestMode::printMenu()
if (!this->isInit) { {
if (!this->isInit)
{
this->isInit = true; this->isInit = true;
this->init(); this->init();
} }
@@ -30,62 +34,82 @@ void MenuTestMode::printMenu() {
this->mainMenu->printMenu(); this->mainMenu->printMenu();
} }
void MenuTestMode::down() { void MenuTestMode::down()
if (this->checkInput()) { {
if (this->checkInput())
{
this->mainMenu->down(); this->mainMenu->down();
} }
} }
void MenuTestMode::up() { void MenuTestMode::up()
if (this->checkInput()) { {
if (this->checkInput())
{
this->mainMenu->up(); this->mainMenu->up();
} }
} }
void MenuTestMode::right() { void MenuTestMode::right()
if (this->checkInput()) { {
if (this->checkInput())
{
this->mainMenu->right(); this->mainMenu->right();
} }
} }
void MenuTestMode::left() { void MenuTestMode::left()
{
if (this->mainMenu->isInSubmenu()) if (this->mainMenu->isInSubmenu())
if (this->checkInput()) { if (this->checkInput())
{
this->mainMenu->left(); this->mainMenu->left();
} }
else { else
{
this->testMode->abortManeuver(); this->testMode->abortManeuver();
this->mainMenu->left(); this->mainMenu->left();
} }
else { else
{
this->parentMenu->printMenu(); this->parentMenu->printMenu();
} }
} }
void MenuTestMode::yes() { void MenuTestMode::yes()
if (this->checkInput()) { {
if (this->checkInput())
{
this->mainMenu->yes(); this->mainMenu->yes();
} }
} }
void MenuTestMode::no() { void MenuTestMode::no()
if (this->mainMenu->isInSubmenu()) { {
if (this->mainMenu->isInSubmenu())
{
if (this->checkInput()) if (this->checkInput())
this->mainMenu->no(); this->mainMenu->no();
else { else
{
this->testMode->abortManeuver(); this->testMode->abortManeuver();
this->mainMenu->no(); this->mainMenu->no();
}} }
else{ }
this->left();} else
{
this->left();
}
} }
void MenuTestMode::init() { void MenuTestMode::init()
{
this->testMode = new TestMode(); this->testMode = new TestMode();
this->driveManager->changeModus(this->testMode); this->driveManager->changeModus(this->testMode);
auto dummy = []() { auto dummy = []()
std::cout << "Dummy in Action" <<std::endl; {
std::cout << "Dummy in Action" << std::endl;
}; };
// Create menu // Create menu
@@ -103,7 +127,6 @@ void MenuTestMode::init() {
auto *encoderLeftMenu = new SpeedometerTest(this->testMode->getSpeedometerLeft()); auto *encoderLeftMenu = new SpeedometerTest(this->testMode->getSpeedometerLeft());
auto *encoderRightMenu = new SpeedometerTest(this->testMode->getSpeedometerRight()); auto *encoderRightMenu = new SpeedometerTest(this->testMode->getSpeedometerRight());
// Set menus on LCD // Set menus on LCD
this->mainMenu->setLcd(this->lcd); this->mainMenu->setLcd(this->lcd);
engineMenu->setLcd(this->lcd); engineMenu->setLcd(this->lcd);
@@ -143,7 +166,6 @@ void MenuTestMode::init() {
engineBothMenu->setMinMaxSteps(1, 0, secondsMax, 1); engineBothMenu->setMinMaxSteps(1, 0, secondsMax, 1);
engineBothMenu->setPrintParentMenu(false); engineBothMenu->setPrintParentMenu(false);
// Entrys for the menus // Entrys for the menus
auto *engineAction = new MenuAction("Engine", engineMenu); auto *engineAction = new MenuAction("Engine", engineMenu);
auto *engineLeftAction = new MenuAction("Left", engineLeftMenu); auto *engineLeftAction = new MenuAction("Left", engineLeftMenu);
@@ -185,70 +207,85 @@ void MenuTestMode::init() {
lightMenu->addEntry(lightOffAction); lightMenu->addEntry(lightOffAction);
} }
void MenuTestMode::update() { void MenuTestMode::update()
if (this->maneuverInAction) { {
if (millis() - this->lastUpdateTime > updateDelay) { if (this->maneuverInAction)
{
if (millis() - this->lastUpdateTime > updateDelay)
{
this->printManeuverTime(); this->printManeuverTime();
this->lastUpdateTime = millis(); this->lastUpdateTime = millis();
}} }
}
} }
bool MenuTestMode::checkInput() { bool MenuTestMode::checkInput()
if (this->testMode->getBusy()) { {
if (this->testMode->getBusy())
{
this->printManeuverTime(); this->printManeuverTime();
this->maneuverInAction = true; this->maneuverInAction = true;
return false; return false;
} }
if (this->maneuverInAction) { if (this->maneuverInAction)
{
this->maneuverInAction = false; this->maneuverInAction = false;
} }
return true; return true;
} }
void MenuTestMode::printManeuverTime() { void MenuTestMode::printManeuverTime()
{
uint8_t maneuverTime = this->testMode->getRemainingManeuverTime(); uint8_t maneuverTime = this->testMode->getRemainingManeuverTime();
if (maneuverTime) { if (maneuverTime)
{
String lineTwo = ""; String lineTwo = "";
lineTwo.concat(maneuverTime); lineTwo.concat(maneuverTime);
lineTwo.concat(" secs"); lineTwo.concat(" secs");
this->print("Maneuver time:", lineTwo); this->print("Maneuver time:", lineTwo);
} else { }
else
{
this->maneuverInAction = false; this->maneuverInAction = false;
this->printMenu(); this->printMenu();
} }
} }
MenuTestModeWrapper::MenuTestModeWrapper(MenuTestMode* menu, TestModeFunctionSingle testModeFunction) MenuTestModeWrapper::MenuTestModeWrapper(MenuTestMode *menu, TestModeFunctionSingle testModeFunction)
: menu {menu}, : menu{menu},
testModeFunctionSingle {testModeFunction}, testModeFunctionSingle{testModeFunction},
testMode {menu->getTestMode()} testMode{menu->getTestMode()}
{ {
} }
MenuTestModeWrapper::MenuTestModeWrapper(MenuTestMode* menu, TestModeFunctionDouble testModeFunction) MenuTestModeWrapper::MenuTestModeWrapper(MenuTestMode *menu, TestModeFunctionDouble testModeFunction)
: menu {menu}, : menu{menu},
testModeFunctionDouble {testModeFunction}, testModeFunctionDouble{testModeFunction},
testMode {menu->getTestMode()} testMode{menu->getTestMode()}
{ {
} }
void MenuTestModeWrapper::action(int16_t* values, uint8_t length) { void MenuTestModeWrapper::action(int16_t *values, uint8_t length)
{
// This function calls a member function with a pointer // This function calls a member function with a pointer
// Very helpful site: // Very helpful site:
// https://isocpp.org/wiki/faq/pointers-to-members#fnptr-vs-memfnptr-types // https://isocpp.org/wiki/faq/pointers-to-members#fnptr-vs-memfnptr-types
bool res = false; bool res = false;
if (length == 2 && static_cast<bool>(this->testModeFunctionDouble)) { if (length == 2 && static_cast<bool>(this->testModeFunctionDouble))
{
res = (this->testMode->*this->testModeFunctionDouble)(values[0], values[1]); res = (this->testMode->*this->testModeFunctionDouble)(values[0], values[1]);
} }
else if (length == 1 && static_cast<bool>(this->testModeFunctionSingle)) { else if (length == 1 && static_cast<bool>(this->testModeFunctionSingle))
{
res = (this->testMode->*this->testModeFunctionSingle)(values[0]); res = (this->testMode->*this->testModeFunctionSingle)(values[0]);
} }
if (res) { if (res)
{
this->menu->printManeuverTime(); this->menu->printManeuverTime();
this->menu->maneuverStarted(); this->menu->maneuverStarted();
} }
@@ -22,8 +22,9 @@
* @brief Interact with the TestMode * @brief Interact with the TestMode
* *
*/ */
class MenuTestMode : public MenuControl { class MenuTestMode : public MenuControl
public: {
public:
/** /**
* @brief Construct a new Menu Test Mode object * @brief Construct a new Menu Test Mode object
* *
@@ -62,16 +63,16 @@ class MenuTestMode : public MenuControl {
*/ */
void update() override; void update() override;
TestMode* getTestMode() const { return this->testMode; } TestMode *getTestMode() const { return this->testMode; }
void maneuverStarted() { this->maneuverInAction = true; } void maneuverStarted() { this->maneuverInAction = true; }
private: private:
void init(); void init();
bool checkInput(); bool checkInput();
DriveManager* driveManager; DriveManager *driveManager;
TestMode* testMode = nullptr; TestMode *testMode = nullptr;
Menu* mainMenu = nullptr; Menu *mainMenu = nullptr;
bool isInit = false; bool isInit = false;
bool maneuverInAction = false; bool maneuverInAction = false;
@@ -82,16 +83,17 @@ class MenuTestMode : public MenuControl {
typedef bool (TestMode::*TestModeFunctionSingle)(int16_t); typedef bool (TestMode::*TestModeFunctionSingle)(int16_t);
typedef bool (TestMode::*TestModeFunctionDouble)(int16_t, int16_t); typedef bool (TestMode::*TestModeFunctionDouble)(int16_t, int16_t);
class MenuTestModeWrapper : public MenuIntInputWrapper { class MenuTestModeWrapper : public MenuIntInputWrapper
public: {
MenuTestModeWrapper(MenuTestMode* menu, TestModeFunctionSingle testModeFunction); public:
MenuTestModeWrapper(MenuTestMode* menu, TestModeFunctionDouble testModeFunction); MenuTestModeWrapper(MenuTestMode *menu, TestModeFunctionSingle testModeFunction);
MenuTestModeWrapper(MenuTestMode *menu, TestModeFunctionDouble testModeFunction);
void action(int16_t* values, uint8_t length) override; void action(int16_t *values, uint8_t length) override;
private: private:
MenuTestMode* menu; MenuTestMode *menu;
TestMode* testMode; TestMode *testMode;
TestModeFunctionSingle testModeFunctionSingle = nullptr; TestModeFunctionSingle testModeFunctionSingle = nullptr;
TestModeFunctionDouble testModeFunctionDouble = nullptr; TestModeFunctionDouble testModeFunctionDouble = nullptr;
}; };
@@ -11,24 +11,26 @@
#include "speedometerTest.h" #include "speedometerTest.h"
SpeedometerTest::SpeedometerTest(Speedometer* speedometer) SpeedometerTest::SpeedometerTest(Speedometer *speedometer)
: speedometer {speedometer} : speedometer{speedometer}
{ {
this->speedometer->setDirection(Speedometer::Forward); this->speedometer->setDirection(Speedometer::Forward);
} }
void SpeedometerTest::printMenu()
void SpeedometerTest::printMenu() { {
switch (this->state) { switch (this->state)
case State::Off : {
case State::Off:
this->print("Press Yes (O)", "to start"); this->print("Press Yes (O)", "to start");
break; break;
case State::Running : case State::Running:
this->print("Running, Yes (O)", "to stop"); this->print("Running, Yes (O)", "to stop");
break; break;
case State::Finished : { case State::Finished:
{
String res = ""; String res = "";
res.concat(this->result); res.concat(this->result);
this->print("Result: ", res); this->print("Result: ", res);
@@ -41,13 +43,15 @@ void SpeedometerTest::printMenu() {
} }
} }
void SpeedometerTest::left()
void SpeedometerTest::left() { {
this->no(); this->no();
} }
void SpeedometerTest::no() { void SpeedometerTest::no()
if (this->state == State::Running){ {
if (this->state == State::Running)
{
speedometer->calibrationMeasurementStop(); speedometer->calibrationMeasurementStop();
} }
@@ -55,21 +59,23 @@ void SpeedometerTest::no() {
this->parentMenu->printMenu(); this->parentMenu->printMenu();
} }
void SpeedometerTest::yes() { void SpeedometerTest::yes()
switch (this->state) { {
case State::Off : switch (this->state)
{
case State::Off:
this->state = State::Running; this->state = State::Running;
this->speedometer->calibrationMeasurementStart(); this->speedometer->calibrationMeasurementStart();
this->printMenu(); this->printMenu();
break; break;
case State::Running : case State::Running:
this->state = State::Finished; this->state = State::Finished;
this->result = this->speedometer->calibrationMeasurementStop(); this->result = this->speedometer->calibrationMeasurementStop();
this->printMenu(); this->printMenu();
break; break;
case State::Finished : case State::Finished:
this->state = State::Running; this->state = State::Running;
this->speedometer->calibrationMeasurementStart(); this->speedometer->calibrationMeasurementStart();
this->printMenu(); this->printMenu();
@@ -18,12 +18,14 @@
* @brief Tests the wheel encoder. * @brief Tests the wheel encoder.
* *
*/ */
class SpeedometerTest : public MenuControl { class SpeedometerTest : public MenuControl
public: {
public:
/** /**
* @brief The states of the test. * @brief The states of the test.
*/ */
enum State { enum State
{
Off, Off,
Running, Running,
Finished Finished
@@ -34,7 +36,7 @@ class SpeedometerTest : public MenuControl {
* *
* @param speedometer * @param speedometer
*/ */
SpeedometerTest(Speedometer* speedometer); SpeedometerTest(Speedometer *speedometer);
/** /**
* @brief Prints the actual state of the test. * @brief Prints the actual state of the test.
@@ -56,8 +58,8 @@ class SpeedometerTest : public MenuControl {
*/ */
void yes() override; void yes() override;
private: private:
Speedometer* speedometer; Speedometer *speedometer;
State state = State::Off; State state = State::Off;
uint16_t result = 0; uint16_t result = 0;
+74 -26
View File
@@ -11,14 +11,36 @@
#include "menuDriveMode.h" #include "menuDriveMode.h"
MenuDriveMode::MenuDriveMode(DriveManager* driveManager) MenuDriveMode::MenuDriveMode(DriveManager *driveManager)
: driveManager {driveManager} : driveManager{driveManager}
{ {
} }
void MenuDriveMode::left() { MenuDriveMode::~MenuDriveMode()
if (static_cast<bool>(this->activeMenu)) { {
if (static_cast<bool>(this->activeMenu)) { if (this->selfCreatedMenuSpeed)
{
delete this->menuSpeed;
}
}
void MenuDriveMode::addSpeedMenu(MenuIntInput *menuSpeed)
{
if (this->selfCreatedMenuSpeed)
{
delete this->menuSpeed;
this->selfCreatedMenuSpeed = false;
}
this->menuSpeed = menuSpeed;
}
void MenuDriveMode::left()
{
if (static_cast<bool>(this->activeMenu))
{
if (static_cast<bool>(this->activeMenu))
{
this->activeMenu->left(); this->activeMenu->left();
} }
return; return;
@@ -31,52 +53,65 @@ void MenuDriveMode::left() {
MenuInformationSites::left(); MenuInformationSites::left();
} }
void MenuDriveMode::right() { void MenuDriveMode::right()
if (static_cast<bool>(this->activeMenu)) { {
if (static_cast<bool>(this->activeMenu))
{
this->activeMenu->right(); this->activeMenu->right();
return; return;
} }
MenuInformationSites::right(); MenuInformationSites::right();
} }
void MenuDriveMode::up() { void MenuDriveMode::up()
if (static_cast<bool>(this->activeMenu)) { {
if (static_cast<bool>(this->activeMenu))
{
this->activeMenu->up(); this->activeMenu->up();
return; return;
} }
MenuInformationSites::up(); MenuInformationSites::up();
} }
void MenuDriveMode::down() { void MenuDriveMode::down()
if (static_cast<bool>(this->activeMenu)) { {
if (static_cast<bool>(this->activeMenu))
{
this->activeMenu->down(); this->activeMenu->down();
return; return;
} }
MenuInformationSites::down(); MenuInformationSites::down();
} }
void MenuDriveMode::yes() { void MenuDriveMode::yes()
if (static_cast<bool>(this->activeMenu)) { {
if (static_cast<bool>(this->activeMenu))
{
this->activeMenu->yes(); this->activeMenu->yes();
return; return;
} }
MenuInformationSites::yes(); MenuInformationSites::yes();
} }
void MenuDriveMode::no() { void MenuDriveMode::no()
if (static_cast<bool>(this->activeMenu)) { {
if (static_cast<bool>(this->activeMenu))
{
this->activeMenu->no(); this->activeMenu->no();
return; return;
} }
MenuInformationSites::no(); MenuInformationSites::no();
} }
void MenuDriveMode::prepareReenterMenu() { void MenuDriveMode::prepareReenterMenu()
{
this->activeMenu = nullptr; this->activeMenu = nullptr;
} }
void MenuDriveMode::printMenu() { void MenuDriveMode::printMenu()
if (static_cast<bool>(this->activeMenu)) { {
if (static_cast<bool>(this->activeMenu))
{
this->activeMenu->printMenu(); this->activeMenu->printMenu();
return; return;
} }
@@ -84,37 +119,50 @@ void MenuDriveMode::printMenu() {
MenuInformationSites::printMenu(); MenuInformationSites::printMenu();
} }
void MenuDriveMode::init() { void MenuDriveMode::init()
{
this->activeMenu = nullptr; this->activeMenu = nullptr;
} }
void MenuDriveMode::activateSpeedMenu() { void MenuDriveMode::activateSpeedMenu()
if (!this->driveManager->isActive()) { {
if (!this->driveManager->isActive())
{
return; return;
} }
DrivingSpeeds& speeds = this->driveManager->getDriveModiPtr()->getSpeedsRef(); if (this->selfCreatedMenuSpeed)
{
delete this->menuSpeed;
}
DrivingSpeeds &speeds = this->driveManager->getDriveModiPtr()->getSpeedsRef();
auto *menu = new MenuIntInput(2, new MenuSpeed(speeds)); auto *menu = new MenuIntInput(2, new MenuSpeed(speeds));
menu->setMinMax(5, UINT8_MAX); menu->setMinMax(5, UINT8_MAX);
menu->setEntry(0, "x m/s e-1", driveManager->getDrivingSpeedsRef().x * 10); menu->setEntry(0, "x m/s e-1", driveManager->getDrivingSpeedsRef().x * 10);
menu->setEntry(1, "z rad/s e-1", driveManager->getDrivingSpeedsRef().rot * 10); menu->setEntry(1, "z rad/s e-1", driveManager->getDrivingSpeedsRef().rot * 10);
this->selfCreatedMenuSpeed = true;
this->addSpeedMenu(menu); this->addSpeedMenu(menu);
} }
void MenuDriveMode::enterSpeedMenu() { void MenuDriveMode::enterSpeedMenu()
{
this->activeMenu = this->menuSpeed; this->activeMenu = this->menuSpeed;
this->enterMenu(); this->enterMenu();
} }
void MenuDriveMode::enterSensorMenu() { void MenuDriveMode::enterSensorMenu()
{
this->activeMenu = this->menuSensor; this->activeMenu = this->menuSensor;
this->enterMenu(); this->enterMenu();
} }
void MenuDriveMode::enterMenu() { void MenuDriveMode::enterMenu()
if (!static_cast<bool>(this->activeMenu)) { {
if (!static_cast<bool>(this->activeMenu))
{
return; return;
} }
+42 -11
View File
@@ -20,17 +20,20 @@
* @brief A base class for Menus about DriveModi * @brief A base class for Menus about DriveModi
* *
*/ */
class MenuDriveMode : public MenuInformationSites { class MenuDriveMode : public MenuInformationSites
public: {
public:
/** /**
* @brief Construct a new Menu Drive Mode object * @brief Construct a new Menu Drive Mode object
* *
* @param driveManager * @param driveManager
*/ */
MenuDriveMode(DriveManager* driveManager); MenuDriveMode(DriveManager *driveManager);
void addSensorMenu(MenuSensorData* menuSensor) { this->menuSensor = menuSensor; } ~MenuDriveMode();
void addSpeedMenu(MenuIntInput* menuSpeed) { this->menuSpeed = menuSpeed; }
void addSensorMenu(MenuSensorData *menuSensor) { this->menuSensor = menuSensor; }
void addSpeedMenu(MenuIntInput *menuSpeed);
/** /**
* @brief Goes back to the parentMenu. * @brief Goes back to the parentMenu.
@@ -45,22 +48,50 @@ class MenuDriveMode : public MenuInformationSites {
void prepareReenterMenu() override; void prepareReenterMenu() override;
void printMenu() override; void printMenu() override;
protected: protected:
void init() override; void init() override;
/**
* @brief Prepare leaving the menu
*
* Can be overwritten to add extra functionality to safely
* exit the menu. This function is called before the parentMenu
* is printed.
*/
virtual void configureOnLeave() {} virtual void configureOnLeave() {}
/**
* @brief Creates an own SpeedMenu
*
* This function uses addSpeedMenu() at the end to that the new menu
*/
void activateSpeedMenu(); void activateSpeedMenu();
/**
* @brief Enter a Menu to edit the speeds
*
* To enter this menu it has to be set by addSpeedMenu() or activateSpeedMenu()
*/
void enterSpeedMenu(); void enterSpeedMenu();
/**
* @brief Enter a Menu with the SensorData
*
* To enter this menu it has to be set by addSensorMenu()
*/
void enterSensorMenu(); void enterSensorMenu();
DriveManager* driveManager; DriveManager *driveManager;
bool firstPrint = true; bool firstPrint = true;
private: private:
void enterMenu(); void enterMenu();
MenuControl* activeMenu = nullptr; MenuControl *activeMenu = nullptr;
MenuSensorData* menuSensor = nullptr; MenuSensorData *menuSensor = nullptr;
MenuIntInput* menuSpeed = nullptr; MenuIntInput *menuSpeed = nullptr;
bool selfCreatedMenuSpeed = false;
}; };
#endif // MENU_DRIVE_MODI_H #endif // MENU_DRIVE_MODI_H
+15 -13
View File
@@ -12,7 +12,6 @@
#ifndef AUTOPILOT_H #ifndef AUTOPILOT_H
#define AUTOPILOT_H #define AUTOPILOT_H
#include "navigation.h" #include "navigation.h"
#include "driveModi/Modi/ManualControl/manualControl.h" #include "driveModi/Modi/ManualControl/manualControl.h"
@@ -27,9 +26,11 @@ class DirectionChangeSignal;
* switch to automatic drive. * switch to automatic drive.
* *
*/ */
class Autopilot : public ManualControl { class Autopilot : public ManualControl
public: {
enum State { public:
enum State
{
InsufficientAccuracy = -2, InsufficientAccuracy = -2,
NoRoute = -1, NoRoute = -1,
None = 0, None = 0,
@@ -70,7 +71,7 @@ class Autopilot : public ManualControl {
* @return State * @return State
*/ */
State getState() const { return this->state; } State getState() const { return this->state; }
Navigation* getNavigation() const { return this->navigation; } Navigation *getNavigation() const { return this->navigation; }
/** /**
* @brief Tells if there are new informations to display * @brief Tells if there are new informations to display
@@ -84,7 +85,7 @@ class Autopilot : public ManualControl {
void switchLoopMode() { this->loopMode = !this->loopMode; } void switchLoopMode() { this->loopMode = !this->loopMode; }
bool getLoopMode() const { return this->loopMode; } bool getLoopMode() const { return this->loopMode; }
private: private:
void init(); void init();
void drive(); void drive();
void beginRotate(); void beginRotate();
@@ -96,13 +97,13 @@ class Autopilot : public ManualControl {
void restartLoop(); void restartLoop();
void afterActivate() override; void afterActivate() override;
Navigation* navigation = nullptr; Navigation *navigation = nullptr;
CourseCorrection courseCorrection{0, 0}; CourseCorrection courseCorrection{0, 0};
RouteInfo routeInfo{0, 0}; RouteInfo routeInfo{0, 0};
State state = State::None; State state = State::None;
State lastState = State::None; State lastState = State::None;
Navigation::Status lastOrderStatus; Navigation::Status lastOrderStatus;
DirectionChangeSignal* directionChangeSignal = nullptr; DirectionChangeSignal *directionChangeSignal = nullptr;
bool updateDisplay = false; bool updateDisplay = false;
bool loopMode = false; bool loopMode = false;
@@ -116,14 +117,15 @@ class Autopilot : public ManualControl {
double minRemainingDistance = 0.25; double minRemainingDistance = 0.25;
}; };
class DirectionChangeSignal : public DirectionChangeWrapper { class DirectionChangeSignal : public DirectionChangeWrapper
public: {
DirectionChangeSignal(Autopilot* pilot); public:
DirectionChangeSignal(Autopilot *pilot);
~DirectionChangeSignal(); ~DirectionChangeSignal();
void action() override; void action() override;
private: private:
Autopilot* pilot; Autopilot *pilot;
}; };
#endif // AUTOPILOT_H #endif // AUTOPILOT_H
@@ -11,12 +11,15 @@
#include "calibrateCompassM.h" #include "calibrateCompassM.h"
void CalibrateCompassM::setCalibrateCompass(CalibrateCompass *caliCompass)
void CalibrateCompassM::setCalibrateCompass(CalibrateCompass *caliCompass) { {
if (static_cast<bool>(caliCompass)) { if (static_cast<bool>(caliCompass))
{
this->caliCompass = caliCompass; this->caliCompass = caliCompass;
this->addChildComponent(this->caliCompass); this->addChildComponent(this->caliCompass);
} else if (static_cast<bool>(this->caliCompass)) { }
else if (static_cast<bool>(this->caliCompass))
{
this->removeChildComponent(this->caliCompass); this->removeChildComponent(this->caliCompass);
this->caliCompass = caliCompass; this->caliCompass = caliCompass;
} }
@@ -1,7 +1,7 @@
/** /**
* @file calibrateCompassM.h * @file calibrateCompassM.h
* @author Alexander Klein (alex@kleiax.de) * @author Alexander Klein (alex@kleiax.de)
* @brief * @brief Contains a Menu class to calibrate the compass
* @version 0.1 * @version 0.1
* @date 2023-09-03 * @date 2023-09-03
* *
@@ -16,12 +16,21 @@
#include "driveModi/Modi/ManualControl/manualControl.h" #include "driveModi/Modi/ManualControl/manualControl.h"
class CalibrateCompassM : public ManualControl { /**
public: * @brief A Menu class to interact with CalibrateCompass class
void setCalibrateCompass(CalibrateCompass* caliCompass = nullptr); */
class CalibrateCompassM : public ManualControl
{
public:
/**
* @brief Set the CalibrateCompass object
*
* @param caliCompass
*/
void setCalibrateCompass(CalibrateCompass *caliCompass = nullptr);
private: private:
CalibrateCompass* caliCompass = nullptr; CalibrateCompass *caliCompass = nullptr;
}; };
#endif //CALIBRATE_COMPASS_M_H #endif // CALIBRATE_COMPASS_M_H
+8 -12
View File
@@ -25,8 +25,9 @@
* you can add a Point everytime you want. * you can add a Point everytime you want.
* *
*/ */
class CaptureRoute : public ManualControl { class CaptureRoute : public ManualControl
public: {
public:
/** /**
* @brief Destroy the Capture Route object * @brief Destroy the Capture Route object
* *
@@ -34,21 +35,15 @@ class CaptureRoute : public ManualControl {
*/ */
~CaptureRoute(); ~CaptureRoute();
// /**
// * @brief Get the Navigation object
// *
// * @return Navigation*
// */
// Navigation* getNavigation() const { return this->navigation; }
/** /**
* @brief Get the Route Info object * @brief Get the Route Info object
* *
* @return RouteInfo * @return RouteInfo
*/ */
RouteInfo getRouteInfo() const { return this->routeInfo; } RouteInfo getRouteInfo() const { return this->routeInfo; }
Navigation::Status getLastStatus() const { return this->status; } Navigation::Status getLastStatus() const { return this->status; }
Navigation* getNavigation() const { return this->navigation; } Navigation *getNavigation() const { return this->navigation; }
/** /**
* @brief Get the distance to the last saved oint * @brief Get the distance to the last saved oint
@@ -64,11 +59,12 @@ class CaptureRoute : public ManualControl {
* @return false * @return false
*/ */
bool shouldUpdate(); bool shouldUpdate();
private:
private:
void run() override; void run() override;
void afterActivate() override; void afterActivate() override;
Navigation* navigation = nullptr; Navigation *navigation = nullptr;
RouteInfo routeInfo; RouteInfo routeInfo;
Point lastSavedPoint; Point lastSavedPoint;
Navigation::Status status = Navigation::Status::Complete; Navigation::Status status = Navigation::Status::Complete;
@@ -13,43 +13,60 @@
#include "driveModi/driveModi.h" #include "driveModi/driveModi.h"
class DirectionChangeWrapper { class DirectionChangeWrapper
public: {
public:
virtual void action() = 0; virtual void action() = 0;
}; };
/** /**
* @brief Drive the Rover with a Joystick * @brief Drive the Rover with a Joystick
* *
* This class gets the x and y value from the PS3 controller * This class gets the x and y value from the ControlPad
* and map the values to moveControl * and map the values to moveControl
* *
* @see MoveControl * @see MoveControl
*/ */
class ManualControl : public DriveModi { class ManualControl : public DriveModi
public: {
enum class InputMode : uint8_t { public:
/**
* @brief The enum is used to change the interpretation of the joystick data
*/
enum class InputMode : uint8_t
{
Analog, Analog,
Digital Digital
}; };
/**
* @brief Change the InputMode to the opposite
*/
void switchInputMode(); void switchInputMode();
void setInputMode(InputMode mode) { this->inputMode = mode; } void setInputMode(InputMode mode) { this->inputMode = mode; }
InputMode getInputMode() const { return this->inputMode; } InputMode getInputMode() const { return this->inputMode; }
void setDirectionChangeCallback(DirectionChangeWrapper* callback) { this->directionChangeWrapper = callback; }
/**
* @brief Set the DirectionChangeWrapper object
*
* This callback is used to inform the CalcAzimuth Component about a direction change
*
* @param callback
*/
void setDirectionChangeCallback(DirectionChangeWrapper *callback) { this->directionChangeWrapper = callback; }
uint16_t getDutycycleLeft() const { return this->moveControl->getDutycycleLeft(); } uint16_t getDutycycleLeft() const { return this->moveControl->getDutycycleLeft(); }
uint16_t getDutycycleRight() const { return this->moveControl->getDutycycleRight(); } uint16_t getDutycycleRight() const { return this->moveControl->getDutycycleRight(); }
protected: protected:
void run() override; void run() override;
private: private:
void analogControl(); void analogControl();
void digitalControl(); void digitalControl();
bool lastLoopTurned = false; bool lastLoopTurned = false;
DirectionChangeWrapper* directionChangeWrapper = nullptr; DirectionChangeWrapper *directionChangeWrapper = nullptr;
InputMode inputMode = InputMode::Analog; InputMode inputMode = InputMode::Analog;
}; };
+24 -12
View File
@@ -15,7 +15,8 @@ void TestMode::run()
if (this->maneuver == Maneuver::Turn) if (this->maneuver == Maneuver::Turn)
{ {
uint16_t delta = abs(this->azimuth - this->getSensorData()->getRealAzimuth()); uint16_t delta = abs(this->azimuth - this->getSensorData()->getRealAzimuth());
if (delta > this->degree) { if (delta > this->degree)
{
this->abort = true; this->abort = true;
} }
} }
@@ -31,7 +32,8 @@ void TestMode::run()
bool TestMode::drive(int16_t cmDistance, int16_t degree) bool TestMode::drive(int16_t cmDistance, int16_t degree)
{ {
if (this->busy){ if (this->busy)
{
return false; return false;
} }
@@ -43,10 +45,12 @@ bool TestMode::drive(int16_t cmDistance, int16_t degree)
// Only left or right // Only left or right
this->moveControl->setSpeed(0); this->moveControl->setSpeed(0);
if (degree < 0){ if (degree < 0)
{
this->moveControl->setRotationSpeed(-this->maxSpeeds.rot); this->moveControl->setRotationSpeed(-this->maxSpeeds.rot);
} }
else if (degree > 0){ else if (degree > 0)
{
this->moveControl->setRotationSpeed(this->maxSpeeds.rot); this->moveControl->setRotationSpeed(this->maxSpeeds.rot);
} }
@@ -62,10 +66,12 @@ bool TestMode::drive(int16_t cmDistance, int16_t degree)
// Only forward or backward // Only forward or backward
this->moveControl->setRotationSpeed(0); this->moveControl->setRotationSpeed(0);
if (cmDistance < 0){ if (cmDistance < 0)
{
this->moveControl->setSpeed(-this->maxSpeeds.x); this->moveControl->setSpeed(-this->maxSpeeds.x);
} }
else if (cmDistance > 0){ else if (cmDistance > 0)
{
this->moveControl->setSpeed(this->maxSpeeds.x); this->moveControl->setSpeed(this->maxSpeeds.x);
} }
@@ -78,10 +84,12 @@ bool TestMode::drive(int16_t cmDistance, int16_t degree)
{ {
// forward or backward and left or right // forward or backward and left or right
// TODO: Calculate roationspeed // TODO: Calculate roationspeed
if (cmDistance < 0){ if (cmDistance < 0)
{
this->moveControl->setSpeed(-this->maxSpeeds.x); this->moveControl->setSpeed(-this->maxSpeeds.x);
} }
else if (cmDistance > 0){ else if (cmDistance > 0)
{
this->moveControl->setSpeed(this->maxSpeeds.x); this->moveControl->setSpeed(this->maxSpeeds.x);
} }
@@ -137,7 +145,8 @@ void TestMode::abortManeuver()
uint8_t TestMode::getRemainingManeuverTime() const uint8_t TestMode::getRemainingManeuverTime() const
{ {
if (this->busy){ if (this->busy)
{
return static_cast<uint8_t>((this->maneuverTime - (millis() - this->actionStart)) / 1000); return static_cast<uint8_t>((this->maneuverTime - (millis() - this->actionStart)) / 1000);
} }
return 0; return 0;
@@ -145,13 +154,16 @@ uint8_t TestMode::getRemainingManeuverTime() const
bool TestMode::engineInit(int16_t powerPercentage, int16_t seconds) bool TestMode::engineInit(int16_t powerPercentage, int16_t seconds)
{ {
if (this->busy){ if (this->busy)
{
return false; return false;
} }
if (powerPercentage > TestMode::maxPercentage || powerPercentage < -TestMode::maxPercentage){ if (powerPercentage > TestMode::maxPercentage || powerPercentage < -TestMode::maxPercentage)
{
return false; return false;
} }
if (seconds < 0){ if (seconds < 0)
{
return false; return false;
} }
+9 -1
View File
@@ -26,7 +26,6 @@ class TestMode : public DriveModi
public: public:
/** /**
* @brief Different states to test the engine * @brief Different states to test the engine
*
*/ */
enum Maneuver enum Maneuver
{ {
@@ -38,6 +37,14 @@ public:
Drive Drive
}; };
/**
* @brief Let the rover drive
*
* @param cmDistance to drive
* @param degree degree to rotate over the hole distance
* @return true
* @return false
*/
bool drive(int16_t cmDistance = 0, int16_t degree = 0); bool drive(int16_t cmDistance = 0, int16_t degree = 0);
/** /**
@@ -89,6 +96,7 @@ public:
* @return false * @return false
*/ */
bool getBusy() const { return this->busy; } bool getBusy() const { return this->busy; }
Maneuver getManeuver() const { return this->maneuver; } Maneuver getManeuver() const { return this->maneuver; }
Speedometer *getSpeedometerLeft() const { return this->moveControl->getSpeedometerLeft(); } Speedometer *getSpeedometerLeft() const { return this->moveControl->getSpeedometerLeft(); }
Speedometer *getSpeedometerRight() const { return this->moveControl->getSpeedometerRight(); } Speedometer *getSpeedometerRight() const { return this->moveControl->getSpeedometerRight(); }
+13 -10
View File
@@ -20,9 +20,13 @@
#include "component.h" #include "component.h"
#include "sensorData.h" #include "sensorData.h"
class DriveManager : public Component { /**
public: * @brief A class to manage and hold the different DriveModi
*
*/
class DriveManager : public Component
{
public:
/** /**
* @brief Construct a new Drive Manager object * @brief Construct a new Drive Manager object
* *
@@ -30,7 +34,7 @@ class DriveManager : public Component {
* @param sensorData * @param sensorData
* @param input * @param input
*/ */
DriveManager(MoveControl *moveControl, const SensorData* sensorData, const ControlPadInput *input); DriveManager(MoveControl *moveControl, const SensorData *sensorData, const ControlPadInput *input);
/** /**
* @brief Construct a new Drive Manager object * @brief Construct a new Drive Manager object
@@ -47,7 +51,7 @@ class DriveManager : public Component {
* *
* @param modus * @param modus
*/ */
void changeModus(DriveModi* modus = nullptr); void changeModus(DriveModi *modus = nullptr);
/** /**
* @brief Get the DriveModi Ptr object * @brief Get the DriveModi Ptr object
@@ -59,13 +63,13 @@ class DriveManager : public Component {
* @see getDriveModi * @see getDriveModi
* @return DriveModi* * @return DriveModi*
*/ */
DriveModi* getDriveModiPtr() const { return this->currentModusPtr; } DriveModi *getDriveModiPtr() const { return this->currentModusPtr; }
DrivingSpeeds& getDrivingSpeedsRef() { return this->drivingSpeeds; } DrivingSpeeds &getDrivingSpeedsRef() { return this->drivingSpeeds; }
bool isActive() const { return this->currentModusPtr; } bool isActive() const { return this->currentModusPtr; }
private: private:
void run() override {}; void run() override{};
void init(); void init();
DriveModi *currentModusPtr = nullptr; DriveModi *currentModusPtr = nullptr;
@@ -73,5 +77,4 @@ class DriveManager : public Component {
DrivingSpeeds drivingSpeeds = {1, 7}; DrivingSpeeds drivingSpeeds = {1, 7};
}; };
#endif // DRIVE_MANAGER_H #endif // DRIVE_MANAGER_H
+8 -4
View File
@@ -1,26 +1,30 @@
#include "driveModi.h" #include "driveModi.h"
DriveModi::~DriveModi() { DriveModi::~DriveModi()
{
this->moveControl->setSpeed(0); this->moveControl->setSpeed(0);
this->moveControl->setRotationSpeed(0); this->moveControl->setRotationSpeed(0);
this->moveControl->setDrivingStatus(MoveControl::Status::Stop); this->moveControl->setDrivingStatus(MoveControl::Status::Stop);
} }
void DriveModi::activate(MoveControl* moveControl, ControlPadInput* input, SensorData* sensorData) { void DriveModi::activate(MoveControl *moveControl, ControlPadInput *input, SensorData *sensorData)
{
this->moveControl = moveControl; this->moveControl = moveControl;
this->input = input; this->input = input;
this->sensorData = sensorData; this->sensorData = sensorData;
this->init(); this->init();
} }
void DriveModi::activate(DriveModiParams params){ void DriveModi::activate(DriveModiParams params)
{
this->moveControl = params.moveControl; this->moveControl = params.moveControl;
this->input = params.input; this->input = params.input;
this->sensorData = params.sensorData; this->sensorData = params.sensorData;
this->init(); this->init();
} }
void DriveModi::init() { void DriveModi::init()
{
this->moveControl->setDrivingStatus(MoveControl::Status::Drive); this->moveControl->setDrivingStatus(MoveControl::Status::Drive);
this->loopDelay = DriveModi::defaultDelay; this->loopDelay = DriveModi::defaultDelay;
this->afterActivate(); this->afterActivate();
+35 -13
View File
@@ -17,10 +17,14 @@
#include "controlPadInput.h" #include "controlPadInput.h"
#include "sensorData.h" #include "sensorData.h"
struct DriveModiParams { /**
MoveControl* moveControl; * @brief The struct contains all objects needed by a DriveMode
const ControlPadInput* input; */
const SensorData* sensorData; struct DriveModiParams
{
MoveControl *moveControl;
const ControlPadInput *input;
const SensorData *sensorData;
}; };
/** /**
@@ -29,28 +33,46 @@ struct DriveModiParams {
* This class must be inherited by other classes which want to be * This class must be inherited by other classes which want to be
* act as a DriveModi, because the DriveModi structure uses polymorphism. * act as a DriveModi, because the DriveModi structure uses polymorphism.
*/ */
class DriveModi : public Component { class DriveModi : public Component
public: {
public:
virtual ~DriveModi(); virtual ~DriveModi();
const SensorData* getSensorData() const { return this->sensorData; } const SensorData *getSensorData() const { return this->sensorData; }
void activate(MoveControl* moveControl, ControlPadInput* input, SensorData* sensorData); /**
* @brief This activates a DriveMode
*
* This function have to be called to provide the DriveMode
* with this objects
*
* @param moveControl
* @param input
* @param sensorData
*/
void activate(MoveControl *moveControl, ControlPadInput *input, SensorData *sensorData);
void activate(DriveModiParams params); void activate(DriveModiParams params);
void setSpeeds(DrivingSpeeds speeds) { this->maxSpeeds = speeds; } void setSpeeds(DrivingSpeeds speeds) { this->maxSpeeds = speeds; }
DrivingSpeeds getSpeeds() const { return this->maxSpeeds; } DrivingSpeeds getSpeeds() const { return this->maxSpeeds; }
DrivingSpeeds& getSpeedsRef() { return this->maxSpeeds; } DrivingSpeeds &getSpeedsRef() { return this->maxSpeeds; }
protected: protected:
/**
* @brief Prepare other things
*
* This function can be overwritten to prepare things
* for the specific DriveModi. This function will be
* called after activate().
*/
virtual void afterActivate() {} virtual void afterActivate() {}
MoveControl *moveControl = nullptr; MoveControl *moveControl = nullptr;
DrivingSpeeds maxSpeeds = {1, 7}; DrivingSpeeds maxSpeeds = {1, 7};
const ControlPadInput* input = nullptr; const ControlPadInput *input = nullptr;
const SensorData* sensorData = nullptr; const SensorData *sensorData = nullptr;
private: private:
void init(); void init();
static constexpr uint8_t defaultDelay = 40; static constexpr uint8_t defaultDelay = 40;
+8 -8
View File
@@ -92,14 +92,14 @@ void setup()
lcd->clear(); lcd->clear();
lcd->noBacklight(); lcd->noBacklight();
network = new Network(static_cast<const char*>(NetworkConfig::ssid), network = new Network(static_cast<const char *>(NetworkConfig::ssid),
static_cast<const char*>(NetworkConfig::password), static_cast<const char *>(NetworkConfig::password),
setIPs()); setIPs());
network->activateEspNow(receiveCallback, sendCallback); network->activateEspNow(receiveCallback, sendCallback);
if (NetworkConfig::mqtt) if (NetworkConfig::mqtt)
{ {
if (network->activateMqtt(static_cast<const char*>(MqttConfig::user), if (network->activateMqtt(static_cast<const char *>(MqttConfig::user),
static_cast<const char*>(MqttConfig::password))) static_cast<const char *>(MqttConfig::password)))
{ {
DebugMqtt::init(network->getMqttClient(), Loglevel::debug); DebugMqtt::init(network->getMqttClient(), Loglevel::debug);
debugMqtt = new DebugMqtt("Console"); debugMqtt = new DebugMqtt("Console");
@@ -125,11 +125,11 @@ void setup()
sensorData = new SensorData(); sensorData = new SensorData();
sensorData->enableGnss(spiPort, PinNumbers::gnssSpiCs); sensorData->enableGnss(spiPort, PinNumbers::gnssSpiCs);
sensorData->enableRealCompass(); sensorData->enableRealCompass();
sensorData->enableNtrip(static_cast<const char*>(NtripConfig::host), sensorData->enableNtrip(static_cast<const char *>(NtripConfig::host),
NtripConfig::port, NtripConfig::port,
static_cast<const char*>(NtripConfig::mountPoint), static_cast<const char *>(NtripConfig::mountPoint),
static_cast<const char*>(NtripConfig::user), static_cast<const char *>(NtripConfig::user),
static_cast<const char*>(NtripConfig::password)); static_cast<const char *>(NtripConfig::password));
// sensorData->enableGyroscope(); // sensorData->enableGyroscope();
driveManager = new DriveManager(&moveController, sensorData, controlPad->getControlPadDataPtr()); driveManager = new DriveManager(&moveController, sensorData, controlPad->getControlPadDataPtr());