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
+5 -5
View File
@@ -26,13 +26,14 @@
#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
@@ -46,7 +47,7 @@ class OutputBuf : public std::streambuf {
* @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,7 +57,7 @@ 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
*/ */
@@ -65,7 +66,6 @@ class OutputBuf : public std::streambuf {
void setDebugMqtt(DebugMqtt *debugMqtt); void setDebugMqtt(DebugMqtt *debugMqtt);
void setSerialBT(BluetoothSerial *serialBT); void setSerialBT(BluetoothSerial *serialBT);
protected: protected:
/** /**
* @brief * @brief
@@ -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;
+2 -2
View File
@@ -20,7 +20,8 @@
* @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
@@ -33,7 +34,6 @@ class MenuPidSettings : public MenuIntInputWrapper {
private: private:
PID *pid; 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);
/** /**
+2 -2
View File
@@ -20,7 +20,8 @@
* @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
@@ -44,7 +45,6 @@ class MenuRoutePoints : public MenuInformationSites {
private: private:
Route *route; Route *route;
bool error = false; bool error = false;
}; };
#endif // MENU_ROUTE_POINTS_H #endif // MENU_ROUTE_POINTS_H
+11 -2
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,8 +15,17 @@
#include "menuInformationSites.h" #include "menuInformationSites.h"
#include "sensorData.h" #include "sensorData.h"
class MenuSensorData : public MenuInformationSites { /**
* @brief A MenuInformationClass to print the SensorData
*/
class MenuSensorData : public MenuInformationSites
{
public: public:
/**
* @brief Construct a new MenuSensorData object
*
* @param SensorData
*/
MenuSensorData(SensorData *SensorData); MenuSensorData(SensorData *SensorData);
private: private:
+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;
+12 -3
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 { /**
* @brief A MenuIntInputWrapper class to change speeds
*/
class MenuSpeed : public MenuIntInputWrapper
{
public: public:
MenuSpeed(DrivingSpeeds &speeds) : speeds(speeds){}; MenuSpeed(DrivingSpeeds &speeds) : speeds(speeds){};
/**
* @brief Changes the speeds
*
* @param values
* @param length
*/
void action(int16_t *values, uint8_t length) override; void action(int16_t *values, uint8_t length) override;
private: private:
DrivingSpeeds &speeds; DrivingSpeeds &speeds;
}; };
#endif // MENU_SPEED_H #endif // MENU_SPEED_H
@@ -12,14 +12,17 @@
#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,7 +26,8 @@
* *
* 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
@@ -19,7 +19,8 @@
* @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
@@ -39,7 +40,6 @@ 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
*/ */
@@ -12,16 +12,19 @@
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,7 +36,8 @@ 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";
@@ -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,10 +122,13 @@ 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();
@@ -20,7 +20,8 @@
* @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
@@ -40,11 +41,10 @@ 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;
@@ -18,7 +18,8 @@
* @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
@@ -43,9 +44,8 @@ class MenuCaptureRoute : public MenuDriveMode {
*/ */
void update() override; void update() override;
void runCommand() override;
private: private:
void runCommand() override;
void init() override; void init() override;
CaptureRoute *captureRoute = nullptr; CaptureRoute *captureRoute = nullptr;
@@ -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,7 +19,8 @@
* @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
@@ -38,11 +39,10 @@ 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;
@@ -15,14 +15,18 @@ MenuTestMode::MenuTestMode(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,61 +34,81 @@ 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;
}; };
@@ -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,36 +207,47 @@ 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();
} }
@@ -234,21 +267,25 @@ MenuTestModeWrapper::MenuTestModeWrapper(MenuTestMode* menu, TestModeFunctionDou
{ {
} }
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,7 +22,8 @@
* @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
@@ -82,7 +83,8 @@ 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: public:
MenuTestModeWrapper(MenuTestMode *menu, TestModeFunctionSingle testModeFunction); MenuTestModeWrapper(MenuTestMode *menu, TestModeFunctionSingle testModeFunction);
MenuTestModeWrapper(MenuTestMode *menu, TestModeFunctionDouble testModeFunction); MenuTestModeWrapper(MenuTestMode *menu, TestModeFunctionDouble testModeFunction);
@@ -17,9 +17,10 @@ SpeedometerTest::SpeedometerTest(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;
@@ -28,7 +29,8 @@ void SpeedometerTest::printMenu() {
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,8 +59,10 @@ void SpeedometerTest::no() {
this->parentMenu->printMenu(); this->parentMenu->printMenu();
} }
void SpeedometerTest::yes() { void SpeedometerTest::yes()
switch (this->state) { {
switch (this->state)
{
case State::Off: case State::Off:
this->state = State::Running; this->state = State::Running;
this->speedometer->calibrationMeasurementStart(); this->speedometer->calibrationMeasurementStart();
@@ -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
+71 -23
View File
@@ -16,9 +16,31 @@ MenuDriveMode::MenuDriveMode(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,15 +119,23 @@ 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;
} }
if (this->selfCreatedMenuSpeed)
{
delete this->menuSpeed;
}
DrivingSpeeds &speeds = this->driveManager->getDriveModiPtr()->getSpeedsRef(); DrivingSpeeds &speeds = this->driveManager->getDriveModiPtr()->getSpeedsRef();
auto *menu = new MenuIntInput(2, new MenuSpeed(speeds)); auto *menu = new MenuIntInput(2, new MenuSpeed(speeds));
@@ -100,21 +143,26 @@ void MenuDriveMode::activateSpeedMenu() {
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;
} }
+33 -2
View File
@@ -20,7 +20,8 @@
* @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
@@ -29,8 +30,10 @@ class MenuDriveMode : public MenuInformationSites {
*/ */
MenuDriveMode(DriveManager *driveManager); MenuDriveMode(DriveManager *driveManager);
~MenuDriveMode();
void addSensorMenu(MenuSensorData *menuSensor) { this->menuSensor = menuSensor; } void addSensorMenu(MenuSensorData *menuSensor) { this->menuSensor = menuSensor; }
void addSpeedMenu(MenuIntInput* menuSpeed) { this->menuSpeed = menuSpeed; } void addSpeedMenu(MenuIntInput *menuSpeed);
/** /**
* @brief Goes back to the parentMenu. * @brief Goes back to the parentMenu.
@@ -47,9 +50,35 @@ class MenuDriveMode : public MenuInformationSites {
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;
@@ -62,5 +91,7 @@ class MenuDriveMode : public MenuInformationSites {
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
+6 -4
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: public:
enum State { enum State
{
InsufficientAccuracy = -2, InsufficientAccuracy = -2,
NoRoute = -1, NoRoute = -1,
None = 0, None = 0,
@@ -116,7 +117,8 @@ class Autopilot : public ManualControl {
double minRemainingDistance = 0.25; double minRemainingDistance = 0.25;
}; };
class DirectionChangeSignal : public DirectionChangeWrapper { class DirectionChangeSignal : public DirectionChangeWrapper
{
public: public:
DirectionChangeSignal(Autopilot *pilot); DirectionChangeSignal(Autopilot *pilot);
~DirectionChangeSignal(); ~DirectionChangeSignal();
@@ -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,8 +16,17 @@
#include "driveModi/Modi/ManualControl/manualControl.h" #include "driveModi/Modi/ManualControl/manualControl.h"
class CalibrateCompassM : public ManualControl { /**
* @brief A Menu class to interact with CalibrateCompass class
*/
class CalibrateCompassM : public ManualControl
{
public: public:
/**
* @brief Set the CalibrateCompass object
*
* @param caliCompass
*/
void setCalibrateCompass(CalibrateCompass *caliCompass = nullptr); void setCalibrateCompass(CalibrateCompass *caliCompass = nullptr);
private: private:
@@ -25,7 +25,8 @@
* 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,19 +35,13 @@ 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; }
@@ -64,6 +59,7 @@ 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;
@@ -13,7 +13,8 @@
#include "driveModi/driveModi.h" #include "driveModi/driveModi.h"
class DirectionChangeWrapper { class DirectionChangeWrapper
{
public: public:
virtual void action() = 0; virtual void action() = 0;
}; };
@@ -21,21 +22,37 @@ class DirectionChangeWrapper {
/** /**
* @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: public:
enum class InputMode : uint8_t { /**
* @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; }
/**
* @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; } void setDirectionChangeCallback(DirectionChangeWrapper *callback) { this->directionChangeWrapper = callback; }
uint16_t getDutycycleLeft() const { return this->moveControl->getDutycycleLeft(); } uint16_t getDutycycleLeft() const { return this->moveControl->getDutycycleLeft(); }
+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(); }
+6 -3
View File
@@ -20,9 +20,13 @@
#include "component.h" #include "component.h"
#include "sensorData.h" #include "sensorData.h"
class DriveManager : public Component { /**
* @brief A class to manage and hold the different DriveModi
*
*/
class DriveManager : public Component
{
public: public:
/** /**
* @brief Construct a new Drive Manager object * @brief Construct a new Drive Manager object
* *
@@ -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();
+24 -2
View File
@@ -17,7 +17,11 @@
#include "controlPadInput.h" #include "controlPadInput.h"
#include "sensorData.h" #include "sensorData.h"
struct DriveModiParams { /**
* @brief The struct contains all objects needed by a DriveMode
*/
struct DriveModiParams
{
MoveControl *moveControl; MoveControl *moveControl;
const ControlPadInput *input; const ControlPadInput *input;
const SensorData *sensorData; const SensorData *sensorData;
@@ -29,12 +33,23 @@ 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; }
/**
* @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(MoveControl *moveControl, ControlPadInput *input, SensorData *sensorData);
void activate(DriveModiParams params); void activate(DriveModiParams params);
@@ -43,6 +58,13 @@ class DriveModi : public Component {
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;