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",
"Schalke",
"Soln",
"Systeminformation",
"TPMOBIL",
"UBLOX",
"wheelspeed",
+2
View File
@@ -30,12 +30,14 @@ Do later:
-> ESP und Sensoren in den DeepSleep für Auschalten oder Akkuschutz
-> Doxygen comments
- navigation
- autopilot
Do now:
Code:
Doxygen Kommentare aktualisieren
Fernbedienung!
Compass calibration überprüfen
Latex:
Anhang: Liste mit allen Komponenten und Kurzbeschreibung
+5 -5
View File
@@ -26,13 +26,14 @@
#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
* and MQTT.
*
*/
class OutputBuf : public std::streambuf {
class OutputBuf : public std::streambuf
{
public:
/**
* @brief Construct a new Output Buf Mqtt object
@@ -46,7 +47,7 @@ class OutputBuf : public std::streambuf {
* @brief Activate the mqtt output
*
* This only works if the DebugMqtt is set by
* setDebugMqtt.
* setDebugMqtt().
*
* @param status
*/
@@ -56,7 +57,7 @@ class OutputBuf : public std::streambuf {
* @brief Active the output over the bluetooth serial consol
*
* This only works if BluetoothSerial is set by
* setSerialBT.
* setSerialBT().
*
* @param status
*/
@@ -65,7 +66,6 @@ class OutputBuf : public std::streambuf {
void setDebugMqtt(DebugMqtt *debugMqtt);
void setSerialBT(BluetoothSerial *serialBT);
protected:
/**
* @brief
@@ -1,7 +1,7 @@
/**
* @file menuCalibrateBattery.h
* @author Alexander Klein (alex@kleiax.de)
* @brief
* @brief Contains a Menu class to calibrate the Battery class
* @version 0.1
* @date 2023-09-26
*
@@ -15,13 +15,27 @@
#include "menuControl.h"
#include "battery.h"
/**
* @brief A Menu class to calibrate the Battery class
*/
class MenuCalibrateBattery : public MenuControl
{
public:
/**
* @brief Construct a new MenuCalibrateBattery object
*
* Prepare the calibration.
*
* @param battery
*/
MenuCalibrateBattery(Battery *battery);
/**
* @brief Prints the instructions for the calibration
*/
void printMenu() override;
// User Inputs
void left() override;
void no() override { this->left(); }
void right() override;
+2 -2
View File
@@ -20,7 +20,8 @@
* @brief A class to tune the PID settings
*
*/
class MenuPidSettings : public MenuIntInputWrapper {
class MenuPidSettings : public MenuIntInputWrapper
{
public:
/**
* @brief Construct a new Menu Pid Settings object
@@ -33,7 +34,6 @@ class MenuPidSettings : public MenuIntInputWrapper {
private:
PID *pid;
};
#endif // PID_SETTINGS_H
+7
View File
@@ -111,6 +111,13 @@ public:
*/
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);
/**
+2 -2
View File
@@ -20,7 +20,8 @@
* @brief Prints coordinates of Route side by side.
*
*/
class MenuRoutePoints : public MenuInformationSites {
class MenuRoutePoints : public MenuInformationSites
{
public:
/**
* @brief Construct a new Menu Route Points object
@@ -44,7 +45,6 @@ class MenuRoutePoints : public MenuInformationSites {
private:
Route *route;
bool error = false;
};
#endif // MENU_ROUTE_POINTS_H
+11 -2
View File
@@ -1,7 +1,7 @@
/**
* @file menuSensorData.h
* @author Alexander Klein (alex@kleiax.de)
* @brief
* @brief Contains a MenuInformationClass to print the SensorData
* @version 0.1
* @date 2023-09-04
*
@@ -15,8 +15,17 @@
#include "menuInformationSites.h"
#include "sensorData.h"
class MenuSensorData : public MenuInformationSites {
/**
* @brief A MenuInformationClass to print the SensorData
*/
class MenuSensorData : public MenuInformationSites
{
public:
/**
* @brief Construct a new MenuSensorData object
*
* @param SensorData
*/
MenuSensorData(SensorData *SensorData);
private:
+4 -2
View File
@@ -11,8 +11,10 @@
#include "menuSpeed.h"
void MenuSpeed::action(int16_t* values, uint8_t length) {
if (length != 2) {
void MenuSpeed::action(int16_t *values, uint8_t length)
{
if (length != 2)
{
return;
}
this->speeds.x = values[0] / 10.0;
+12 -3
View File
@@ -1,7 +1,7 @@
/**
* @file menuSpeed.h
* @author Alexander Klein (alex@kleiax.de)
* @brief
* @brief Contains a MenuIntInputWrapper to change speeds
* @version 0.1
* @date 2023-09-26
*
@@ -15,15 +15,24 @@
#include <menuIntInput.h>
#include "moveControl.h"
class MenuSpeed : public MenuIntInputWrapper {
/**
* @brief A MenuIntInputWrapper class to change speeds
*/
class MenuSpeed : public MenuIntInputWrapper
{
public:
MenuSpeed(DrivingSpeeds &speeds) : speeds(speeds){};
/**
* @brief Changes the speeds
*
* @param values
* @param length
*/
void action(int16_t *values, uint8_t length) override;
private:
DrivingSpeeds &speeds;
};
#endif // MENU_SPEED_H
@@ -12,14 +12,17 @@
#include "menuSysteminformation.h"
MenuSysteminformation::MenuSysteminformation(Battery *mainBattery)
: MenuInformationSites(8), mainBattery {mainBattery} {
: MenuInformationSites(8), mainBattery{mainBattery}
{
this->noEqualLeft = true;
}
void MenuSysteminformation::printPage() const {
void MenuSysteminformation::printPage() const
{
String lineOne = "";
String lineTwo = "";
switch (this->getCurrentPage()) {
switch (this->getCurrentPage())
{
case 0:
lineOne = "Free Heap:";
lineTwo.concat(ESP.getFreeHeap());
@@ -71,4 +74,3 @@ void MenuSysteminformation::printPage() const {
this->print(lineOne, lineTwo);
}
@@ -26,7 +26,8 @@
*
* The informations are about the batteries, memory and uptime.
*/
class MenuSysteminformation : public MenuInformationSites {
class MenuSysteminformation : public MenuInformationSites
{
public:
/**
* @brief Construct a new Menu Systeminformation object
@@ -19,7 +19,8 @@
* @brief A class to print informations about the Autopilot
*
*/
class MenuAutopilot : public MenuDriveMode {
class MenuAutopilot : public MenuDriveMode
{
public:
/**
* @brief Construct a new Menu Autopilot object
@@ -39,7 +40,6 @@ class MenuAutopilot : public MenuDriveMode {
*/
void printPage() const override;
/**
* @brief can be called to update shown data
*/
@@ -12,16 +12,19 @@
MenuCalibrateCompass::MenuCalibrateCompass(DriveManager *driveManager) : MenuDriveMode(driveManager) {}
MenuCalibrateCompass::~MenuCalibrateCompass() {
MenuCalibrateCompass::~MenuCalibrateCompass()
{
delete this->caliCompass;
this->caliCompassMode->setCalibrateCompass();
}
void MenuCalibrateCompass::printPage() const {
void MenuCalibrateCompass::printPage() const
{
String lineOne = "";
String lineTwo = "";
switch (this->getCurrentPage()) {
switch (this->getCurrentPage())
{
case 0:
lineOne = "-Ready to drive-";
lineTwo = "Compass Mode";
@@ -33,7 +36,8 @@ void MenuCalibrateCompass::printPage() const {
break;
case 2:
switch (this->caliCompass->getState()) {
switch (this->caliCompass->getState())
{
case CalibrateCompass::State::Ready:
lineOne = "Start compass";
lineTwo = "calibration";
@@ -108,7 +112,8 @@ void MenuCalibrateCompass::printPage() const {
this->print(lineOne, lineTwo);
}
void MenuCalibrateCompass::init() {
void MenuCalibrateCompass::init()
{
this->firstPrint = false;
this->caliCompassMode = new CalibrateCompassM();
this->driveManager->changeModus(this->caliCompassMode);
@@ -117,10 +122,13 @@ void MenuCalibrateCompass::init() {
MenuDriveMode::updateDelay = MenuCalibrateCompass::updateDelay;
}
void MenuCalibrateCompass::runCommand() {
switch (this->getCurrentPage()) {
void MenuCalibrateCompass::runCommand()
{
switch (this->getCurrentPage())
{
case 2:
switch (this->caliCompass->getState()) {
switch (this->caliCompass->getState())
{
case CalibrateCompass::State::Ready:
this->caliCompassMode->setCalibrateCompass(this->caliCompass);
this->caliCompass->start();
@@ -20,7 +20,8 @@
* @brief A class to print informations about the class ManualControl
*
*/
class MenuCalibrateCompass : public MenuDriveMode {
class MenuCalibrateCompass : public MenuDriveMode
{
public:
/**
* @brief Construct a new Menu Manual Control object
@@ -40,11 +41,10 @@ class MenuCalibrateCompass : public MenuDriveMode {
*/
void printPage() const override;
protected:
private:
void init() override;
void runCommand() override;
private:
CalibrateCompassM *caliCompassMode = nullptr;
CalibrateCompass *caliCompass = nullptr;
@@ -18,7 +18,8 @@
* @brief A class to print informations about the Autopilot
*
*/
class MenuCaptureRoute : public MenuDriveMode {
class MenuCaptureRoute : public MenuDriveMode
{
public:
/**
* @brief Construct a new Menu Capture Route object
@@ -43,9 +44,8 @@ class MenuCaptureRoute : public MenuDriveMode {
*/
void update() override;
void runCommand() override;
private:
void runCommand() override;
void init() override;
CaptureRoute *captureRoute = nullptr;
@@ -10,26 +10,30 @@
*/
#include "menuManualDrive.h"
MenuManualControl::MenuManualControl(DriveManager* driveManager) : MenuDriveMode(driveManager) {
MenuManualControl::MenuManualControl(DriveManager *driveManager) : MenuDriveMode(driveManager)
{
this->noEqualLeft = true;
}
void MenuManualControl::printPage() const {
void MenuManualControl::printPage() const
{
String lineOne = "";
String lineTwo = "";
switch (this->getCurrentPage()) {
switch (this->getCurrentPage())
{
case 0:
lineOne = "-Ready to drive-";
break;
case 1:
lineOne = "Input mode:";
if (this->manualControl->getInputMode() == ManualControl::InputMode::Analog) {
if (this->manualControl->getInputMode() == ManualControl::InputMode::Analog)
{
lineTwo = "Analog";
}
else {
else
{
lineTwo = "Digital";
}
break;
@@ -50,7 +54,8 @@ void MenuManualControl::printPage() const {
this->print(lineOne, lineTwo);
}
void MenuManualControl::init() {
void MenuManualControl::init()
{
this->firstPrint = false;
this->manualControl = new ManualControl();
this->driveManager->changeModus(this->manualControl);
@@ -60,8 +65,10 @@ void MenuManualControl::init() {
MenuDriveMode::init();
}
void MenuManualControl::runCommand() {
switch (this->getCurrentPage()) {
void MenuManualControl::runCommand()
{
switch (this->getCurrentPage())
{
case 1:
this->manualControl->switchInputMode();
break;
@@ -19,7 +19,8 @@
* @brief A class to print informations about the class ManualControl
*
*/
class MenuManualControl : public MenuDriveMode {
class MenuManualControl : public MenuDriveMode
{
public:
/**
* @brief Construct a new Menu Manual Control object
@@ -38,11 +39,10 @@ class MenuManualControl : public MenuDriveMode {
*/
void printPage() const override;
protected:
private:
void init() override;
void runCommand() override;
private:
ManualControl *manualControl = nullptr;
CalibrateCompass *caliCompass = nullptr;
@@ -15,14 +15,18 @@ MenuTestMode::MenuTestMode(DriveManager* driveManager)
{
}
MenuTestMode::~MenuTestMode() {
if (isInit) {
MenuTestMode::~MenuTestMode()
{
if (isInit)
{
delete this->mainMenu;
}
}
void MenuTestMode::printMenu() {
if (!this->isInit) {
void MenuTestMode::printMenu()
{
if (!this->isInit)
{
this->isInit = true;
this->init();
}
@@ -30,61 +34,81 @@ void MenuTestMode::printMenu() {
this->mainMenu->printMenu();
}
void MenuTestMode::down() {
if (this->checkInput()) {
void MenuTestMode::down()
{
if (this->checkInput())
{
this->mainMenu->down();
}
}
void MenuTestMode::up() {
if (this->checkInput()) {
void MenuTestMode::up()
{
if (this->checkInput())
{
this->mainMenu->up();
}
}
void MenuTestMode::right() {
if (this->checkInput()) {
void MenuTestMode::right()
{
if (this->checkInput())
{
this->mainMenu->right();
}
}
void MenuTestMode::left() {
void MenuTestMode::left()
{
if (this->mainMenu->isInSubmenu())
if (this->checkInput()) {
if (this->checkInput())
{
this->mainMenu->left();
}
else {
else
{
this->testMode->abortManeuver();
this->mainMenu->left();
}
else {
else
{
this->parentMenu->printMenu();
}
}
void MenuTestMode::yes() {
if (this->checkInput()) {
void MenuTestMode::yes()
{
if (this->checkInput())
{
this->mainMenu->yes();
}
}
void MenuTestMode::no() {
if (this->mainMenu->isInSubmenu()) {
void MenuTestMode::no()
{
if (this->mainMenu->isInSubmenu())
{
if (this->checkInput())
this->mainMenu->no();
else {
else
{
this->testMode->abortManeuver();
this->mainMenu->no();
}}
else{
this->left();}
}
}
else
{
this->left();
}
}
void MenuTestMode::init() {
void MenuTestMode::init()
{
this->testMode = new TestMode();
this->driveManager->changeModus(this->testMode);
auto dummy = []() {
auto dummy = []()
{
std::cout << "Dummy in Action" << std::endl;
};
@@ -103,7 +127,6 @@ void MenuTestMode::init() {
auto *encoderLeftMenu = new SpeedometerTest(this->testMode->getSpeedometerLeft());
auto *encoderRightMenu = new SpeedometerTest(this->testMode->getSpeedometerRight());
// Set menus on LCD
this->mainMenu->setLcd(this->lcd);
engineMenu->setLcd(this->lcd);
@@ -143,7 +166,6 @@ void MenuTestMode::init() {
engineBothMenu->setMinMaxSteps(1, 0, secondsMax, 1);
engineBothMenu->setPrintParentMenu(false);
// Entrys for the menus
auto *engineAction = new MenuAction("Engine", engineMenu);
auto *engineLeftAction = new MenuAction("Left", engineLeftMenu);
@@ -185,36 +207,47 @@ void MenuTestMode::init() {
lightMenu->addEntry(lightOffAction);
}
void MenuTestMode::update() {
if (this->maneuverInAction) {
if (millis() - this->lastUpdateTime > updateDelay) {
void MenuTestMode::update()
{
if (this->maneuverInAction)
{
if (millis() - this->lastUpdateTime > updateDelay)
{
this->printManeuverTime();
this->lastUpdateTime = millis();
}}
}
}
}
bool MenuTestMode::checkInput() {
if (this->testMode->getBusy()) {
bool MenuTestMode::checkInput()
{
if (this->testMode->getBusy())
{
this->printManeuverTime();
this->maneuverInAction = true;
return false;
}
if (this->maneuverInAction) {
if (this->maneuverInAction)
{
this->maneuverInAction = false;
}
return true;
}
void MenuTestMode::printManeuverTime() {
void MenuTestMode::printManeuverTime()
{
uint8_t maneuverTime = this->testMode->getRemainingManeuverTime();
if (maneuverTime) {
if (maneuverTime)
{
String lineTwo = "";
lineTwo.concat(maneuverTime);
lineTwo.concat(" secs");
this->print("Maneuver time:", lineTwo);
} else {
}
else
{
this->maneuverInAction = false;
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
// Very helpful site:
// https://isocpp.org/wiki/faq/pointers-to-members#fnptr-vs-memfnptr-types
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]);
}
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]);
}
if (res) {
if (res)
{
this->menu->printManeuverTime();
this->menu->maneuverStarted();
}
@@ -22,7 +22,8 @@
* @brief Interact with the TestMode
*
*/
class MenuTestMode : public MenuControl {
class MenuTestMode : public MenuControl
{
public:
/**
* @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::*TestModeFunctionDouble)(int16_t, int16_t);
class MenuTestModeWrapper : public MenuIntInputWrapper {
class MenuTestModeWrapper : public MenuIntInputWrapper
{
public:
MenuTestModeWrapper(MenuTestMode *menu, TestModeFunctionSingle testModeFunction);
MenuTestModeWrapper(MenuTestMode *menu, TestModeFunctionDouble testModeFunction);
@@ -17,9 +17,10 @@ SpeedometerTest::SpeedometerTest(Speedometer* speedometer)
this->speedometer->setDirection(Speedometer::Forward);
}
void SpeedometerTest::printMenu() {
switch (this->state) {
void SpeedometerTest::printMenu()
{
switch (this->state)
{
case State::Off:
this->print("Press Yes (O)", "to start");
break;
@@ -28,7 +29,8 @@ void SpeedometerTest::printMenu() {
this->print("Running, Yes (O)", "to stop");
break;
case State::Finished : {
case State::Finished:
{
String res = "";
res.concat(this->result);
this->print("Result: ", res);
@@ -41,13 +43,15 @@ void SpeedometerTest::printMenu() {
}
}
void SpeedometerTest::left() {
void SpeedometerTest::left()
{
this->no();
}
void SpeedometerTest::no() {
if (this->state == State::Running){
void SpeedometerTest::no()
{
if (this->state == State::Running)
{
speedometer->calibrationMeasurementStop();
}
@@ -55,8 +59,10 @@ void SpeedometerTest::no() {
this->parentMenu->printMenu();
}
void SpeedometerTest::yes() {
switch (this->state) {
void SpeedometerTest::yes()
{
switch (this->state)
{
case State::Off:
this->state = State::Running;
this->speedometer->calibrationMeasurementStart();
@@ -18,12 +18,14 @@
* @brief Tests the wheel encoder.
*
*/
class SpeedometerTest : public MenuControl {
class SpeedometerTest : public MenuControl
{
public:
/**
* @brief The states of the test.
*/
enum State {
enum State
{
Off,
Running,
Finished
+71 -23
View File
@@ -16,9 +16,31 @@ MenuDriveMode::MenuDriveMode(DriveManager* driveManager)
{
}
void MenuDriveMode::left() {
if (static_cast<bool>(this->activeMenu)) {
if (static_cast<bool>(this->activeMenu)) {
MenuDriveMode::~MenuDriveMode()
{
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();
}
return;
@@ -31,52 +53,65 @@ void MenuDriveMode::left() {
MenuInformationSites::left();
}
void MenuDriveMode::right() {
if (static_cast<bool>(this->activeMenu)) {
void MenuDriveMode::right()
{
if (static_cast<bool>(this->activeMenu))
{
this->activeMenu->right();
return;
}
MenuInformationSites::right();
}
void MenuDriveMode::up() {
if (static_cast<bool>(this->activeMenu)) {
void MenuDriveMode::up()
{
if (static_cast<bool>(this->activeMenu))
{
this->activeMenu->up();
return;
}
MenuInformationSites::up();
}
void MenuDriveMode::down() {
if (static_cast<bool>(this->activeMenu)) {
void MenuDriveMode::down()
{
if (static_cast<bool>(this->activeMenu))
{
this->activeMenu->down();
return;
}
MenuInformationSites::down();
}
void MenuDriveMode::yes() {
if (static_cast<bool>(this->activeMenu)) {
void MenuDriveMode::yes()
{
if (static_cast<bool>(this->activeMenu))
{
this->activeMenu->yes();
return;
}
MenuInformationSites::yes();
}
void MenuDriveMode::no() {
if (static_cast<bool>(this->activeMenu)) {
void MenuDriveMode::no()
{
if (static_cast<bool>(this->activeMenu))
{
this->activeMenu->no();
return;
}
MenuInformationSites::no();
}
void MenuDriveMode::prepareReenterMenu() {
void MenuDriveMode::prepareReenterMenu()
{
this->activeMenu = nullptr;
}
void MenuDriveMode::printMenu() {
if (static_cast<bool>(this->activeMenu)) {
void MenuDriveMode::printMenu()
{
if (static_cast<bool>(this->activeMenu))
{
this->activeMenu->printMenu();
return;
}
@@ -84,15 +119,23 @@ void MenuDriveMode::printMenu() {
MenuInformationSites::printMenu();
}
void MenuDriveMode::init() {
void MenuDriveMode::init()
{
this->activeMenu = nullptr;
}
void MenuDriveMode::activateSpeedMenu() {
if (!this->driveManager->isActive()) {
void MenuDriveMode::activateSpeedMenu()
{
if (!this->driveManager->isActive())
{
return;
}
if (this->selfCreatedMenuSpeed)
{
delete this->menuSpeed;
}
DrivingSpeeds &speeds = this->driveManager->getDriveModiPtr()->getSpeedsRef();
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(1, "z rad/s e-1", driveManager->getDrivingSpeedsRef().rot * 10);
this->selfCreatedMenuSpeed = true;
this->addSpeedMenu(menu);
}
void MenuDriveMode::enterSpeedMenu() {
void MenuDriveMode::enterSpeedMenu()
{
this->activeMenu = this->menuSpeed;
this->enterMenu();
}
void MenuDriveMode::enterSensorMenu() {
void MenuDriveMode::enterSensorMenu()
{
this->activeMenu = this->menuSensor;
this->enterMenu();
}
void MenuDriveMode::enterMenu() {
if (!static_cast<bool>(this->activeMenu)) {
void MenuDriveMode::enterMenu()
{
if (!static_cast<bool>(this->activeMenu))
{
return;
}
+33 -2
View File
@@ -20,7 +20,8 @@
* @brief A base class for Menus about DriveModi
*
*/
class MenuDriveMode : public MenuInformationSites {
class MenuDriveMode : public MenuInformationSites
{
public:
/**
* @brief Construct a new Menu Drive Mode object
@@ -29,8 +30,10 @@ class MenuDriveMode : public MenuInformationSites {
*/
MenuDriveMode(DriveManager *driveManager);
~MenuDriveMode();
void addSensorMenu(MenuSensorData *menuSensor) { this->menuSensor = menuSensor; }
void addSpeedMenu(MenuIntInput* menuSpeed) { this->menuSpeed = menuSpeed; }
void addSpeedMenu(MenuIntInput *menuSpeed);
/**
* @brief Goes back to the parentMenu.
@@ -47,9 +50,35 @@ class MenuDriveMode : public MenuInformationSites {
protected:
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() {}
/**
* @brief Creates an own SpeedMenu
*
* This function uses addSpeedMenu() at the end to that the new menu
*/
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();
/**
* @brief Enter a Menu with the SensorData
*
* To enter this menu it has to be set by addSensorMenu()
*/
void enterSensorMenu();
DriveManager *driveManager;
@@ -62,5 +91,7 @@ class MenuDriveMode : public MenuInformationSites {
MenuControl *activeMenu = nullptr;
MenuSensorData *menuSensor = nullptr;
MenuIntInput *menuSpeed = nullptr;
bool selfCreatedMenuSpeed = false;
};
#endif // MENU_DRIVE_MODI_H
+6 -4
View File
@@ -12,7 +12,6 @@
#ifndef AUTOPILOT_H
#define AUTOPILOT_H
#include "navigation.h"
#include "driveModi/Modi/ManualControl/manualControl.h"
@@ -27,9 +26,11 @@ class DirectionChangeSignal;
* switch to automatic drive.
*
*/
class Autopilot : public ManualControl {
class Autopilot : public ManualControl
{
public:
enum State {
enum State
{
InsufficientAccuracy = -2,
NoRoute = -1,
None = 0,
@@ -116,7 +117,8 @@ class Autopilot : public ManualControl {
double minRemainingDistance = 0.25;
};
class DirectionChangeSignal : public DirectionChangeWrapper {
class DirectionChangeSignal : public DirectionChangeWrapper
{
public:
DirectionChangeSignal(Autopilot *pilot);
~DirectionChangeSignal();
@@ -11,12 +11,15 @@
#include "calibrateCompassM.h"
void CalibrateCompassM::setCalibrateCompass(CalibrateCompass *caliCompass) {
if (static_cast<bool>(caliCompass)) {
void CalibrateCompassM::setCalibrateCompass(CalibrateCompass *caliCompass)
{
if (static_cast<bool>(caliCompass))
{
this->caliCompass = caliCompass;
this->addChildComponent(this->caliCompass);
} else if (static_cast<bool>(this->caliCompass)) {
}
else if (static_cast<bool>(this->caliCompass))
{
this->removeChildComponent(this->caliCompass);
this->caliCompass = caliCompass;
}
@@ -1,7 +1,7 @@
/**
* @file calibrateCompassM.h
* @author Alexander Klein (alex@kleiax.de)
* @brief
* @brief Contains a Menu class to calibrate the compass
* @version 0.1
* @date 2023-09-03
*
@@ -16,8 +16,17 @@
#include "driveModi/Modi/ManualControl/manualControl.h"
class CalibrateCompassM : public ManualControl {
/**
* @brief A Menu class to interact with CalibrateCompass class
*/
class CalibrateCompassM : public ManualControl
{
public:
/**
* @brief Set the CalibrateCompass object
*
* @param caliCompass
*/
void setCalibrateCompass(CalibrateCompass *caliCompass = nullptr);
private:
@@ -25,7 +25,8 @@
* you can add a Point everytime you want.
*
*/
class CaptureRoute : public ManualControl {
class CaptureRoute : public ManualControl
{
public:
/**
* @brief Destroy the Capture Route object
@@ -34,19 +35,13 @@ class CaptureRoute : public ManualControl {
*/
~CaptureRoute();
// /**
// * @brief Get the Navigation object
// *
// * @return Navigation*
// */
// Navigation* getNavigation() const { return this->navigation; }
/**
* @brief Get the Route Info object
*
* @return RouteInfo
*/
RouteInfo getRouteInfo() const { return this->routeInfo; }
Navigation::Status getLastStatus() const { return this->status; }
Navigation *getNavigation() const { return this->navigation; }
@@ -64,6 +59,7 @@ class CaptureRoute : public ManualControl {
* @return false
*/
bool shouldUpdate();
private:
void run() override;
void afterActivate() override;
@@ -13,7 +13,8 @@
#include "driveModi/driveModi.h"
class DirectionChangeWrapper {
class DirectionChangeWrapper
{
public:
virtual void action() = 0;
};
@@ -21,21 +22,37 @@ class DirectionChangeWrapper {
/**
* @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
*
* @see MoveControl
*/
class ManualControl : public DriveModi {
class ManualControl : public DriveModi
{
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,
Digital
};
/**
* @brief Change the InputMode to the opposite
*/
void switchInputMode();
void setInputMode(InputMode mode) { this->inputMode = mode; }
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; }
uint16_t getDutycycleLeft() const { return this->moveControl->getDutycycleLeft(); }
+24 -12
View File
@@ -15,7 +15,8 @@ void TestMode::run()
if (this->maneuver == Maneuver::Turn)
{
uint16_t delta = abs(this->azimuth - this->getSensorData()->getRealAzimuth());
if (delta > this->degree) {
if (delta > this->degree)
{
this->abort = true;
}
}
@@ -31,7 +32,8 @@ void TestMode::run()
bool TestMode::drive(int16_t cmDistance, int16_t degree)
{
if (this->busy){
if (this->busy)
{
return false;
}
@@ -43,10 +45,12 @@ bool TestMode::drive(int16_t cmDistance, int16_t degree)
// Only left or right
this->moveControl->setSpeed(0);
if (degree < 0){
if (degree < 0)
{
this->moveControl->setRotationSpeed(-this->maxSpeeds.rot);
}
else if (degree > 0){
else if (degree > 0)
{
this->moveControl->setRotationSpeed(this->maxSpeeds.rot);
}
@@ -62,10 +66,12 @@ bool TestMode::drive(int16_t cmDistance, int16_t degree)
// Only forward or backward
this->moveControl->setRotationSpeed(0);
if (cmDistance < 0){
if (cmDistance < 0)
{
this->moveControl->setSpeed(-this->maxSpeeds.x);
}
else if (cmDistance > 0){
else if (cmDistance > 0)
{
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
// TODO: Calculate roationspeed
if (cmDistance < 0){
if (cmDistance < 0)
{
this->moveControl->setSpeed(-this->maxSpeeds.x);
}
else if (cmDistance > 0){
else if (cmDistance > 0)
{
this->moveControl->setSpeed(this->maxSpeeds.x);
}
@@ -137,7 +145,8 @@ void TestMode::abortManeuver()
uint8_t TestMode::getRemainingManeuverTime() const
{
if (this->busy){
if (this->busy)
{
return static_cast<uint8_t>((this->maneuverTime - (millis() - this->actionStart)) / 1000);
}
return 0;
@@ -145,13 +154,16 @@ uint8_t TestMode::getRemainingManeuverTime() const
bool TestMode::engineInit(int16_t powerPercentage, int16_t seconds)
{
if (this->busy){
if (this->busy)
{
return false;
}
if (powerPercentage > TestMode::maxPercentage || powerPercentage < -TestMode::maxPercentage){
if (powerPercentage > TestMode::maxPercentage || powerPercentage < -TestMode::maxPercentage)
{
return false;
}
if (seconds < 0){
if (seconds < 0)
{
return false;
}
+9 -1
View File
@@ -26,7 +26,6 @@ class TestMode : public DriveModi
public:
/**
* @brief Different states to test the engine
*
*/
enum Maneuver
{
@@ -38,6 +37,14 @@ public:
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);
/**
@@ -89,6 +96,7 @@ public:
* @return false
*/
bool getBusy() const { return this->busy; }
Maneuver getManeuver() const { return this->maneuver; }
Speedometer *getSpeedometerLeft() const { return this->moveControl->getSpeedometerLeft(); }
Speedometer *getSpeedometerRight() const { return this->moveControl->getSpeedometerRight(); }
+6 -3
View File
@@ -20,9 +20,13 @@
#include "component.h"
#include "sensorData.h"
class DriveManager : public Component {
/**
* @brief A class to manage and hold the different DriveModi
*
*/
class DriveManager : public Component
{
public:
/**
* @brief Construct a new Drive Manager object
*
@@ -73,5 +77,4 @@ class DriveManager : public Component {
DrivingSpeeds drivingSpeeds = {1, 7};
};
#endif // DRIVE_MANAGER_H
+8 -4
View File
@@ -1,26 +1,30 @@
#include "driveModi.h"
DriveModi::~DriveModi() {
DriveModi::~DriveModi()
{
this->moveControl->setSpeed(0);
this->moveControl->setRotationSpeed(0);
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->input = input;
this->sensorData = sensorData;
this->init();
}
void DriveModi::activate(DriveModiParams params){
void DriveModi::activate(DriveModiParams params)
{
this->moveControl = params.moveControl;
this->input = params.input;
this->sensorData = params.sensorData;
this->init();
}
void DriveModi::init() {
void DriveModi::init()
{
this->moveControl->setDrivingStatus(MoveControl::Status::Drive);
this->loopDelay = DriveModi::defaultDelay;
this->afterActivate();
+24 -2
View File
@@ -17,7 +17,11 @@
#include "controlPadInput.h"
#include "sensorData.h"
struct DriveModiParams {
/**
* @brief The struct contains all objects needed by a DriveMode
*/
struct DriveModiParams
{
MoveControl *moveControl;
const ControlPadInput *input;
const SensorData *sensorData;
@@ -29,12 +33,23 @@ struct DriveModiParams {
* This class must be inherited by other classes which want to be
* act as a DriveModi, because the DriveModi structure uses polymorphism.
*/
class DriveModi : public Component {
class DriveModi : public Component
{
public:
virtual ~DriveModi();
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(DriveModiParams params);
@@ -43,6 +58,13 @@ class DriveModi : public Component {
DrivingSpeeds &getSpeedsRef() { return this->maxSpeeds; }
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() {}
MoveControl *moveControl = nullptr;