diff --git a/.vscode/settings.json b/.vscode/settings.json index bed1279..b8d72a8 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -78,5 +78,18 @@ "streambuf": "cpp", "functional": "cpp", "cmath": "cpp" - } -} \ No newline at end of file + }, + "cSpell.words": [ + "Ahnung", + "akku", + "gast", + "Huus", + "Keine", + "kleiax", + "Lebennig", + "Punica", + "RHEDE", + "TPMOBIL", + "ZLPJ" + ] +} diff --git a/doc/Doxygen/Doxyfile b/doc/Doxygen/Doxyfile index 8d490bc..74eb00a 100644 --- a/doc/Doxygen/Doxyfile +++ b/doc/Doxygen/Doxyfile @@ -483,7 +483,7 @@ EXTRACT_ALL = YES # be included in the documentation. # The default value is: NO. -EXTRACT_PRIVATE = NO +EXTRACT_PRIVATE = YES # If the EXTRACT_PRIV_VIRTUAL tag is set to YES, documented private virtual # methods of a class will be included in the documentation. @@ -501,7 +501,7 @@ EXTRACT_PACKAGE = NO # included in the documentation. # The default value is: NO. -EXTRACT_STATIC = NO +EXTRACT_STATIC = YES # If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined # locally in source files will be included in the documentation. If set to NO, @@ -793,7 +793,7 @@ CITE_BIB_FILES = # messages are off. # The default value is: NO. -QUIET = NO +QUIET = YES # The WARNINGS tag can be used to turn on/off the warning messages that are # generated to standard error (stderr) by doxygen. If WARNINGS is set to YES @@ -834,7 +834,7 @@ WARN_IF_INCOMPLETE_DOC = YES # WARN_IF_INCOMPLETE_DOC # The default value is: NO. -WARN_NO_PARAMDOC = NO +WARN_NO_PARAMDOC = YES # If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when # a warning is encountered. If the WARN_AS_ERROR tag is set to FAIL_ON_WARNINGS @@ -932,7 +932,6 @@ FILE_PATTERNS = *.c \ *.md \ *.mm \ *.dox \ - *.py \ *.pyw \ *.f90 \ *.f95 \ @@ -945,7 +944,8 @@ FILE_PATTERNS = *.c \ *.vhdl \ *.ucf \ *.qsf \ - *.ice + *.ice \ + *.cpp # The RECURSIVE tag can be used to specify whether or not subdirectories should # be searched for input files as well. @@ -2358,7 +2358,7 @@ EXTERNAL_PAGES = YES # powerful graphs. # The default value is: YES. -CLASS_DIAGRAMS = YES +CLASS_DIAGRAMS = NO # You can include diagrams made with dia in doxygen documentation. Doxygen will # then run dia to produce the diagram and insert it in the documentation. The @@ -2380,7 +2380,7 @@ HIDE_UNDOC_RELATIONS = YES # set to NO # The default value is: NO. -HAVE_DOT = NO +HAVE_DOT = YES # The DOT_NUM_THREADS specifies the number of dot invocations doxygen is allowed # to run in parallel. When set to 0 doxygen will base this on the number of @@ -2519,7 +2519,7 @@ INCLUDED_BY_GRAPH = YES # The default value is: NO. # This tag requires that the tag HAVE_DOT is set to YES. -CALL_GRAPH = NO +CALL_GRAPH = YES # If the CALLER_GRAPH tag is set to YES then doxygen will generate a caller # dependency graph for every global function or class method. @@ -2531,7 +2531,7 @@ CALL_GRAPH = NO # The default value is: NO. # This tag requires that the tag HAVE_DOT is set to YES. -CALLER_GRAPH = NO +CALLER_GRAPH = YES # If the GRAPHICAL_HIERARCHY tag is set to YES then doxygen will graphical # hierarchy of all classes instead of a textual one. diff --git a/doc/Notes and TODOs/TODO allgemein.txt b/doc/Notes and TODOs/TODO allgemein.txt index 61449f3..4fadd46 100644 --- a/doc/Notes and TODOs/TODO allgemein.txt +++ b/doc/Notes and TODOs/TODO allgemein.txt @@ -1,2 +1,3 @@ -Menu hat manchmal speicher leaks :/ + -> Document the Akku lib + -> Program underfloorLighting diff --git a/include/config.h b/include/config.h index 9217138..dd64a00 100644 --- a/include/config.h +++ b/include/config.h @@ -1,2 +1,17 @@ -// PS3 Controller +/** + * @file config.h + * @author Alexander Klein (alex@kleiax.de) + * @brief Some defines to configere the project. + * @version 0.1 + * @date 2022-02-15 + * + * @copyright Copyright (c) 2022 + * + */ + +/** + * @brief The MAC-Address saved in PS3-Controller + * + * The PS3-Controller only connects to the address which is saved in it. + */ #define CONTROLLER_MAC "24:62:AB:F2:4B:3A" diff --git a/include/moveControl.h b/include/moveControl.h index b726103..fde1163 100644 --- a/include/moveControl.h +++ b/include/moveControl.h @@ -1,7 +1,7 @@ /** * @file moveControl.h * @author Alexander Klein (alex@kleiax.de) - * @brief Contrains the MoveControl class + * @brief Contains the MoveControl class * @version 0.1 * @date 2021-12-14 * @@ -32,7 +32,7 @@ enum DrivingStatus {stop, /** * @brief This class manages the motors and the encoders * - * The controler uses two PIDs to control the motors. The PIDs + * The class uses two PIDs to control the motors. The PIDs * use the Speedometer class to get the current speed and the * given target speed to calculate a new duty cycle for the motors. * @@ -42,7 +42,7 @@ class MoveControl { /** * @brief Construct a new Move Control object * - * Initalize the motors, encoders and PIDs with given + * Initialize the motors, encoders and PIDs with given * values in moveControlConfig.h */ MoveControl(); @@ -66,14 +66,14 @@ class MoveControl { void loop(); /** - * @brief Noramly called repeatedly by loop() to calcluate new values. + * @brief Normally called repeatedly by loop() to calculate new values. */ void runMoveControl(); /** * @brief Set the DrivingStatus * - * @see DrDrivingStatus + * @see DrivingStatus * @param status */ void setDrivingStatus(DrivingStatus status); @@ -99,8 +99,6 @@ class MoveControl { /** * @brief Set the pid tunings * - * TODO: check if the function is working or indicates seg fault - * * @param side 0 -> left, 1 -> right * @param p * @param i @@ -119,7 +117,7 @@ class MoveControl { /** * @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_; } diff --git a/include/moveControlConfig.h b/include/moveControlConfig.h index 322525c..f5060af 100644 --- a/include/moveControlConfig.h +++ b/include/moveControlConfig.h @@ -1,7 +1,7 @@ /** * @file moveControlConfig.h * @author Alexander Klein (alex@kleiax.de) - * @brief This file inherits some configuartion for moveControl.h + * @brief This file inherits some configurations for moveControl.h * @version 0.1 * @date 2021-12-14 * @@ -41,4 +41,4 @@ // SPEEDOMETER #define WHEEL_DIAMETER 0.1263 - #define ENC_STEPS 1024 \ No newline at end of file + #define ENC_STEPS 1024 diff --git a/include/network.h b/include/network.h index 141893f..40b3879 100644 --- a/include/network.h +++ b/include/network.h @@ -1,7 +1,7 @@ /** * @file network.h * @author Alexander Klein (alex@kleiax.de) - * @brief TODO: write some stuff here too + * @brief Contains the Network class. * @version 0.1 * @date 2021-12-14 * @@ -18,17 +18,53 @@ #include "networkConfig.h" -#define MQTT_TIME_RECONNECT 2500 - +/** + * @brief This class handles all network stuff + * + * This class only inherits static functions and members and use + * only the configuration data is given by networkConfig.h + * + */ class Network { public: + /** + * @brief Set the all IPs needed by this class + */ static void setIps(); + + /** + * @brief Establish a connection to the WiFi. + */ static void connectWifi(); + + /** + * @brief Set all general settings to connect to a broker. + */ static void setupMQTT(); + + /** + * @brief Checks if mqtt is still connected + * + * If mqtt is not connect, this function try a reconnect + * with the function connectMQTT. This function should be + * called every mainloop. + */ static void checkMQTT(); - static PubSubClient* getMqtttClient(); + + /** + * @brief Get the Mqtt Client object + * + * @return PubSubClient* + */ + static PubSubClient* getMqttClient(); private: + /** + * @brief Tries a connect to the broker + * + * @return true if the connect attemp was successful + * @return false if the connect attemp was unsuccessful + */ static bool connectMQTT(); static IPAddress local_IP; diff --git a/include/networkConfig.h b/include/networkConfig.h index 403018b..dfb753d 100644 --- a/include/networkConfig.h +++ b/include/networkConfig.h @@ -1,5 +1,22 @@ +/** + * @file networkConfig.h + * @author Alexander Klein (alex@kleiax.de) + * @brief Contains the settings for the Network class + * + * With different defines the location can be choosen. + * + * @version 0.1 + * @date 2022-02-15 + * + * @copyright Copyright (c) 2022 + * + */ + +// General config +#define MQTT_TIME_RECONNECT 2500 #define HW1 + //Network config RHEDE #ifdef RHEDE #define WLAN_SSID "LebennigHuus" diff --git a/lib/MQTT/debugMqtt.cpp b/lib/MQTT/debugMqtt.cpp index a58d001..44a2fe9 100644 --- a/lib/MQTT/debugMqtt.cpp +++ b/lib/MQTT/debugMqtt.cpp @@ -18,9 +18,11 @@ char DebugMqtt::msg[MQTT_BUFFER_SIZE]; char DebugMqtt::topic[MQTT_BUFFER_SIZE]; -DebugMqtt::DebugMqtt(const char* name) { +DebugMqtt::DebugMqtt(const char* name, uint8_t bufSize) { this->name = name; - this->buf = new char[this->bufSitze]; + if (bufSize != 0) + this->bufSize = bufSize; + this->buf = new char[this->bufSize]; } DebugMqtt::~DebugMqtt() { @@ -62,7 +64,7 @@ void DebugMqtt::writeToInflux(String measurement_name, String field_set, float m void DebugMqtt::addCharacter(char c) { this->buf[this->bufPos] = c; this->bufPos++; - if (c == '\n' || this->bufPos >= this->bufSitze - 1) { + if (c == '\n' || this->bufPos >= this->bufSize - 1) { this->buf[this->bufPos - 1] = '\0'; this->sendMsg(Loglevel::info, buf); this->bufPos = 0; diff --git a/lib/MQTT/debugMqtt.h b/lib/MQTT/debugMqtt.h index af97b48..672e9a6 100644 --- a/lib/MQTT/debugMqtt.h +++ b/lib/MQTT/debugMqtt.h @@ -69,15 +69,16 @@ class DebugMqtt { * @brief Construct a new Debug Mqtt object. * * @param name A String with send with every Message. + * @param bufSize for the addCharacter function. */ - DebugMqtt(const char* name); + DebugMqtt(const char* name, uint8_t bufSize = 0); ~DebugMqtt(); /** * @brief Send a Message via MQTT * - * This funtion uses sendData to send the given string and + * This function uses sendData to send the given string and * add the name to the message given by the constructer. * * @see sendData() @@ -93,9 +94,9 @@ class DebugMqtt { /** * @brief Send a Message via MQTT * - * This funtion sends the Data via MQTT with the given topic + * This function sends the Data via MQTT with the given topic * from Loglevel or followed by given String topic. - * Normaly this function is called by sendMsg() or by + * Normally this function is called by sendMsg() or by * writeToInflux() * * @see sendData() @@ -112,7 +113,7 @@ class DebugMqtt { /** * @brief Send a Message via MQTT for InfluxDB * - * This funtion sends a MQTT message which is intended for + * This function sends a MQTT message which is intended for * Telegraf. Telegraf can listen on MQTT messages and put * them in an Influx Database. * @@ -123,14 +124,23 @@ class DebugMqtt { */ void writeToInflux(String measurement_name, String field_set, float measurement, uint64_t nanos); + /** + * @brief Adds a single character to the buf + * + * The buf will be flushed out: + * 1. when the buffer is full + * 2. when the character is '\n' + * + * @param c + */ void addCharacter(char c); /** - * @brief Initalize debugMQTT for all instances + * @brief Initialize debugMQTT for all instances * * You only have to call this function once for your project. - * If you call this funtion again you overwrite the client and - * the loglevel. If you only eant du overwrite the max_loglevel + * If you call this function again you overwrite the client and + * the loglevel. If you only want du overwrite the max_loglevel * use changeLoglevel() * * @see changeLoglevel() @@ -153,7 +163,7 @@ class DebugMqtt { const char* name; char* buf; uint8_t bufPos = 0; - uint8_t bufSitze = 100; + uint8_t bufSize = 100; static String enum_to_string(Loglevel loglevel); diff --git a/lib/MQTT/outputBufMqtt.cpp b/lib/MQTT/outputBufMqtt.cpp index ab3bdff..f7abb56 100644 --- a/lib/MQTT/outputBufMqtt.cpp +++ b/lib/MQTT/outputBufMqtt.cpp @@ -1,7 +1,7 @@ /** - * @file outputStreamMqtt.cpp + * @file outputBufMqtt.cpp * @author Alexander Klein (alex@kleiax.de) - * @brief + * @brief Contains the implementation of the class OutputBufMqtt * @version 0.1 * @date 2022-02-14 * diff --git a/lib/MQTT/outputBufMqtt.h b/lib/MQTT/outputBufMqtt.h index a63477a..5ded5b9 100644 --- a/lib/MQTT/outputBufMqtt.h +++ b/lib/MQTT/outputBufMqtt.h @@ -1,7 +1,11 @@ /** - * @file outputStreamMqtt.h + * @file outputBufMqtt.h * @author Alexander Klein (alex@kleiax.de) - * @brief + * @brief Contains a small class that provide a streambuf + * + * The streambuf is used to double the std::cout to consol + * and MQTT. + * * @version 0.1 * @date 2022-02-14 * @@ -19,11 +23,29 @@ #include "debugMqtt.h" +/** + * @brief A alternativ streambuf for std::cout + * + * The streambuf is used to double the std::cout to consol + * and MQTT. + * + */ class OutputBufMqtt : public std::streambuf { public: + /** + * @brief Construct a new Output Buf Mqtt object + * + * @param debugMqtt + */ OutputBufMqtt(DebugMqtt* debugMqtt); protected: + /** + * @brief + * + * @param c + * @return std::streambuf::int_type + */ virtual std::streambuf::int_type overflow(std::streambuf::int_type c); public: diff --git a/lib/Menu/menu.cpp b/lib/Menu/menu.cpp index 7a22f6f..c52b01f 100644 --- a/lib/Menu/menu.cpp +++ b/lib/Menu/menu.cpp @@ -1,7 +1,7 @@ /** * @file menu.cpp * @author Alexander Klein (alex@kleiax.de) - * @brief + * @brief Implementation of the class Menu * @version 0.1 * @date 2022-01-12 * diff --git a/lib/Menu/menu.h b/lib/Menu/menu.h index 0fbba40..e72825b 100644 --- a/lib/Menu/menu.h +++ b/lib/Menu/menu.h @@ -1,7 +1,7 @@ /** * @file menu.h * @author Alexander Klein (alex@kleiax.de) - * @brief + * @brief Contains the Menu class * @version 0.1 * @date 2022-01-12 * @@ -17,20 +17,30 @@ #include "menuControl.h" class MenuAction; + +/** + * @brief A class to build menu structers + */ class Menu : public MenuControl { public: Menu(); + /** + * @brief Add a menu action to the menu + * + * @param entry + */ void addEntry(MenuAction* entry); - void printMenu(); - void update(); - void down(); - void up(); - void right(); - void left(); - void yes(); - void no(); + void printMenu() override; + void update() override; + + void down() override; + void up() override; + void right() override; + void left() override; + void yes() override; + void no() override; private: bool inSubmenu = false; @@ -40,4 +50,4 @@ class Menu : public MenuControl { }; -#endif // MENU_H \ No newline at end of file +#endif // MENU_H diff --git a/lib/Menu/menuAction.cpp b/lib/Menu/menuAction.cpp index 1b4de3e..e80f609 100644 --- a/lib/Menu/menuAction.cpp +++ b/lib/Menu/menuAction.cpp @@ -1,7 +1,7 @@ /** - * @file menuEntry.cpp + * @file menuAction.cpp * @author Alexander Klein (alex@kleiax.de) - * @brief + * @brief Implentation of the class MenuAction * @version 0.1 * @date 2022-01-12 * @@ -16,20 +16,6 @@ MenuAction::MenuAction(const char* name, void (*function) (), void (*callback) ( this->callback = callback; } -MenuAction::MenuAction(const char* name, void (*function) ()) { - this->name = name; - this->function = function; - this->callback = nullptr; -} - -// MenuAction::MenuAction(const char* name, void (DriveManager:: *classFunction) ()) { -// this->name = name; -// this->classFunction = classFunction; -// this->classFunc = true; -// this->function = nullptr; -// this->callback = nullptr; -// } - MenuAction::MenuAction(const char* name, MenuControl* menu) { this->name = name; this->menu = menu; @@ -60,4 +46,4 @@ MenuControl* MenuAction::getMenu() { return this->menu; else return nullptr; -} \ No newline at end of file +} diff --git a/lib/Menu/menuAction.h b/lib/Menu/menuAction.h index 8175dd3..3c25d9a 100644 --- a/lib/Menu/menuAction.h +++ b/lib/Menu/menuAction.h @@ -1,7 +1,7 @@ /** - * @file menuEntry.h + * @file menuAction.h * @author Alexander Klein (alex@kleiax.de) - * @brief + * @brief Contains the MenuAction class * @version 0.1 * @date 2022-01-12 * @@ -14,15 +14,63 @@ #include "menu.h" class MenuControl; + +/** + * @brief This class forms the transition between menus. + * + * In the Menu these are the entries. + * This class can be call an submenu or a function. + */ class MenuAction { public: - MenuAction(const char* name, void (*function) (), void (*callback) ()); - MenuAction(const char* name, void (*function) ()); + + /** + * @brief Construct a new Menu Action object + * + * @param name shown in the Menu + * @param function to call when activate the entry + * @param callback to call when leave the entry + */ + MenuAction(const char* name, void (*function) (), void (*callback) () = nullptr); + + /** + * @brief Construct a new Menu Action object + * + * This constructer is used for submenus. + * + * @param name shown in the Menu + * @param menu to call when activate the entry + */ MenuAction(const char* name, MenuControl* menu); + + /** + * @brief activates the entry + */ void runAction(); + /** + * @brief Get the Name string + * + * @return const char* + */ const char* getName(); + + /** + * @brief Get the Is Menu object + * + * @return true runAction calls a submenu + * @return false runAction call a function + */ bool getIsMenu(); + + /** + * @brief Get the Menu object + * + * Before call this function it may be useful + * to check if is it a submenu with getIsMenu. + * + * @return MenuControl* + */ MenuControl* getMenu(); private: @@ -35,4 +83,4 @@ class MenuAction { MenuControl* menu; }; -#endif // MENU_ENTRY_H \ No newline at end of file +#endif // MENU_ENTRY_H diff --git a/lib/Menu/menuControl.h b/lib/Menu/menuControl.h index eca689e..e57f325 100644 --- a/lib/Menu/menuControl.h +++ b/lib/Menu/menuControl.h @@ -1,7 +1,7 @@ /** * @file menuControl.h * @author Alexander Klein (alex@kleiax.de) - * @brief + * @brief Contains a abstract class for Menu * @version 0.1 * @date 2022-01-19 * @@ -15,25 +15,59 @@ #include #include +/** + * @brief Baseclass to build Menus + * + * This class must be inherited by other classes which want to be + * act as a menu, because the menu structure uses polymorphism. + * + */ class MenuControl { public: - // Ínputs from the Gamepad + /** @name UserInputs + * @brief This functions should be called be user actions. + * + * This functions have to be implement in every other menu + * class. + */ + ///@{ virtual void down(); virtual void up(); virtual void right(); virtual void left(); virtual void yes(); virtual void no(); + ///@} + /** + * @brief can be called to update shown data + */ virtual void update(); virtual void printMenu(); + + /** + * @brief Set the Parent Menu + * + * If the parentMenu is set it will be called automaticaly + * when the user left the child menu. + * + * @param menu + */ void setParentMenu(MenuControl* menu) { this->parentMenu = menu; } + + /** + * @brief Set the Lcd object + * + * If this is set the menu will be print on the display too. + * + * @param lcd + */ void setLcd(LiquidCrystal_I2C* lcd) { this->lcd = lcd; } protected: MenuControl* parentMenu = nullptr; LiquidCrystal_I2C* lcd = nullptr; }; -#endif // MENU_CONTROLL_H \ No newline at end of file +#endif // MENU_CONTROLL_H diff --git a/lib/MotorControl/motorControl.h b/lib/MotorControl/motorControl.h index 42524c7..7337b3f 100644 --- a/lib/MotorControl/motorControl.h +++ b/lib/MotorControl/motorControl.h @@ -32,7 +32,7 @@ class MotorControl { MotorControl(); /** - * @brief Initalize the motorcontroler + * @brief Initialize the motorController * * @param pwm_pin The output pin for the signal on the esp. * @param pwm_channel One of the pwm channels from the esp. @@ -53,7 +53,7 @@ class MotorControl { uint16_t loop(); /** - * @brief Normaly called repeatedly by loop() to update the pwm signal. + * @brief Normally called repeatedly by loop() to update the pwm signal. * * Checks the difference between target power and current power to * increase or decrease the duty cycle. The amount of decrease or increase @@ -167,4 +167,4 @@ class MotorControl { }; -#endif // MOTOR_CONTROL_H \ No newline at end of file +#endif // MOTOR_CONTROL_H diff --git a/lib/Navigation/navigation.cpp b/lib/Navigation/navigation.cpp index 371448d..41e789b 100644 --- a/lib/Navigation/navigation.cpp +++ b/lib/Navigation/navigation.cpp @@ -1,7 +1,7 @@ /** * @file navigation.cpp * @author Alexander Klein (alex@kleiax.de) - * @brief + * @brief Contains the implementation of the class Navigation * @version 0.1 * @date 2022-01-31 * @@ -50,7 +50,7 @@ CourseCorrection Navigation::getCourseCorrection() { Point currentPos = this->currentLocation(); double targetCourse = Navigation::courseTo(currentPos, this->targetPoint); - double distance = Navigation::distanceBetwenn(currentPos, this->targetPoint); + double distance = Navigation::distanceBetween(currentPos, this->targetPoint); if (targetCourse < 0 || distance < 0 || this->navigationFinished) return courseCorrection; @@ -89,7 +89,7 @@ bool Navigation::addCurrentPosToRoute() { } // Ever Point after the first - if (MIN_DISTANCE_BETWEEN_POINTS <= this->distanceBetwenn(p, this->lastPoint)) { + if (MIN_DISTANCE_BETWEEN_POINTS <= this->distanceBetween(p, this->lastPoint)) { this->route->addPointToRoute(p); this->lastPoint = p; return true; @@ -121,7 +121,7 @@ bool Navigation::setTargetPoint(Point target) { return false; } -double Navigation::distanceBetwenn(Point p1, Point p2) { +double Navigation::distanceBetween(Point p1, Point p2) { if (p1.isValid() && p2.isValid()) return TinyGPSPlus::distanceBetween(p1.lat, p1.lon, p2.lat, p2.lon); return -1; diff --git a/lib/Navigation/navigation.h b/lib/Navigation/navigation.h index c01263f..3e50ded 100644 --- a/lib/Navigation/navigation.h +++ b/lib/Navigation/navigation.h @@ -1,7 +1,7 @@ /** * @file navigation.h * @author Alexander Klein (alex@kleiax.de) - * @brief + * @brief Contains a class which navigate an object by the given route * @version 0.1 * @date 2022-01-10 * @@ -18,33 +18,153 @@ #include "route.h" +/** + * @brief The minimal distance between Points + * + * This is a very critical option. It have to be + * around the half accuracy of the positioning system + * + */ #define MIN_DISTANCE_BETWEEN_POINTS 1 +/** + * @brief This struct inherits the result of the navigation + * + * The drive get objects of this struct and should + * correct the direction in dependency on this. + * + */ struct CourseCorrection { int16_t correction; double distance; }; + +/** + * @brief This class navigate an object + * + * The class use the given Route and the gps device + * to tell the driver in which direction he have to + * be drive and the distance to the next checkpoint. + * + */ class Navigation { public: + /** + * @brief Construct a new Navigation object + * + * @param rx pin to the gps device + * @param tx pin to the gps device + * @param route with which to navigate + */ Navigation(uint8_t rx, uint8_t tx, Route* route = nullptr); + + /** + * @brief Destroy the Navigation object + * + */ ~Navigation(); + + /** + * @brief Decodes new GPS information + * + * Should be called ever main loop. + */ void loop(); + /** + * @brief creates a new empty route + * + */ void newRoute(); + /** + * @brief Tries to start the route + * + * For example the route can not be started + * if there are no Points or wrong Points. + * + * @return true route is started + * @return false route can not be started + */ bool startNavigation(); + + /** + * @brief Get the Course Correction object + * + * This should be called by the driver to get new instructions. + * + * @return CourseCorrection + */ CourseCorrection getCourseCorrection(); + /** + * @brief Tries to add the current Position to the route + * + * This can be go wrong if there is no valid GPS signal + * + * @return true successful added point + * @return false no point added to route + */ bool addCurrentPosToRoute(); + /** + * @brief Returns the GPS object + * + * @return TinyGPSPlus* + */ TinyGPSPlus* getGPS() { return this->gps; } + + /** + * @brief Get the Route Info object + * + * This object contains information about the route. + * For example the stored points. + * + * @return RouteInfo + */ RouteInfo getRouteInfo() const { return this->route->getRouteInfo(); } private: + /** + * @brief Returns the current Location + * + * @return Point + */ Point currentLocation(); + + /** + * @brief Set the next point as target + * + * @return true + * @return false + */ bool nextPoint(); + + /** + * @brief Set the target point + * + * @param target + * @return true + * @return false + */ bool setTargetPoint(Point target); - static double distanceBetwenn(Point p1, Point p2); + + /** + * @brief Calculate the distance between to points + * + * @param p1 point 1 + * @param p2 point 2 + * @return double distance in meter + */ + static double distanceBetween(Point p1, Point p2); + + /** + * @brief Calculates the course from point1 to point2 + * + * @param p1 point 1 + * @param p2 point 2 + * @return double degree north = 0° west = 270° + */ static double courseTo(Point p1, Point p2); TinyGPSPlus* gps; @@ -57,4 +177,4 @@ class Navigation { bool navigationFinished = false; }; -#endif // NAVIGATION_H \ No newline at end of file +#endif // NAVIGATION_H diff --git a/lib/Navigation/route.cpp b/lib/Navigation/route.cpp index 36c85e6..574c9dd 100644 --- a/lib/Navigation/route.cpp +++ b/lib/Navigation/route.cpp @@ -1,7 +1,7 @@ /** * @file route.cpp * @author Alexander Klein (alex@kleiax.de) - * @brief + * @brief Implements the class Route * @version 0.1 * @date 2022-01-31 * @@ -11,9 +11,6 @@ #include "route.h" -// TODO: Delete iostream -#include - Route::Route() { } diff --git a/lib/Navigation/route.h b/lib/Navigation/route.h index a25bb44..46e9565 100644 --- a/lib/Navigation/route.h +++ b/lib/Navigation/route.h @@ -1,7 +1,7 @@ /** * @file route.h * @author Alexander Klein (alex@kleiax.de) - * @brief + * @brief Contains a class which hold multiple Points * @version 0.1 * @date 2022-01-31 * @@ -16,33 +16,100 @@ #include +/** + * @brief A to handle points on the earth + * + * The points inherits latidue and longitude as doubles + * + */ class Point{ public: + /** + * @brief Construct a new Point object + * + * @param lat latidude + * @param lon longitude + */ Point(double lat, double lon) { this->lat = lat; this->lon = lon; } Point(){ this->lat = 0; this->lon = 0; } double lat = 0; double lon = 0; + /** + * @brief checks if to points are equal + * + * @param rhs + * @return true + * @return false + */ bool operator==(const Point& rhs) const { return this->lat == rhs.lat && this->lon == rhs.lon; } + /** + * @brief Checks if the Point is valid + * + * @return true + * @return false + */ bool isValid() const { return this->lat + this->lon; } }; +/** + * @brief Holds some route information + * + */ struct RouteInfo{ + /** + * @brief Selected number of Points + */ uint16_t currentPoint; + + /** + * @brief Total points stored in route + */ uint16_t totalPoints; }; +/** + * @brief A class to manage multiple points + * + * The list of point presents a route which can be driven + */ class Route { public: + /** + * @brief Construct a new Route object + */ Route(); + + /** + * @brief Adds a point to the list + * + * @param point + */ void addPointToRoute(Point point); + + /** + * @brief Select the first point as target + * + * @return Point + */ Point startRoute(); + + /** + * @brief Get the next point and set it as target + * + * @return Point is zero if there are no more Points + */ Point getNextPoint(); + /** + * @brief Get the Route Info object + * + * @return RouteInfo + */ RouteInfo getRouteInfo(); private: diff --git a/lib/Speedometer/speedometer.h b/lib/Speedometer/speedometer.h index f888b8c..194c16c 100644 --- a/lib/Speedometer/speedometer.h +++ b/lib/Speedometer/speedometer.h @@ -1,7 +1,7 @@ /** * @file speedometer.h * @author Alexander Klein (alex@kleiax.de) - * @brief A complete implementation to measure wheel speeds with an encoder. + * @brief A implementation to measure wheel speeds with an encoder. * @version 0.1 * @date 2021-12-09 * @@ -32,7 +32,7 @@ * @brief A class which use a encoder to calc the speed * * This class use ESP32 pulse counter hardware peripheral. - * The calclutaed speed is the average of an amount of last measurments. + * The calculated speed is the average of an amount of last measurements. * */ class Speedometer { @@ -40,7 +40,7 @@ class Speedometer { Speedometer(); /** - * @brief Initalize the speedometer + * @brief Initialize the speedometer * * @param pinA Pin on the Esp from the encoder. * @param pinB Pin on the Esp from the encoder. @@ -63,7 +63,7 @@ class Speedometer { uint16_t loop(); /** - * @brief Noramly called repeatedly by loop() to calcluate new values. + * @brief Normally called repeatedly by loop() to calculate new values. * * Add a new Value to the average and update the speed. */ @@ -121,4 +121,4 @@ class Speedometer { uint32_t last_millis_calc = 0; }; -#endif // SPEEDOMETER_H \ No newline at end of file +#endif // SPEEDOMETER_H diff --git a/src/SpecialMenus/Akku/menuAkku.cpp b/src/SpecialMenus/Akku/menuAkku.cpp index 04cac88..5f83c91 100644 --- a/src/SpecialMenus/Akku/menuAkku.cpp +++ b/src/SpecialMenus/Akku/menuAkku.cpp @@ -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 * diff --git a/src/SpecialMenus/Akku/menuAkku.h b/src/SpecialMenus/Akku/menuAkku.h index 387bc4d..b271246 100644 --- a/src/SpecialMenus/Akku/menuAkku.h +++ b/src/SpecialMenus/Akku/menuAkku.h @@ -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; diff --git a/src/SpecialMenus/GPS/menuGPS.cpp b/src/SpecialMenus/GPS/menuGPS.cpp index b77db59..66c7ff0 100644 --- a/src/SpecialMenus/GPS/menuGPS.cpp +++ b/src/SpecialMenus/GPS/menuGPS.cpp @@ -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 * diff --git a/src/SpecialMenus/GPS/menuGPS.h b/src/SpecialMenus/GPS/menuGPS.h index dd03b6e..853e3c7 100644 --- a/src/SpecialMenus/GPS/menuGPS.h +++ b/src/SpecialMenus/GPS/menuGPS.h @@ -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 \ No newline at end of file +#endif // MENU_GPS_H diff --git a/src/SpecialMenus/PID/menuPidSettings.cpp b/src/SpecialMenus/PID/menuPidSettings.cpp index 4774c2b..72011d5 100644 --- a/src/SpecialMenus/PID/menuPidSettings.cpp +++ b/src/SpecialMenus/PID/menuPidSettings.cpp @@ -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 * diff --git a/src/SpecialMenus/PID/menuPidSettings.h b/src/SpecialMenus/PID/menuPidSettings.h index 5452db4..00e5793 100644 --- a/src/SpecialMenus/PID/menuPidSettings.h +++ b/src/SpecialMenus/PID/menuPidSettings.h @@ -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 \ No newline at end of file +#endif // PID_SETTINGS_H diff --git a/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp b/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp index 47b6be7..b97af6f 100644 --- a/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp +++ b/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp @@ -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 * diff --git a/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.h b/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.h index 0c04f9e..40a90fd 100644 --- a/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.h +++ b/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.h @@ -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: diff --git a/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp b/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp index a99743e..f6c4e47 100644 --- a/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp +++ b/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp @@ -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 * diff --git a/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.h b/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.h index 42491e0..3aa441c 100644 --- a/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.h +++ b/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.h @@ -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 \ No newline at end of file +#endif // MENU_MANUAL_DRIVE_H diff --git a/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.cpp b/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.cpp index 6ec8654..b393946 100644 --- a/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.cpp +++ b/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.cpp @@ -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 * diff --git a/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.h b/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.h index 0d4bffe..fa7631b 100644 --- a/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.h +++ b/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.h @@ -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 \ No newline at end of file +#endif // MENU_MANUAL_DRIVE_H diff --git a/src/SpecialMenus/driveModi/menuDriveMode.cpp b/src/SpecialMenus/driveModi/menuDriveMode.cpp index 88bc4f9..4fe9cc7 100644 --- a/src/SpecialMenus/driveModi/menuDriveMode.cpp +++ b/src/SpecialMenus/driveModi/menuDriveMode.cpp @@ -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(); -} \ No newline at end of file +} diff --git a/src/SpecialMenus/driveModi/menuDriveMode.h b/src/SpecialMenus/driveModi/menuDriveMode.h index d282dfe..6bc4a64 100644 --- a/src/SpecialMenus/driveModi/menuDriveMode.h +++ b/src/SpecialMenus/driveModi/menuDriveMode.h @@ -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 \ No newline at end of file +#endif // MENU_DRIVE_MODI_H diff --git a/src/driveModi/Modi/Autopilot/autopilot.cpp b/src/driveModi/Modi/Autopilot/autopilot.cpp index d7c20d5..0c7129d 100644 --- a/src/driveModi/Modi/Autopilot/autopilot.cpp +++ b/src/driveModi/Modi/Autopilot/autopilot.cpp @@ -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 * diff --git a/src/driveModi/Modi/Autopilot/autopilot.h b/src/driveModi/Modi/Autopilot/autopilot.h index 28d6464..61cd763 100644 --- a/src/driveModi/Modi/Autopilot/autopilot.h +++ b/src/driveModi/Modi/Autopilot/autopilot.h @@ -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 \ No newline at end of file +#endif // AUTOPILOT_H diff --git a/src/driveModi/Modi/CaptureRoute/captureRoute.cpp b/src/driveModi/Modi/CaptureRoute/captureRoute.cpp index 33ad13c..4fd990f 100644 --- a/src/driveModi/Modi/CaptureRoute/captureRoute.cpp +++ b/src/driveModi/Modi/CaptureRoute/captureRoute.cpp @@ -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; -} \ No newline at end of file +} diff --git a/src/driveModi/Modi/CaptureRoute/captureRoute.h b/src/driveModi/Modi/CaptureRoute/captureRoute.h index 96bc10a..0c37209 100644 --- a/src/driveModi/Modi/CaptureRoute/captureRoute.h +++ b/src/driveModi/Modi/CaptureRoute/captureRoute.h @@ -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 \ No newline at end of file +#endif // CAPTURE_ROUTE_H diff --git a/src/driveModi/Modi/ConsolControl/consolControl.cpp b/src/driveModi/Modi/ConsolControl/consolControl.cpp index 6faad56..6b57026 100644 --- a/src/driveModi/Modi/ConsolControl/consolControl.cpp +++ b/src/driveModi/Modi/ConsolControl/consolControl.cpp @@ -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"); -} \ No newline at end of file diff --git a/src/driveModi/Modi/ConsolControl/consolControl.h b/src/driveModi/Modi/ConsolControl/consolControl.h index 4bd0e12..bf1b91f 100644 --- a/src/driveModi/Modi/ConsolControl/consolControl.h +++ b/src/driveModi/Modi/ConsolControl/consolControl.h @@ -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 - -#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 \ No newline at end of file +#endif // CONSOL_CONTROL_H diff --git a/src/driveModi/Modi/ManualControl/manualControl.h b/src/driveModi/Modi/ManualControl/manualControl.h index 74123d0..95114a3 100644 --- a/src/driveModi/Modi/ManualControl/manualControl.h +++ b/src/driveModi/Modi/ManualControl/manualControl.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 \ No newline at end of file +#endif // MANUAL_CONTROL_H diff --git a/src/driveModi/driveManager.cpp b/src/driveModi/driveManager.cpp index 2ed9bb1..8ac3b96 100644 --- a/src/driveModi/driveManager.cpp +++ b/src/driveModi/driveManager.cpp @@ -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); } diff --git a/src/driveModi/driveManager.h b/src/driveModi/driveManager.h index bd87af7..dfe94f9 100644 --- a/src/driveModi/driveManager.h +++ b/src/driveModi/driveManager.h @@ -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 \ No newline at end of file +#endif // DRIVE_MANAGER_H diff --git a/src/driveModi/driveModi.h b/src/driveModi/driveModi.h index 221bd5e..dc36121 100644 --- a/src/driveModi/driveModi.h +++ b/src/driveModi/driveModi.h @@ -14,11 +14,24 @@ #include +/** + * @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 \ No newline at end of file +#endif // DRIVEMODI_H diff --git a/src/main.cpp b/src/main.cpp index 9d14ff9..627b55f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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 #include #include @@ -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"); diff --git a/src/moveControl.cpp b/src/moveControl.cpp index 2c71362..74c5dcb 100644 --- a/src/moveControl.cpp +++ b/src/moveControl.cpp @@ -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() { diff --git a/src/network.cpp b/src/network.cpp index 4c31c72..c9f938c 100644 --- a/src/network.cpp +++ b/src/network.cpp @@ -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; }