Finish documention until someone change something

This commit is contained in:
2022-02-15 20:12:50 +01:00
parent 3a2e51713b
commit c8e3344b27
50 changed files with 991 additions and 223 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
/**
* @file menuAkku.cpp
* @author Alexander Klein (alex@kleiax.de)
* @brief
* @brief Contains a implementation of the class MenuAkku
* @version 0.1
* @date 2022-02-05
*
+31 -9
View File
@@ -1,7 +1,7 @@
/**
* @file menuAkku.h
* @author Alexander Klein (alex@kleiax.de)
* @brief
* @brief Contains a Menu class to show battery pack informations
* @version 0.1
* @date 2022-02-05
*
@@ -16,19 +16,41 @@
#include "menuControl.h"
/**
* @brief This class shows Akku informations
*
* Provide information for main battery pack and
* PS3-Controller battery pack
*
*/
class MenuAkku : public MenuControl {
public:
/**
* @brief Construct a new Menu Akku object
*
*/
MenuAkku();
void down(){}
void up(){}
void right();
void left();
void no();
void yes();
void down() override {}
void up() override {}
void right() override;
void left() override;
void no() override;
void yes() override;
void printMenu();
void update();
/**
* @brief Prints the Information to display and console
*
* The informations are only printed to the display if it
* set.
*/
void printMenu() override;
/**
* @brief Renew the informations and print them
*
*/
void update() override;
private:
const uint16_t delay = 5000;
+1 -1
View File
@@ -1,7 +1,7 @@
/**
* @file menuGPS.cpp
* @author Alexander Klein (alex@kleiax.de)
* @brief
* @brief Contains an implementation of the class MenuGPS
* @version 0.1
* @date 2022-01-29
*
+54 -10
View File
@@ -1,7 +1,7 @@
/**
* @file menuGPS.h
* @author Alexander Klein (alex@kleiax.de)
* @brief
* @brief Contains a class to print informations about the GPS object
* @version 0.1
* @date 2022-01-29
*
@@ -16,19 +16,63 @@
#include "menuControl.h"
/**
* @brief A class to print informations about the GPS object
*
*/
class MenuGPS : public MenuControl {
public:
/**
* @brief Construct a new Menu GPS object
*
* @param gps
*/
MenuGPS(TinyGPSPlus* gps);
void down();
void up();
void right();
void left();
void no();
void yes();
void printMenu();
void update();
/**
* @brief Next page
*/
void down() override;
/**
* @brief Previous page
*/
void up() override;
/**
* @brief Update information
*/
void right() override;
/**
* @brief Go to the parent menu
*/
void left() override;
/**
* @brief Go to the parent menu
*/
void no() override;
/**
* @brief Update information
*/
void yes() override;
/**
* @brief Prints the Information to display and console
*
* Prints the selected page.
* The informations are only printed to the display if it
* set.
*/
void printMenu() override;
/**
* @brief can be called to update shown data
*/
void update() override;
private:
const uint8_t countPages = 7;
@@ -41,4 +85,4 @@ class MenuGPS : public MenuControl {
uint32_t last_millis = 0;
};
#endif // MENU_GPS_H
#endif // MENU_GPS_H
+2 -2
View File
@@ -1,7 +1,7 @@
/**
* @file pidSettings.cpp
* @file menuPidSettings.cpp
* @author Alexander Klein (alex@kleiax.de)
* @brief
* @brief Contains an implementation of the class MenuPidSettings
* @version 0.1
* @date 2022-01-19
*
+50 -11
View File
@@ -1,7 +1,7 @@
/**
* @file pidSettings.h
* @file menuPidSettings.h
* @author Alexander Klein (alex@kleiax.de)
* @brief
* @brief Contains a class to tune the PID settings
* @version 0.1
* @date 2022-01-19
*
@@ -18,19 +18,58 @@
#define NUM_VAL 3
/**
* @brief A class to tune the PID settings
*
*/
class MenuPidSettings : public MenuControl {
public:
/**
* @brief Construct a new Menu Pid Settings object
*
* @param pid
*/
MenuPidSettings(PID* pid);
void down();
void up();
void right();
void left();
void no();
void yes();
/**
* @brief Decrement selected value
*/
void down() override;
void printMenu();
void update(){};
/**
* @brief Increment selected value
*/
void up() override;
/**
* @brief Select next value
*/
void right() override;
/**
* @brief Select previous value
*/
void left() override;
/**
* @brief Leave menu without saving
*/
void no() override;
/**
* @brief Leave menu with saving
*/
void yes() override;
/**
* @brief Prints the Information to display and console
*
* The informations are only printed to the display if it
* set.
*/
void printMenu() override;
void update() override {};
private:
PID* pid;
@@ -39,4 +78,4 @@ class MenuPidSettings : public MenuControl {
};
#endif // PID_SETTINGS_H
#endif // PID_SETTINGS_H
@@ -1,7 +1,7 @@
/**
* @file menuAutopilot.cpp
* @author Alexander Klein (alex@kleiax.de)
* @brief
* @brief Contains an implementation of the class MenuAutopilot
* @version 0.1
* @date 2022-02-03
*
@@ -1,7 +1,7 @@
/**
* @file menuAutopilot.h
* @author Alexander Klein (alex@kleiax.de)
* @brief
* @brief Contains a class to print informations about the Autopilot
* @version 0.1
* @date 2022-02-03
*
@@ -14,10 +14,33 @@
#include "SpecialMenus/driveModi/menuDriveMode.h"
/**
* @brief A class to print informations about the Autopilot
*
*/
class MenuAutopilot : public MenuDriveMode {
public:
/**
* @brief Construct a new Menu Autopilot object
*
* @param driveManager for MenuDriveMode
*/
MenuAutopilot(DriveManager* driveManager) : MenuDriveMode(driveManager) {}
/**
* @brief Prints the Information to display and console
*
* The informations are only printed to the display if it
* set.
*
* Changes the DriveModi to Autopilot if it is the first time called
* and save the Autopilot object.
*/
void printMenu();
/**
* @brief can be called to update shown data
*/
void update();
private:
@@ -1,7 +1,7 @@
/**
* @file menuCaptureRoute.cpp
* @author Alexander Klein (alex@kleiax.de)
* @brief
* @brief Contains an implementation of the class MenuCaptureRoute
* @version 0.1
* @date 2022-01-31
*
@@ -1,7 +1,7 @@
/**
* @file menuCaptureRoute.h
* @author Alexander Klein (alex@kleiax.de)
* @brief
* @brief Contains a class to print informations about CaptureRoute
* @version 0.1
* @date 2022-01-31
*
@@ -13,10 +13,33 @@
#include "SpecialMenus/driveModi/menuDriveMode.h"
/**
* @brief A class to print informations about the Autopilot
*
*/
class MenuCaptureRoute : public MenuDriveMode {
public:
/**
* @brief Construct a new Menu Capture Route object
*
* @param driveManager
*/
MenuCaptureRoute(DriveManager* driveManager) : MenuDriveMode(driveManager) {}
/**
* @brief Prints the Information to display and console
*
* The informations are only printed to the display if it
* set.
*
* Changes the DriveModi to CaptureRoute if it is the first time called
* and save the CaptureRoute object.
*/
void printMenu();
/**
* @brief can be called to update shown data
*/
void update();
private:
@@ -26,4 +49,4 @@ class MenuCaptureRoute : public MenuDriveMode {
RouteInfo routeInfo;
};
#endif // MENU_MANUAL_DRIVE_H
#endif // MENU_MANUAL_DRIVE_H
@@ -1,7 +1,7 @@
/**
* @file menuManualDrive.cpp
* @author Alexander Klein (alex@kleiax.de)
* @brief
* @brief Contains an implementation of the class MenuManualDrive
* @version 0.1
* @date 2022-01-20
*
@@ -1,7 +1,7 @@
/**
* @file menuManualDrive.h
* @author Alexander Klein (alex@kleiax.de)
* @brief
* @brief Contains a class to print information about the class ManualControl
* @version 0.1
* @date 2022-01-20
*
@@ -14,10 +14,28 @@
#include "SpecialMenus/driveModi/menuDriveMode.h"
/**
* @brief A class to print informations about the class ManualControl
*
*/
class MenuManualControl : public MenuDriveMode {
public:
/**
* @brief Construct a new Menu Manual Control object
*
* @param driveManager
*/
MenuManualControl(DriveManager* driveManager) : MenuDriveMode(driveManager) {}
/**
* @brief Prints the Information to display and console
*
* The informations are only printed to the display if it
* set.
*
* Changes the DriveModi to Autopilot if it is the first time called.
*/
void printMenu();
};
#endif // MENU_MANUAL_DRIVE_H
#endif // MENU_MANUAL_DRIVE_H
+2 -2
View File
@@ -1,7 +1,7 @@
/**
* @file menuDriveMode.cpp
* @author Alexander Klein (alex@kleiax.de)
* @brief
* @brief Contains an implementation of the class MenuDriveMode
* @version 0.1
* @date 2022-01-31
*
@@ -24,4 +24,4 @@ void MenuDriveMode::left() {
void MenuDriveMode::no() {
this->left();
}
}
+21 -8
View File
@@ -1,7 +1,7 @@
/**
* @file menuDriveMode.h
* @author Alexander Klein (alex@kleiax.de)
* @brief
* @brief Contains a base class for Menus about DriveModi
* @version 0.1
* @date 2022-01-31
*
@@ -14,18 +14,31 @@
#include "menuControl.h"
#include "driveModi/driveManager.h"
/**
* @brief A base class for Menus about DriveModi
*
*/
class MenuDriveMode : public MenuControl {
public:
/**
* @brief Construct a new Menu Drive Mode object
*
* @param driveManager
*/
MenuDriveMode(DriveManager* driveManager);
void down(){}
void up(){}
void right(){}
void left();
void no();
void yes(){}
void down() override {}
void up() override {}
void right() override {}
void left() override;
void no() override;
void yes() override {}
virtual void printMenu() = 0;
/**
* @brief can be called to update shown data
*/
void update(){}
protected:
@@ -33,4 +46,4 @@ class MenuDriveMode : public MenuControl {
bool firstPrint = true;
};
#endif // MENU_DRIVE_MODI_H
#endif // MENU_DRIVE_MODI_H
+1 -1
View File
@@ -1,7 +1,7 @@
/**
* @file autopilot.cpp
* @author Alexander Klein (alex@kleiax.de)
* @brief
* @brief Contains the implementation of the class Autopilot
* @version 0.1
* @date 2022-02-02
*
+80 -2
View File
@@ -1,7 +1,7 @@
/**
* @file autopilot.h
* @author Alexander Klein (alex@kleiax.de)
* @brief
* @brief Contains a class which use the navigate class to drive automaticaly
* @version 0.1
* @date 2022-02-02
*
@@ -17,20 +17,98 @@
#include "moveControl.h"
#include "driveModi/Modi/ManualControl/manualControl.h"
/**
* @brief This class use the navigate class to drive automaticaly
*
* This class get the information from the navigate class. When an
* object of this class is constructed the rover can be driven manually.
* When the Rover is near to the first position of the Route, you can
* switch to automatic drive.
*
*/
class Autopilot : public ManualControl {
public:
/**
* @brief Construct a new Autopilot object
*
* @param moveControl for ManualControl
* @param navigation for route instructions
*/
Autopilot(MoveControl* moveControl, Navigation* navigation);
/**
* @brief Calls runAutopilot or ManualControl loop
*
* This function should be called every main loop. If self
* driving is activated the function call run Autopilot. If
* the delay is not reached the function returns immediately.
*
* If self driving is not activated this functions calls the
* ManualControl loop additionally.
*/
void loop();
/**
* @brief Manges the autoipilot
*
* If the first Point is near to current location you can turn
* the autopilot on.
* Gets the course correction and decide what to do.
*/
void runAutopilot();
/**
* @brief Get the Route Info object
*
* @return RouteInfo
*/
RouteInfo getRouteInfo() const { return this->routeInfo; }
/**
* @brief Get the Course Correction object
*
* @return CourseCorrection
*/
CourseCorrection getCourseCorrection() const { return this->courseCorrection; }
/**
* @brief Get the Navigation Started status
*
* @return true
* @return false
*/
bool getNavigationStarted() const { return this->navigationStarted; }
/**
* @brief Get the Navigation Ended status
*
* @return true
* @return false
*/
bool getNavigationEnded() const { return this->navigationEnded; }
/**
* @brief Get the Self Driving status
*
* @return true
* @return false
*/
bool getSelfDriving() const { return this->selfDriving; }
/**
* @brief Get the Self Driving Available status
*
* @return true
* @return false
*/
bool getSelfDrivingAvailable() const { return this->selfDrivingAvailable; }
/**
* @brief Tells if there are new informations to display
*
* @return true
* @return false
*/
bool shouldUpdate();
private:
@@ -52,4 +130,4 @@ class Autopilot : public ManualControl {
uint8_t delay = 40;
};
#endif // AUTOPILOT_H
#endif // AUTOPILOT_H
@@ -1,3 +1,14 @@
/**
* @file captureRoute.cpp
* @author Alexander Klein (alex@kleiax.de)
* @brief Contains the implementation of the class CaptureRoute
* @version 0.1
* @date 2022-02-15
*
* @copyright Copyright (c) 2022
*
*/
#include "driveModi/Modi/CaptureRoute/captureRoute.h"
CaptureRoute::CaptureRoute(MoveControl* moveControl, Navigation* navigation)
@@ -31,4 +42,4 @@ bool CaptureRoute::shouldUpdate() {
return true;
}
return false;
}
}
+55 -2
View File
@@ -1,3 +1,14 @@
/**
* @file captureRoute.h
* @author Alexander Klein (alex@kleiax.de)
* @brief Contains a class to capture a driven route
* @version 0.1
* @date 2022-02-15
*
* @copyright Copyright (c) 2022
*
*/
#ifndef CAPTURE_ROUTE_H
#define CAPTURE_ROUTE_H
@@ -6,17 +17,59 @@
#include "driveModi/Modi/ManualControl/manualControl.h"
#include "navigation.h"
/**
* @brief A class to capture a driven class
*
* This class inherits ManualControl so you can drive
* normally as in ManualControl. If GPS signal is valid
* you can add a Point everytime you want.
*
*/
class CaptureRoute : public ManualControl {
public:
/**
* @brief Construct a new Capture Route object
*
* @param moveControl for ManualControl
* @param navigation to add Points
*/
CaptureRoute(MoveControl* moveControl, Navigation* navigation);
/**
* @brief Calls runCaptureRoute and ManualControl::loop
*
* Calls everytime the other loop but only calls runCaptureRoute
* if the delay is reached.
*
*/
void loop();
/**
* @brief Checks if a Point should be added to the Route
*
*/
void runCaptureRoute();
/**
* @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; }
/**
* @brief Tells if there are new informations to display
*
* @return true
* @return false
*/
bool shouldUpdate();
private:
Navigation* navigation;
@@ -28,4 +81,4 @@ class CaptureRoute : public ManualControl {
bool updateDisplay = false;
};
#endif // CAPTURE_ROUTE_H
#endif // CAPTURE_ROUTE_H
@@ -1,43 +1,13 @@
/**
* @file consolControl.cpp
* @author Alexander Klein (alex@kleiax.de)
* @brief
* @version 0.1
* @date 2022-02-15
*
* @copyright Copyright (c) 2022
*
*/
#include "consolControl.h"
ConsolControl::ConsolControl() {
this->debug = new DebugMqtt("ConsolControl");
}
void ConsolControl::init(MoveControl *MoveControl) {
this->moveControl = moveControl;
}
void ConsolControl::run() {
uint8_t side = -1;
if (Serial.available()) {
char cmd = Serial.read();
if (cmd == 'l') {
side = 0;
} else if (cmd == 'r') {
side = 1;
}
double p = Serial.parseFloat();
double i = Serial.parseFloat();
double d = Serial.parseFloat();
double s = Serial.parseFloat();
double r = Serial.parseFloat();
if (p && i && d && s && r) {
Serial.println("ConsolControl changeDate");
this->moveControl->setPidTunings(side, p, i, d);
this->moveControl->setSpeed(s);
this->moveControl->setRotationspeed(r);
} else {
this->moveControl->setDrivingStatus(DrivingStatus::stop);
printManual();
debug->sendMsg(Loglevel::error, "not all double are not zero");
}
}
}
void ConsolControl::printManual() {
Serial.println("r 12.0 13.0 4.0 1.0 1.0 // site p i d s r");
}
@@ -1,24 +1,20 @@
/**
* @file consolControl.h
* @author Alexander Klein (alex@kleiax.de)
* @brief
* @version 0.1
* @date 2022-02-15
*
* @copyright Copyright (c) 2022
*
*/
#ifndef CONSOL_CONTROL_H
#define CONSOL_CONTROL_H
#include <string>
#include "moveControl.h"
#include "driveModi/driveModi.h"
#include "debugMqtt.h"
class ConsolControl : DriveModi{
public:
ConsolControl();
void init(MoveControl *moveControl);
void run();
private:
void printManual();
MoveControl *moveControl;
DebugMqtt *debug;
};
#endif // CONSOL_CONTROL_H
#endif // CONSOL_CONTROL_H
@@ -51,7 +51,7 @@ class ManualControl : public DriveModi{
/**
* @brief Set the min delay between each loop
*
* @param delay time in Milliseconds
* @param delay_ time in Milliseconds
*/
void setDelay(uint8_t delay_) { delay = delay_; }
@@ -79,4 +79,4 @@ class ManualControl : public DriveModi{
double max_rotation = 7;
};
#endif // MANUAL_CONTROL_H
#endif // MANUAL_CONTROL_H
+2 -1
View File
@@ -1,7 +1,7 @@
/**
* @file driveManager.cpp
* @author Alexander Klein (alex@kleiax.de)
* @brief Implemention of the class driveManager.h.
* @brief Implemention of the class DriveManager
* @version 0.1
* @date 2021-12-14
*
@@ -17,6 +17,7 @@ Modi& operator++(Modi& m, int) {
DriveManager::DriveManager(MoveControl *moveControl) {
this->moveControl = moveControl;
// TODO: Delete magic numbers
this->navigation = new Navigation(17, 16);
}
+64 -1
View File
@@ -30,6 +30,10 @@
#include "driveModi/Modi/ConsolControl/consolControl.h"
#include "driveModi/Modi/TestMode/testMode.h"
/**
* @brief An enum to choose the DriveMode
*
*/
enum class Modi {
Off,
ManualControl,
@@ -41,15 +45,74 @@ enum class Modi {
class DriveManager {
public:
/**
* @brief Construct a new Drive Manager object
*
* Creates a Navigation object
*
* @param moveControl
*/
DriveManager(MoveControl *moveControl);
/**
* @brief Destroy the Drive Manager object
*
*/
~DriveManager();
/**
* @brief Calls all loop functions
*
* Calls the MoveControl, Navigation loop function. The
* loop function from the DriveMode is called if it is set.
*
* This function should be called every main loop.
*
*/
void loop();
/**
* @brief Increment the DriveModi enum
* Than calls changeModus
*
* @see Modi
*/
void nextModus();
/**
* @brief Change the DriveModi to a specific value
*
* Sets MoveControl to a safe state, delete the last
* DriveModi and than set the new DriveModi
*
* @param modus
*/
void changeModus(Modi modus);
/**
* @brief Get the Navigation object
*
* @return Navigation*
*/
Navigation* getNavigation() {return this->navigation;}
/**
* @brief Get the DriveModi Ptr object
*
* This is a pointer to the Object of the current DriveMode.
* If you know which DriveMode is active, you can cast this
* pointer to it.
*
* @see getDriveModi
* @return DriveModi*
*/
DriveModi* getDriveModiPtr() { return this->currentModusPtr; }
/**
* @brief Get the DriveModi enum
*
* @return Modi
*/
Modi getDriveModi() { return this->currentModus; }
private:
@@ -60,4 +123,4 @@ class DriveManager {
};
#endif // DRIVE_MANAGER_H
#endif // DRIVE_MANAGER_H
+14 -1
View File
@@ -14,11 +14,24 @@
#include <Ps3Controller.h>
/**
* @brief Baseclass to build DriveModi
*
* 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:
DriveModi(){}
virtual ~DriveModi(){}
/**
* @brief This function is called by the DriveManager
*
* All actions from a DriveMode have to called from
* this function or the PS3-Controller
*/
virtual void loop() = 0;
};
#endif // DRIVEMODI_H
#endif // DRIVEMODI_H
+16 -1
View File
@@ -1,3 +1,18 @@
/**
* @file main.cpp
* @author Alexander Klein (alex@kleiax.de)
* @brief The main file.
*
* Sets up Network stuff, PS3-Controller, Menu and Lcd
* Handles Controller Input
*
* @version 0.1
* @date 2022-02-15
*
* @copyright Copyright (c) 2022
*
*/
#include <Arduino.h>
#include <Ps3Controller.h>
#include <iostream>
@@ -42,7 +57,7 @@ void setup() {
Network::connectWifi();
Network::setupMQTT();
Network::checkMQTT();
DebugMqtt::init(Network::getMqtttClient(), Loglevel::debug);
DebugMqtt::init(Network::getMqttClient(), Loglevel::debug);
std::cout << "Activate additional output via MQTT..." << std::endl;
debugMqtt = new DebugMqtt("Console");
+10
View File
@@ -1,3 +1,13 @@
/**
* @file moveControl.cpp
* @author Alexander Klein (alex@kleiax.de)
* @brief Contains an implementation of the class MoveControl
* @version 0.1
* @date 2022-02-15
*
* @copyright Copyright (c) 2022
*
*/
#include "moveControl.h"
MoveControl::MoveControl() {
+2 -2
View File
@@ -1,7 +1,7 @@
/**
* @file network.cpp
* @author Alexander Klein (alex@kleiax.de)
* @brief TODO: write some stuff
* @brief Contains the implementation of the ststic class Network
* @version 0.1
* @date 2021-12-14
*
@@ -86,6 +86,6 @@ void Network::checkMQTT() {
mqtt_client->loop();
}
PubSubClient* Network::getMqtttClient() {
PubSubClient* Network::getMqttClient() {
return mqtt_client;
}