doxygen finished
This commit is contained in:
Vendored
+1
@@ -152,6 +152,7 @@
|
|||||||
"Rtcm",
|
"Rtcm",
|
||||||
"Schalke",
|
"Schalke",
|
||||||
"Soln",
|
"Soln",
|
||||||
|
"Systeminformation",
|
||||||
"TPMOBIL",
|
"TPMOBIL",
|
||||||
"UBLOX",
|
"UBLOX",
|
||||||
"wheelspeed",
|
"wheelspeed",
|
||||||
|
|||||||
@@ -30,12 +30,14 @@ Do later:
|
|||||||
-> ESP und Sensoren in den DeepSleep für Auschalten oder Akkuschutz
|
-> ESP und Sensoren in den DeepSleep für Auschalten oder Akkuschutz
|
||||||
-> Doxygen comments
|
-> Doxygen comments
|
||||||
- navigation
|
- navigation
|
||||||
|
- autopilot
|
||||||
|
|
||||||
|
|
||||||
Do now:
|
Do now:
|
||||||
Code:
|
Code:
|
||||||
Doxygen Kommentare aktualisieren
|
Doxygen Kommentare aktualisieren
|
||||||
Fernbedienung!
|
Fernbedienung!
|
||||||
|
Compass calibration überprüfen
|
||||||
|
|
||||||
Latex:
|
Latex:
|
||||||
Anhang: Liste mit allen Komponenten und Kurzbeschreibung
|
Anhang: Liste mit allen Komponenten und Kurzbeschreibung
|
||||||
|
|||||||
+50
-50
@@ -2,15 +2,15 @@
|
|||||||
* @file outputBuf.h
|
* @file outputBuf.h
|
||||||
* @author Alexander Klein (alex@kleiax.de)
|
* @author Alexander Klein (alex@kleiax.de)
|
||||||
* @brief Contains a small class that provide a streambuf
|
* @brief Contains a small class that provide a streambuf
|
||||||
*
|
*
|
||||||
* The streambuf is used to double the std::cout to consol
|
* The streambuf is used to double the std::cout to consol
|
||||||
* and MQTT.
|
* and MQTT.
|
||||||
*
|
*
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
* @date 2022-02-14
|
* @date 2022-02-14
|
||||||
*
|
*
|
||||||
* @copyright Copyright (c) 2022
|
* @copyright Copyright (c) 2022
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef OUTPUT_STREAM_MQTT_H
|
#ifndef OUTPUT_STREAM_MQTT_H
|
||||||
@@ -26,61 +26,61 @@
|
|||||||
#include <BluetoothSerial.h>
|
#include <BluetoothSerial.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief A alternativ streambuf for std::cout
|
* @brief A alternative streambuf for std::cout
|
||||||
*
|
*
|
||||||
* The streambuf is used to double the std::cout to consol
|
* The streambuf is used to double the std::cout to consol
|
||||||
* and MQTT.
|
* and MQTT.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class OutputBuf : public std::streambuf {
|
class OutputBuf : public std::streambuf
|
||||||
public:
|
{
|
||||||
/**
|
public:
|
||||||
* @brief Construct a new Output Buf Mqtt object
|
/**
|
||||||
*
|
* @brief Construct a new Output Buf Mqtt object
|
||||||
* @param debugMqtt
|
*
|
||||||
* @param serialBT
|
* @param debugMqtt
|
||||||
*/
|
* @param serialBT
|
||||||
OutputBuf(DebugMqtt* debugMqtt = nullptr, BluetoothSerial* serialBT = nullptr);
|
*/
|
||||||
|
OutputBuf(DebugMqtt *debugMqtt = nullptr, BluetoothSerial *serialBT = nullptr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Activate the mqtt output
|
* @brief Activate the mqtt output
|
||||||
*
|
*
|
||||||
* This only works if the DebugMqtt is set by
|
* This only works if the DebugMqtt is set by
|
||||||
* setDebugMqtt.
|
* setDebugMqtt().
|
||||||
*
|
*
|
||||||
* @param status
|
* @param status
|
||||||
*/
|
*/
|
||||||
void activateMqtt(bool status);
|
void activateMqtt(bool status);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Active the output over the bluetooth serial consol
|
* @brief Active the output over the bluetooth serial consol
|
||||||
*
|
*
|
||||||
* This only works if BluetoothSerial is set by
|
* This only works if BluetoothSerial is set by
|
||||||
* setSerialBT.
|
* setSerialBT().
|
||||||
*
|
*
|
||||||
* @param status
|
* @param status
|
||||||
*/
|
*/
|
||||||
void activateSerialBT(bool status);
|
void activateSerialBT(bool status);
|
||||||
|
|
||||||
void setDebugMqtt(DebugMqtt* debugMqtt);
|
void setDebugMqtt(DebugMqtt *debugMqtt);
|
||||||
void setSerialBT(BluetoothSerial* serialBT);
|
void setSerialBT(BluetoothSerial *serialBT);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/**
|
||||||
|
* @brief
|
||||||
|
*
|
||||||
|
* @param c
|
||||||
|
* @return std::streambuf::int_type
|
||||||
|
*/
|
||||||
|
virtual std::streambuf::int_type overflow(std::streambuf::int_type c);
|
||||||
|
|
||||||
protected:
|
private:
|
||||||
/**
|
bool isMqttActive = false;
|
||||||
* @brief
|
bool isSerialBTActive = false;
|
||||||
*
|
|
||||||
* @param c
|
|
||||||
* @return std::streambuf::int_type
|
|
||||||
*/
|
|
||||||
virtual std::streambuf::int_type overflow(std::streambuf::int_type c);
|
|
||||||
|
|
||||||
private:
|
DebugMqtt *debugMqtt;
|
||||||
bool isMqttActive = false;
|
BluetoothSerial *serialBT;
|
||||||
bool isSerialBTActive = false;
|
|
||||||
|
|
||||||
DebugMqtt* debugMqtt;
|
|
||||||
BluetoothSerial* serialBT;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // OUTPUT_STREAM_MQTT_H
|
#endif // OUTPUT_STREAM_MQTT_H
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* @file menuCalibrateBattery.h
|
* @file menuCalibrateBattery.h
|
||||||
* @author Alexander Klein (alex@kleiax.de)
|
* @author Alexander Klein (alex@kleiax.de)
|
||||||
* @brief
|
* @brief Contains a Menu class to calibrate the Battery class
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
* @date 2023-09-26
|
* @date 2023-09-26
|
||||||
*
|
*
|
||||||
@@ -15,13 +15,27 @@
|
|||||||
#include "menuControl.h"
|
#include "menuControl.h"
|
||||||
#include "battery.h"
|
#include "battery.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief A Menu class to calibrate the Battery class
|
||||||
|
*/
|
||||||
class MenuCalibrateBattery : public MenuControl
|
class MenuCalibrateBattery : public MenuControl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Construct a new MenuCalibrateBattery object
|
||||||
|
*
|
||||||
|
* Prepare the calibration.
|
||||||
|
*
|
||||||
|
* @param battery
|
||||||
|
*/
|
||||||
MenuCalibrateBattery(Battery *battery);
|
MenuCalibrateBattery(Battery *battery);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Prints the instructions for the calibration
|
||||||
|
*/
|
||||||
void printMenu() override;
|
void printMenu() override;
|
||||||
|
|
||||||
|
// User Inputs
|
||||||
void left() override;
|
void left() override;
|
||||||
void no() override { this->left(); }
|
void no() override { this->left(); }
|
||||||
void right() override;
|
void right() override;
|
||||||
|
|||||||
@@ -4,9 +4,9 @@
|
|||||||
* @brief Contains a class to tune the PID settings
|
* @brief Contains a class to tune the PID settings
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
* @date 2022-01-19
|
* @date 2022-01-19
|
||||||
*
|
*
|
||||||
* @copyright Copyright (c) 2022
|
* @copyright Copyright (c) 2022
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef PID_SETTINGS_H
|
#ifndef PID_SETTINGS_H
|
||||||
@@ -18,22 +18,22 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief A class to tune the PID settings
|
* @brief A class to tune the PID settings
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class MenuPidSettings : public MenuIntInputWrapper {
|
class MenuPidSettings : public MenuIntInputWrapper
|
||||||
public:
|
{
|
||||||
/**
|
public:
|
||||||
* @brief Construct a new Menu Pid Settings object
|
/**
|
||||||
*
|
* @brief Construct a new Menu Pid Settings object
|
||||||
* @param pid
|
*
|
||||||
*/
|
* @param pid
|
||||||
MenuPidSettings(PID* pid);
|
*/
|
||||||
|
MenuPidSettings(PID *pid);
|
||||||
|
|
||||||
void action(int16_t* values, uint8_t length) override;
|
void action(int16_t *values, uint8_t length) override;
|
||||||
|
|
||||||
private:
|
|
||||||
PID* pid;
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
PID *pid;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PID_SETTINGS_H
|
#endif // PID_SETTINGS_H
|
||||||
|
|||||||
@@ -111,6 +111,13 @@ public:
|
|||||||
*/
|
*/
|
||||||
void exportRoute(uint8_t routeNumber);
|
void exportRoute(uint8_t routeNumber);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Delete a Route
|
||||||
|
*
|
||||||
|
* The functions tries to delete the current route from the RoverApi.
|
||||||
|
*
|
||||||
|
* @param routeNumber
|
||||||
|
*/
|
||||||
void deleteRoute(uint8_t routeNumber);
|
void deleteRoute(uint8_t routeNumber);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -4,9 +4,9 @@
|
|||||||
* @brief Contains a class to print the coordinates of a Route.
|
* @brief Contains a class to print the coordinates of a Route.
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
* @date 2022-12-28
|
* @date 2022-12-28
|
||||||
*
|
*
|
||||||
* @copyright Copyright (c) 2022
|
* @copyright Copyright (c) 2022
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MENU_ROUTE_POINTS_H
|
#ifndef MENU_ROUTE_POINTS_H
|
||||||
@@ -18,33 +18,33 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Prints coordinates of Route side by side.
|
* @brief Prints coordinates of Route side by side.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class MenuRoutePoints : public MenuInformationSites {
|
class MenuRoutePoints : public MenuInformationSites
|
||||||
public:
|
{
|
||||||
/**
|
public:
|
||||||
* @brief Construct a new Menu Route Points object
|
/**
|
||||||
*
|
* @brief Construct a new Menu Route Points object
|
||||||
* @param route
|
*
|
||||||
*/
|
* @param route
|
||||||
MenuRoutePoints(Route *route);
|
*/
|
||||||
|
MenuRoutePoints(Route *route);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Configure the base class MenuInformationSites
|
* @brief Configure the base class MenuInformationSites
|
||||||
*
|
*
|
||||||
* Set the amount of pages.
|
* Set the amount of pages.
|
||||||
*/
|
*/
|
||||||
void init () override;
|
void init() override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Prints the the coordinates of the current Point.
|
* @brief Prints the the coordinates of the current Point.
|
||||||
*/
|
*/
|
||||||
void printPage() const override;
|
void printPage() const override;
|
||||||
|
|
||||||
private:
|
|
||||||
Route* route;
|
|
||||||
bool error = false;
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
Route *route;
|
||||||
|
bool error = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MENU_ROUTE_POINTS_H
|
#endif // MENU_ROUTE_POINTS_H
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
/**
|
/**
|
||||||
* @file menuSensorData.h
|
* @file menuSensorData.h
|
||||||
* @author Alexander Klein (alex@kleiax.de)
|
* @author Alexander Klein (alex@kleiax.de)
|
||||||
* @brief
|
* @brief Contains a MenuInformationClass to print the SensorData
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
* @date 2023-09-04
|
* @date 2023-09-04
|
||||||
*
|
*
|
||||||
* @copyright Copyright (c) 2023
|
* @copyright Copyright (c) 2023
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MENU_SENSOR_DATA_H
|
#ifndef MENU_SENSOR_DATA_H
|
||||||
@@ -15,14 +15,23 @@
|
|||||||
#include "menuInformationSites.h"
|
#include "menuInformationSites.h"
|
||||||
#include "sensorData.h"
|
#include "sensorData.h"
|
||||||
|
|
||||||
class MenuSensorData : public MenuInformationSites {
|
/**
|
||||||
public:
|
* @brief A MenuInformationClass to print the SensorData
|
||||||
MenuSensorData(SensorData* SensorData);
|
*/
|
||||||
|
class MenuSensorData : public MenuInformationSites
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Construct a new MenuSensorData object
|
||||||
|
*
|
||||||
|
* @param SensorData
|
||||||
|
*/
|
||||||
|
MenuSensorData(SensorData *SensorData);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void printPage() const override;
|
void printPage() const override;
|
||||||
|
|
||||||
SensorData* sensorData;
|
SensorData *sensorData;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //MENU_SENSOR_DATA_H
|
#endif // MENU_SENSOR_DATA_H
|
||||||
|
|||||||
@@ -1,18 +1,20 @@
|
|||||||
/**
|
/**
|
||||||
* @file menuSpeed.cpp
|
* @file menuSpeed.cpp
|
||||||
* @author Alexander Klein (alex@kleiax.de)
|
* @author Alexander Klein (alex@kleiax.de)
|
||||||
* @brief
|
* @brief
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
* @date 2023-09-26
|
* @date 2023-09-26
|
||||||
*
|
*
|
||||||
* @copyright Copyright (c) 2023
|
* @copyright Copyright (c) 2023
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "menuSpeed.h"
|
#include "menuSpeed.h"
|
||||||
|
|
||||||
void MenuSpeed::action(int16_t* values, uint8_t length) {
|
void MenuSpeed::action(int16_t *values, uint8_t length)
|
||||||
if (length != 2) {
|
{
|
||||||
|
if (length != 2)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this->speeds.x = values[0] / 10.0;
|
this->speeds.x = values[0] / 10.0;
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
/**
|
/**
|
||||||
* @file menuSpeed.h
|
* @file menuSpeed.h
|
||||||
* @author Alexander Klein (alex@kleiax.de)
|
* @author Alexander Klein (alex@kleiax.de)
|
||||||
* @brief
|
* @brief Contains a MenuIntInputWrapper to change speeds
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
* @date 2023-09-26
|
* @date 2023-09-26
|
||||||
*
|
*
|
||||||
* @copyright Copyright (c) 2023
|
* @copyright Copyright (c) 2023
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MENU_SPEED_H
|
#ifndef MENU_SPEED_H
|
||||||
@@ -15,15 +15,24 @@
|
|||||||
#include <menuIntInput.h>
|
#include <menuIntInput.h>
|
||||||
#include "moveControl.h"
|
#include "moveControl.h"
|
||||||
|
|
||||||
class MenuSpeed : public MenuIntInputWrapper {
|
/**
|
||||||
public:
|
* @brief A MenuIntInputWrapper class to change speeds
|
||||||
MenuSpeed(DrivingSpeeds& speeds) : speeds(speeds){};
|
*/
|
||||||
|
class MenuSpeed : public MenuIntInputWrapper
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MenuSpeed(DrivingSpeeds &speeds) : speeds(speeds){};
|
||||||
|
|
||||||
void action(int16_t* values, uint8_t length) override;
|
/**
|
||||||
|
* @brief Changes the speeds
|
||||||
private:
|
*
|
||||||
DrivingSpeeds& speeds;
|
* @param values
|
||||||
|
* @param length
|
||||||
|
*/
|
||||||
|
void action(int16_t *values, uint8_t length) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
DrivingSpeeds &speeds;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MENU_SPEED_H
|
#endif // MENU_SPEED_H
|
||||||
|
|||||||
@@ -4,71 +4,73 @@
|
|||||||
* @brief Contains an implementation of the class MenuSysteminformation
|
* @brief Contains an implementation of the class MenuSysteminformation
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
* @date 2022-12-27
|
* @date 2022-12-27
|
||||||
*
|
*
|
||||||
* @copyright Copyright (c) 2022
|
* @copyright Copyright (c) 2022
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "menuSysteminformation.h"
|
#include "menuSysteminformation.h"
|
||||||
|
|
||||||
MenuSysteminformation::MenuSysteminformation(Battery* mainBattery)
|
MenuSysteminformation::MenuSysteminformation(Battery *mainBattery)
|
||||||
: MenuInformationSites(8), mainBattery {mainBattery} {
|
: MenuInformationSites(8), mainBattery{mainBattery}
|
||||||
|
{
|
||||||
this->noEqualLeft = true;
|
this->noEqualLeft = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuSysteminformation::printPage() const {
|
void MenuSysteminformation::printPage() const
|
||||||
|
{
|
||||||
String lineOne = "";
|
String lineOne = "";
|
||||||
String lineTwo = "";
|
String lineTwo = "";
|
||||||
switch (this->getCurrentPage()) {
|
switch (this->getCurrentPage())
|
||||||
case 0:
|
{
|
||||||
lineOne = "Free Heap:";
|
case 0:
|
||||||
lineTwo.concat(ESP.getFreeHeap());
|
lineOne = "Free Heap:";
|
||||||
break;
|
lineTwo.concat(ESP.getFreeHeap());
|
||||||
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
lineOne = "Max alloc Heap:";
|
lineOne = "Max alloc Heap:";
|
||||||
lineTwo.concat(ESP.getMaxAllocHeap());
|
lineTwo.concat(ESP.getMaxAllocHeap());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
lineOne = "Uptime in secs:";
|
lineOne = "Uptime in secs:";
|
||||||
lineTwo.concat((millis() / 1000));
|
lineTwo.concat((millis() / 1000));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
lineOne = "Main battery:";
|
lineOne = "Main battery:";
|
||||||
lineTwo = "";
|
lineTwo = "";
|
||||||
lineTwo.concat(this->mainBattery->getBatteryPercent());
|
lineTwo.concat(this->mainBattery->getBatteryPercent());
|
||||||
lineTwo.concat("% - V=");
|
lineTwo.concat("% - V=");
|
||||||
lineTwo.concat(this->mainBattery->getBatteryVoltage());
|
lineTwo.concat(this->mainBattery->getBatteryVoltage());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
lineOne = "Current WiFi";
|
lineOne = "Current WiFi";
|
||||||
lineTwo = "channel: ";
|
lineTwo = "channel: ";
|
||||||
lineTwo.concat(Network::getCurrentChannel());
|
lineTwo.concat(Network::getCurrentChannel());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 5:
|
case 5:
|
||||||
lineOne = "Software verion:";
|
lineOne = "Software verion:";
|
||||||
lineTwo = VERSION;
|
lineTwo = VERSION;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 6:
|
case 6:
|
||||||
lineOne = "Build timestamp:";
|
lineOne = "Build timestamp:";
|
||||||
lineTwo = String(BUILD_TIMESTAMP).substring(0, 16);
|
lineTwo = String(BUILD_TIMESTAMP).substring(0, 16);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 7:
|
case 7:
|
||||||
lineOne = "Kleiax Rover by";
|
lineOne = "Kleiax Rover by";
|
||||||
lineTwo = "Alexander Klein";
|
lineTwo = "Alexander Klein";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
this->printDefault();
|
this->printDefault();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->print(lineOne, lineTwo);
|
this->print(lineOne, lineTwo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,9 +4,9 @@
|
|||||||
* @brief Contains a class to print informations about the system
|
* @brief Contains a class to print informations about the system
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
* @date 2022-12-27
|
* @date 2022-12-27
|
||||||
*
|
*
|
||||||
* @copyright Copyright (c) 2022
|
* @copyright Copyright (c) 2022
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MENU_SYSTEMINFORMATION_H
|
#ifndef MENU_SYSTEMINFORMATION_H
|
||||||
@@ -23,22 +23,23 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Prints information about the current system status.
|
* @brief Prints information about the current system status.
|
||||||
*
|
*
|
||||||
* The informations are about the batteries, memory and uptime.
|
* The informations are about the batteries, memory and uptime.
|
||||||
*/
|
*/
|
||||||
class MenuSysteminformation : public MenuInformationSites {
|
class MenuSysteminformation : public MenuInformationSites
|
||||||
public:
|
{
|
||||||
/**
|
public:
|
||||||
* @brief Construct a new Menu Systeminformation object
|
/**
|
||||||
*
|
* @brief Construct a new Menu Systeminformation object
|
||||||
* @param mainBattery
|
*
|
||||||
*/
|
* @param mainBattery
|
||||||
MenuSysteminformation(Battery* mainBattery);
|
*/
|
||||||
|
MenuSysteminformation(Battery *mainBattery);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void printPage() const override;
|
void printPage() const override;
|
||||||
|
|
||||||
Battery* mainBattery;
|
Battery *mainBattery;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MENU_SYSTEMINFORMATION_H
|
#endif // MENU_SYSTEMINFORMATION_H
|
||||||
|
|||||||
@@ -4,9 +4,9 @@
|
|||||||
* @brief Contains a class to print informations about the Autopilot
|
* @brief Contains a class to print informations about the Autopilot
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
* @date 2022-02-03
|
* @date 2022-02-03
|
||||||
*
|
*
|
||||||
* @copyright Copyright (c) 2022
|
* @copyright Copyright (c) 2022
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MENU_AUTOPILOT_DRIVE_H
|
#ifndef MENU_AUTOPILOT_DRIVE_H
|
||||||
@@ -17,44 +17,44 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief A class to print informations about the Autopilot
|
* @brief A class to print informations about the Autopilot
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class MenuAutopilot : public MenuDriveMode {
|
class MenuAutopilot : public MenuDriveMode
|
||||||
public:
|
{
|
||||||
/**
|
public:
|
||||||
* @brief Construct a new Menu Autopilot object
|
/**
|
||||||
*
|
* @brief Construct a new Menu Autopilot object
|
||||||
* @param driveManager for MenuDriveMode
|
*
|
||||||
*/
|
* @param driveManager for MenuDriveMode
|
||||||
MenuAutopilot(DriveManager* driveManager) : MenuDriveMode(driveManager) {}
|
*/
|
||||||
|
MenuAutopilot(DriveManager *driveManager) : MenuDriveMode(driveManager) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Prints the Information to display and console
|
* @brief Prints the Information to display and console
|
||||||
*
|
*
|
||||||
* The informations are only printed to the display if it
|
* The informations are only printed to the display if it
|
||||||
* set.
|
* set.
|
||||||
*
|
*
|
||||||
* Changes the DriveModi to Autopilot if it is the first time called
|
* Changes the DriveModi to Autopilot if it is the first time called
|
||||||
* and save the Autopilot object.
|
* and save the Autopilot object.
|
||||||
*/
|
*/
|
||||||
void printPage() const override;
|
void printPage() const override;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief can be called to update shown data
|
* @brief can be called to update shown data
|
||||||
*/
|
*/
|
||||||
void update() override;
|
void update() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init() override;
|
void init() override;
|
||||||
void runCommand() override;
|
void runCommand() override;
|
||||||
void runCommandNo() override;
|
void runCommandNo() override;
|
||||||
|
|
||||||
bool mutable targetFreezed = false;
|
bool mutable targetFreezed = false;
|
||||||
double mutable minDistance;
|
double mutable minDistance;
|
||||||
|
|
||||||
Autopilot* autopilot;
|
Autopilot *autopilot;
|
||||||
RouteInfo routeInfo;
|
RouteInfo routeInfo;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MENU_AUTOPILOT_DRIVE_H
|
#endif // MENU_AUTOPILOT_DRIVE_H
|
||||||
|
|||||||
@@ -4,159 +4,167 @@
|
|||||||
* @brief Contains an implementation of the class MenuManualDrive
|
* @brief Contains an implementation of the class MenuManualDrive
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
* @date 2022-01-20
|
* @date 2022-01-20
|
||||||
*
|
*
|
||||||
* @copyright Copyright (c) 2022
|
* @copyright Copyright (c) 2022
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#include "menuCalibrateCompass.h"
|
#include "menuCalibrateCompass.h"
|
||||||
|
|
||||||
MenuCalibrateCompass::MenuCalibrateCompass(DriveManager* driveManager) : MenuDriveMode(driveManager) {}
|
MenuCalibrateCompass::MenuCalibrateCompass(DriveManager *driveManager) : MenuDriveMode(driveManager) {}
|
||||||
|
|
||||||
MenuCalibrateCompass::~MenuCalibrateCompass() {
|
MenuCalibrateCompass::~MenuCalibrateCompass()
|
||||||
|
{
|
||||||
delete this->caliCompass;
|
delete this->caliCompass;
|
||||||
this->caliCompassMode->setCalibrateCompass();
|
this->caliCompassMode->setCalibrateCompass();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuCalibrateCompass::printPage() const {
|
void MenuCalibrateCompass::printPage() const
|
||||||
|
{
|
||||||
String lineOne = "";
|
String lineOne = "";
|
||||||
String lineTwo = "";
|
String lineTwo = "";
|
||||||
|
|
||||||
switch (this->getCurrentPage()) {
|
switch (this->getCurrentPage())
|
||||||
case 0:
|
{
|
||||||
lineOne = "-Ready to drive-";
|
case 0:
|
||||||
lineTwo = "Compass Mode";
|
lineOne = "-Ready to drive-";
|
||||||
|
lineTwo = "Compass Mode";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
lineOne = "Azimuth:";
|
||||||
|
lineTwo.concat(this->caliCompassMode->getSensorData()->getRealAzimuth());
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
switch (this->caliCompass->getState())
|
||||||
|
{
|
||||||
|
case CalibrateCompass::State::Ready:
|
||||||
|
lineOne = "Start compass";
|
||||||
|
lineTwo = "calibration";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case CalibrateCompass::State::Calibrating:
|
||||||
lineOne = "Azimuth:";
|
lineOne = "Calibrating...";
|
||||||
lineTwo.concat(this->caliCompassMode->getSensorData()->getRealAzimuth());
|
lineTwo = "Move around";
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
switch (this->caliCompass->getState()) {
|
|
||||||
case CalibrateCompass::State::Ready :
|
|
||||||
lineOne = "Start compass";
|
|
||||||
lineTwo = "calibration";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CalibrateCompass::State::Calibrating :
|
|
||||||
lineOne = "Calibrating...";
|
|
||||||
lineTwo = "Move around";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CalibrateCompass::State::Finished:
|
|
||||||
lineOne = "Calibration";
|
|
||||||
lineTwo = "finished";
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case CalibrateCompass::State::Finished:
|
||||||
lineOne = "Save compass";
|
lineOne = "Calibration";
|
||||||
lineTwo = "data in flash";
|
lineTwo = "finished";
|
||||||
break;
|
|
||||||
|
|
||||||
case 4:
|
|
||||||
lineOne = "Load data";
|
|
||||||
lineTwo = "from flash";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 5:
|
|
||||||
lineOne = "Remove";
|
|
||||||
lineTwo = "calibration data";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 6:
|
|
||||||
lineOne = "Use current";
|
|
||||||
lineTwo = "calibration data";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 7:
|
|
||||||
lineOne = "Reset for new";
|
|
||||||
lineTwo = "calibration run";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 8:
|
|
||||||
lineOne = "X min: ";
|
|
||||||
lineOne.concat(this->caliCompass->getCalibrationData().data[0][0]);
|
|
||||||
lineTwo = "X max: ";
|
|
||||||
lineTwo.concat(this->caliCompass->getCalibrationData().data[0][1]);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 9:
|
|
||||||
lineOne = "Y min: ";
|
|
||||||
lineOne.concat(this->caliCompass->getCalibrationData().data[1][0]);
|
|
||||||
lineTwo = "Y max: ";
|
|
||||||
lineTwo.concat(this->caliCompass->getCalibrationData().data[1][1]);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 10:
|
|
||||||
lineOne = "Z min: ";
|
|
||||||
lineOne.concat(this->caliCompass->getCalibrationData().data[2][0]);
|
|
||||||
lineTwo = "Z max: ";
|
|
||||||
lineTwo.concat(this->caliCompass->getCalibrationData().data[2][1]);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
this->printDefault();
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
lineOne = "Save compass";
|
||||||
|
lineTwo = "data in flash";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 4:
|
||||||
|
lineOne = "Load data";
|
||||||
|
lineTwo = "from flash";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 5:
|
||||||
|
lineOne = "Remove";
|
||||||
|
lineTwo = "calibration data";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 6:
|
||||||
|
lineOne = "Use current";
|
||||||
|
lineTwo = "calibration data";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 7:
|
||||||
|
lineOne = "Reset for new";
|
||||||
|
lineTwo = "calibration run";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 8:
|
||||||
|
lineOne = "X min: ";
|
||||||
|
lineOne.concat(this->caliCompass->getCalibrationData().data[0][0]);
|
||||||
|
lineTwo = "X max: ";
|
||||||
|
lineTwo.concat(this->caliCompass->getCalibrationData().data[0][1]);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 9:
|
||||||
|
lineOne = "Y min: ";
|
||||||
|
lineOne.concat(this->caliCompass->getCalibrationData().data[1][0]);
|
||||||
|
lineTwo = "Y max: ";
|
||||||
|
lineTwo.concat(this->caliCompass->getCalibrationData().data[1][1]);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 10:
|
||||||
|
lineOne = "Z min: ";
|
||||||
|
lineOne.concat(this->caliCompass->getCalibrationData().data[2][0]);
|
||||||
|
lineTwo = "Z max: ";
|
||||||
|
lineTwo.concat(this->caliCompass->getCalibrationData().data[2][1]);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
this->printDefault();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->print(lineOne, lineTwo);
|
this->print(lineOne, lineTwo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuCalibrateCompass::init() {
|
void MenuCalibrateCompass::init()
|
||||||
|
{
|
||||||
this->firstPrint = false;
|
this->firstPrint = false;
|
||||||
this->caliCompassMode = new CalibrateCompassM();
|
this->caliCompassMode = new CalibrateCompassM();
|
||||||
this->driveManager->changeModus(this->caliCompassMode);
|
this->driveManager->changeModus(this->caliCompassMode);
|
||||||
this->caliCompass = new CalibrateCompass(this->caliCompassMode->getSensorData()->getRealCompass());
|
this->caliCompass = new CalibrateCompass(this->caliCompassMode->getSensorData()->getRealCompass());
|
||||||
this->setCountPages(11);
|
this->setCountPages(11);
|
||||||
MenuDriveMode::updateDelay = MenuCalibrateCompass::updateDelay;
|
MenuDriveMode::updateDelay = MenuCalibrateCompass::updateDelay;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuCalibrateCompass::runCommand() {
|
void MenuCalibrateCompass::runCommand()
|
||||||
switch (this->getCurrentPage()) {
|
{
|
||||||
case 2:
|
switch (this->getCurrentPage())
|
||||||
switch (this->caliCompass->getState()) {
|
{
|
||||||
case CalibrateCompass::State::Ready :
|
case 2:
|
||||||
this->caliCompassMode->setCalibrateCompass(this->caliCompass);
|
switch (this->caliCompass->getState())
|
||||||
this->caliCompass->start();
|
{
|
||||||
break;
|
case CalibrateCompass::State::Ready:
|
||||||
|
this->caliCompassMode->setCalibrateCompass(this->caliCompass);
|
||||||
case CalibrateCompass::State::Finished:
|
this->caliCompass->start();
|
||||||
this->caliCompassMode->setCalibrateCompass();
|
|
||||||
this->caliCompass->useData();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case CalibrateCompass::State::Finished:
|
||||||
this->caliCompass->saveData();
|
this->caliCompassMode->setCalibrateCompass();
|
||||||
break;
|
|
||||||
|
|
||||||
case 4:
|
|
||||||
this->caliCompass->loadData();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 5:
|
|
||||||
this->caliCompass->removeCalibration();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 6:
|
|
||||||
this->caliCompass->useData();
|
this->caliCompass->useData();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 7:
|
|
||||||
this->caliCompass->reset();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
this->caliCompass->saveData();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 4:
|
||||||
|
this->caliCompass->loadData();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 5:
|
||||||
|
this->caliCompass->removeCalibration();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 6:
|
||||||
|
this->caliCompass->useData();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 7:
|
||||||
|
this->caliCompass->reset();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,9 @@
|
|||||||
* @brief Contains a class to print information about the class ManualControl
|
* @brief Contains a class to print information about the class ManualControl
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
* @date 2022-01-20
|
* @date 2022-01-20
|
||||||
*
|
*
|
||||||
* @copyright Copyright (c) 2022
|
* @copyright Copyright (c) 2022
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MENU_CALIBRATE_COMPASS_H
|
#ifndef MENU_CALIBRATE_COMPASS_H
|
||||||
@@ -18,37 +18,37 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief A class to print informations about the class ManualControl
|
* @brief A class to print informations about the class ManualControl
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class MenuCalibrateCompass : public MenuDriveMode {
|
class MenuCalibrateCompass : public MenuDriveMode
|
||||||
public:
|
{
|
||||||
/**
|
public:
|
||||||
* @brief Construct a new Menu Manual Control object
|
/**
|
||||||
*
|
* @brief Construct a new Menu Manual Control object
|
||||||
* @param driveManager
|
*
|
||||||
*/
|
* @param driveManager
|
||||||
MenuCalibrateCompass(DriveManager* driveManager);
|
*/
|
||||||
~MenuCalibrateCompass();
|
MenuCalibrateCompass(DriveManager *driveManager);
|
||||||
|
~MenuCalibrateCompass();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Prints the Information to display and console
|
* @brief Prints the Information to display and console
|
||||||
*
|
*
|
||||||
* The informations are only printed to the display if it
|
* The informations are only printed to the display if it
|
||||||
* set.
|
* set.
|
||||||
*
|
*
|
||||||
* Changes the DriveModi to Autopilot if it is the first time called.
|
* Changes the DriveModi to Autopilot if it is the first time called.
|
||||||
*/
|
*/
|
||||||
void printPage() const override;
|
void printPage() const override;
|
||||||
|
|
||||||
protected:
|
private:
|
||||||
void init() override;
|
void init() override;
|
||||||
void runCommand() override;
|
void runCommand() override;
|
||||||
|
|
||||||
private:
|
CalibrateCompassM *caliCompassMode = nullptr;
|
||||||
CalibrateCompassM* caliCompassMode = nullptr;
|
CalibrateCompass *caliCompass = nullptr;
|
||||||
CalibrateCompass* caliCompass = nullptr;
|
|
||||||
|
|
||||||
static constexpr uint16_t updateDelay = 500;
|
static constexpr uint16_t updateDelay = 500;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MENU_CALIBRATE_COMPASS_H
|
#endif // MENU_CALIBRATE_COMPASS_H
|
||||||
|
|||||||
@@ -4,9 +4,9 @@
|
|||||||
* @brief Contains a class to print informations about CaptureRoute
|
* @brief Contains a class to print informations about CaptureRoute
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
* @date 2022-01-31
|
* @date 2022-01-31
|
||||||
*
|
*
|
||||||
* @copyright Copyright (c) 2022
|
* @copyright Copyright (c) 2022
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#ifndef MENU_CAPTURE_ROUTE_H
|
#ifndef MENU_CAPTURE_ROUTE_H
|
||||||
#define MENU_MANUAL_DRIVE_H
|
#define MENU_MANUAL_DRIVE_H
|
||||||
@@ -16,41 +16,41 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief A class to print informations about the Autopilot
|
* @brief A class to print informations about the Autopilot
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class MenuCaptureRoute : public MenuDriveMode {
|
class MenuCaptureRoute : public MenuDriveMode
|
||||||
public:
|
{
|
||||||
/**
|
public:
|
||||||
* @brief Construct a new Menu Capture Route object
|
/**
|
||||||
*
|
* @brief Construct a new Menu Capture Route object
|
||||||
* @param driveManager
|
*
|
||||||
*/
|
* @param driveManager
|
||||||
MenuCaptureRoute(DriveManager* driveManager) : MenuDriveMode(driveManager) {}
|
*/
|
||||||
|
MenuCaptureRoute(DriveManager *driveManager) : MenuDriveMode(driveManager) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Prints the Information to display and console
|
* @brief Prints the Information to display and console
|
||||||
*
|
*
|
||||||
* The informations are only printed to the display if it
|
* The informations are only printed to the display if it
|
||||||
* set.
|
* set.
|
||||||
*
|
*
|
||||||
* Changes the DriveModi to CaptureRoute if it is the first time called
|
* Changes the DriveModi to CaptureRoute if it is the first time called
|
||||||
* and save the CaptureRoute object.
|
* and save the CaptureRoute object.
|
||||||
*/
|
*/
|
||||||
void printPage() const override;
|
void printPage() const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief can be called to update shown data
|
* @brief can be called to update shown data
|
||||||
*/
|
*/
|
||||||
void update() override;
|
void update() override;
|
||||||
|
|
||||||
void runCommand() override;
|
private:
|
||||||
|
void runCommand() override;
|
||||||
|
void init() override;
|
||||||
|
|
||||||
private:
|
CaptureRoute *captureRoute = nullptr;
|
||||||
void init() override;
|
|
||||||
|
|
||||||
CaptureRoute* captureRoute = nullptr;
|
static constexpr uint16_t updateDelay = 500;
|
||||||
|
|
||||||
static constexpr uint16_t updateDelay = 500;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MENU_MANUAL_DRIVE_H
|
#endif // MENU_MANUAL_DRIVE_H
|
||||||
|
|||||||
@@ -4,77 +4,84 @@
|
|||||||
* @brief Contains an implementation of the class MenuManualDrive
|
* @brief Contains an implementation of the class MenuManualDrive
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
* @date 2022-01-20
|
* @date 2022-01-20
|
||||||
*
|
*
|
||||||
* @copyright Copyright (c) 2022
|
* @copyright Copyright (c) 2022
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#include "menuManualDrive.h"
|
#include "menuManualDrive.h"
|
||||||
|
|
||||||
MenuManualControl::MenuManualControl(DriveManager* driveManager) : MenuDriveMode(driveManager) {
|
MenuManualControl::MenuManualControl(DriveManager *driveManager) : MenuDriveMode(driveManager)
|
||||||
|
{
|
||||||
this->noEqualLeft = true;
|
this->noEqualLeft = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MenuManualControl::printPage() const
|
||||||
void MenuManualControl::printPage() const {
|
{
|
||||||
String lineOne = "";
|
String lineOne = "";
|
||||||
String lineTwo = "";
|
String lineTwo = "";
|
||||||
|
|
||||||
switch (this->getCurrentPage()) {
|
switch (this->getCurrentPage())
|
||||||
case 0:
|
{
|
||||||
lineOne = "-Ready to drive-";
|
case 0:
|
||||||
break;
|
lineOne = "-Ready to drive-";
|
||||||
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
lineOne = "Input mode:";
|
lineOne = "Input mode:";
|
||||||
if (this->manualControl->getInputMode() == ManualControl::InputMode::Analog) {
|
if (this->manualControl->getInputMode() == ManualControl::InputMode::Analog)
|
||||||
lineTwo = "Analog";
|
{
|
||||||
}
|
lineTwo = "Analog";
|
||||||
else {
|
}
|
||||||
lineTwo = "Digital";
|
else
|
||||||
}
|
{
|
||||||
break;
|
lineTwo = "Digital";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
lineOne = "Speed Menu";
|
lineOne = "Speed Menu";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
lineOne = "Sensor Menu";
|
lineOne = "Sensor Menu";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
this->printDefault();
|
this->printDefault();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->print(lineOne, lineTwo);
|
this->print(lineOne, lineTwo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuManualControl::init() {
|
void MenuManualControl::init()
|
||||||
|
{
|
||||||
this->firstPrint = false;
|
this->firstPrint = false;
|
||||||
this->manualControl = new ManualControl();
|
this->manualControl = new ManualControl();
|
||||||
this->driveManager->changeModus(this->manualControl);
|
this->driveManager->changeModus(this->manualControl);
|
||||||
this->setCountPages(4);
|
this->setCountPages(4);
|
||||||
MenuDriveMode::updateDelay = MenuManualControl::updateDelay;
|
MenuDriveMode::updateDelay = MenuManualControl::updateDelay;
|
||||||
this->activateSpeedMenu();
|
this->activateSpeedMenu();
|
||||||
MenuDriveMode::init();
|
MenuDriveMode::init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuManualControl::runCommand() {
|
void MenuManualControl::runCommand()
|
||||||
switch (this->getCurrentPage()) {
|
{
|
||||||
case 1:
|
switch (this->getCurrentPage())
|
||||||
this->manualControl->switchInputMode();
|
{
|
||||||
break;
|
case 1:
|
||||||
|
this->manualControl->switchInputMode();
|
||||||
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
this->enterSpeedMenu();
|
this->enterSpeedMenu();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
this->enterSensorMenu();
|
this->enterSensorMenu();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,9 @@
|
|||||||
* @brief Contains a class to print information about the class ManualControl
|
* @brief Contains a class to print information about the class ManualControl
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
* @date 2022-01-20
|
* @date 2022-01-20
|
||||||
*
|
*
|
||||||
* @copyright Copyright (c) 2022
|
* @copyright Copyright (c) 2022
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MENU_MANUAL_DRIVE_H
|
#ifndef MENU_MANUAL_DRIVE_H
|
||||||
@@ -17,36 +17,36 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief A class to print informations about the class ManualControl
|
* @brief A class to print informations about the class ManualControl
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class MenuManualControl : public MenuDriveMode {
|
class MenuManualControl : public MenuDriveMode
|
||||||
public:
|
{
|
||||||
/**
|
public:
|
||||||
* @brief Construct a new Menu Manual Control object
|
/**
|
||||||
*
|
* @brief Construct a new Menu Manual Control object
|
||||||
* @param driveManager
|
*
|
||||||
*/
|
* @param driveManager
|
||||||
MenuManualControl(DriveManager* driveManager);
|
*/
|
||||||
|
MenuManualControl(DriveManager *driveManager);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Prints the Information to display and console
|
* @brief Prints the Information to display and console
|
||||||
*
|
*
|
||||||
* The informations are only printed to the display if it
|
* The informations are only printed to the display if it
|
||||||
* set.
|
* set.
|
||||||
*
|
*
|
||||||
* Changes the DriveModi to Autopilot if it is the first time called.
|
* Changes the DriveModi to Autopilot if it is the first time called.
|
||||||
*/
|
*/
|
||||||
void printPage() const override;
|
void printPage() const override;
|
||||||
|
|
||||||
protected:
|
private:
|
||||||
void init() override;
|
void init() override;
|
||||||
void runCommand() override;
|
void runCommand() override;
|
||||||
|
|
||||||
private:
|
ManualControl *manualControl = nullptr;
|
||||||
ManualControl* manualControl = nullptr;
|
CalibrateCompass *caliCompass = nullptr;
|
||||||
CalibrateCompass* caliCompass = nullptr;
|
|
||||||
|
|
||||||
static constexpr uint16_t updateDelay = 500;
|
static constexpr uint16_t updateDelay = 500;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MENU_MANUAL_DRIVE_H
|
#endif // MENU_MANUAL_DRIVE_H
|
||||||
|
|||||||
@@ -4,25 +4,29 @@
|
|||||||
* @brief Contains the implementation of the class MenuTestMode.
|
* @brief Contains the implementation of the class MenuTestMode.
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
* @date 2022-09-08
|
* @date 2022-09-08
|
||||||
*
|
*
|
||||||
* @copyright Copyright (c) 2022
|
* @copyright Copyright (c) 2022
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#include "menuTestMode.h"
|
#include "menuTestMode.h"
|
||||||
|
|
||||||
MenuTestMode::MenuTestMode(DriveManager* driveManager)
|
MenuTestMode::MenuTestMode(DriveManager *driveManager)
|
||||||
: driveManager {driveManager}
|
: driveManager{driveManager}
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuTestMode::~MenuTestMode() {
|
MenuTestMode::~MenuTestMode()
|
||||||
if (isInit) {
|
{
|
||||||
|
if (isInit)
|
||||||
|
{
|
||||||
delete this->mainMenu;
|
delete this->mainMenu;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuTestMode::printMenu() {
|
void MenuTestMode::printMenu()
|
||||||
if (!this->isInit) {
|
{
|
||||||
|
if (!this->isInit)
|
||||||
|
{
|
||||||
this->isInit = true;
|
this->isInit = true;
|
||||||
this->init();
|
this->init();
|
||||||
}
|
}
|
||||||
@@ -30,62 +34,82 @@ void MenuTestMode::printMenu() {
|
|||||||
this->mainMenu->printMenu();
|
this->mainMenu->printMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuTestMode::down() {
|
void MenuTestMode::down()
|
||||||
if (this->checkInput()) {
|
{
|
||||||
|
if (this->checkInput())
|
||||||
|
{
|
||||||
this->mainMenu->down();
|
this->mainMenu->down();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuTestMode::up() {
|
void MenuTestMode::up()
|
||||||
if (this->checkInput()) {
|
{
|
||||||
|
if (this->checkInput())
|
||||||
|
{
|
||||||
this->mainMenu->up();
|
this->mainMenu->up();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuTestMode::right() {
|
void MenuTestMode::right()
|
||||||
if (this->checkInput()) {
|
{
|
||||||
|
if (this->checkInput())
|
||||||
|
{
|
||||||
this->mainMenu->right();
|
this->mainMenu->right();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuTestMode::left() {
|
void MenuTestMode::left()
|
||||||
|
{
|
||||||
if (this->mainMenu->isInSubmenu())
|
if (this->mainMenu->isInSubmenu())
|
||||||
if (this->checkInput()) {
|
if (this->checkInput())
|
||||||
|
{
|
||||||
this->mainMenu->left();
|
this->mainMenu->left();
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
this->testMode->abortManeuver();
|
this->testMode->abortManeuver();
|
||||||
this->mainMenu->left();
|
this->mainMenu->left();
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
this->parentMenu->printMenu();
|
this->parentMenu->printMenu();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuTestMode::yes() {
|
void MenuTestMode::yes()
|
||||||
if (this->checkInput()) {
|
{
|
||||||
|
if (this->checkInput())
|
||||||
|
{
|
||||||
this->mainMenu->yes();
|
this->mainMenu->yes();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuTestMode::no() {
|
void MenuTestMode::no()
|
||||||
if (this->mainMenu->isInSubmenu()) {
|
{
|
||||||
|
if (this->mainMenu->isInSubmenu())
|
||||||
|
{
|
||||||
if (this->checkInput())
|
if (this->checkInput())
|
||||||
this->mainMenu->no();
|
this->mainMenu->no();
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
this->testMode->abortManeuver();
|
this->testMode->abortManeuver();
|
||||||
this->mainMenu->no();
|
this->mainMenu->no();
|
||||||
}}
|
}
|
||||||
else{
|
}
|
||||||
this->left();}
|
else
|
||||||
|
{
|
||||||
|
this->left();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuTestMode::init() {
|
void MenuTestMode::init()
|
||||||
|
{
|
||||||
this->testMode = new TestMode();
|
this->testMode = new TestMode();
|
||||||
this->driveManager->changeModus(this->testMode);
|
this->driveManager->changeModus(this->testMode);
|
||||||
|
|
||||||
auto dummy = []() {
|
auto dummy = []()
|
||||||
std::cout << "Dummy in Action" <<std::endl;
|
{
|
||||||
|
std::cout << "Dummy in Action" << std::endl;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Create menu
|
// Create menu
|
||||||
@@ -103,7 +127,6 @@ void MenuTestMode::init() {
|
|||||||
auto *encoderLeftMenu = new SpeedometerTest(this->testMode->getSpeedometerLeft());
|
auto *encoderLeftMenu = new SpeedometerTest(this->testMode->getSpeedometerLeft());
|
||||||
auto *encoderRightMenu = new SpeedometerTest(this->testMode->getSpeedometerRight());
|
auto *encoderRightMenu = new SpeedometerTest(this->testMode->getSpeedometerRight());
|
||||||
|
|
||||||
|
|
||||||
// Set menus on LCD
|
// Set menus on LCD
|
||||||
this->mainMenu->setLcd(this->lcd);
|
this->mainMenu->setLcd(this->lcd);
|
||||||
engineMenu->setLcd(this->lcd);
|
engineMenu->setLcd(this->lcd);
|
||||||
@@ -143,7 +166,6 @@ void MenuTestMode::init() {
|
|||||||
engineBothMenu->setMinMaxSteps(1, 0, secondsMax, 1);
|
engineBothMenu->setMinMaxSteps(1, 0, secondsMax, 1);
|
||||||
engineBothMenu->setPrintParentMenu(false);
|
engineBothMenu->setPrintParentMenu(false);
|
||||||
|
|
||||||
|
|
||||||
// Entrys for the menus
|
// Entrys for the menus
|
||||||
auto *engineAction = new MenuAction("Engine", engineMenu);
|
auto *engineAction = new MenuAction("Engine", engineMenu);
|
||||||
auto *engineLeftAction = new MenuAction("Left", engineLeftMenu);
|
auto *engineLeftAction = new MenuAction("Left", engineLeftMenu);
|
||||||
@@ -162,7 +184,7 @@ void MenuTestMode::init() {
|
|||||||
auto *lightRedAction = new MenuAction("Red", dummy);
|
auto *lightRedAction = new MenuAction("Red", dummy);
|
||||||
auto *lightGreenAction = new MenuAction("Green", dummy);
|
auto *lightGreenAction = new MenuAction("Green", dummy);
|
||||||
auto *lightBlueAction = new MenuAction("Blue", dummy);
|
auto *lightBlueAction = new MenuAction("Blue", dummy);
|
||||||
auto *lightOffAction = new MenuAction("Off", dummy);
|
auto *lightOffAction = new MenuAction("Off", dummy);
|
||||||
|
|
||||||
// Add entries to the menus
|
// Add entries to the menus
|
||||||
this->mainMenu->addEntry(engineAction);
|
this->mainMenu->addEntry(engineAction);
|
||||||
@@ -182,74 +204,89 @@ void MenuTestMode::init() {
|
|||||||
lightMenu->addEntry(lightRedAction);
|
lightMenu->addEntry(lightRedAction);
|
||||||
lightMenu->addEntry(lightGreenAction);
|
lightMenu->addEntry(lightGreenAction);
|
||||||
lightMenu->addEntry(lightBlueAction);
|
lightMenu->addEntry(lightBlueAction);
|
||||||
lightMenu->addEntry(lightOffAction);
|
lightMenu->addEntry(lightOffAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuTestMode::update() {
|
void MenuTestMode::update()
|
||||||
if (this->maneuverInAction) {
|
{
|
||||||
if (millis() - this->lastUpdateTime > updateDelay) {
|
if (this->maneuverInAction)
|
||||||
|
{
|
||||||
|
if (millis() - this->lastUpdateTime > updateDelay)
|
||||||
|
{
|
||||||
this->printManeuverTime();
|
this->printManeuverTime();
|
||||||
this->lastUpdateTime = millis();
|
this->lastUpdateTime = millis();
|
||||||
}}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MenuTestMode::checkInput() {
|
bool MenuTestMode::checkInput()
|
||||||
if (this->testMode->getBusy()) {
|
{
|
||||||
|
if (this->testMode->getBusy())
|
||||||
|
{
|
||||||
this->printManeuverTime();
|
this->printManeuverTime();
|
||||||
this->maneuverInAction = true;
|
this->maneuverInAction = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->maneuverInAction) {
|
if (this->maneuverInAction)
|
||||||
|
{
|
||||||
this->maneuverInAction = false;
|
this->maneuverInAction = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuTestMode::printManeuverTime() {
|
void MenuTestMode::printManeuverTime()
|
||||||
|
{
|
||||||
uint8_t maneuverTime = this->testMode->getRemainingManeuverTime();
|
uint8_t maneuverTime = this->testMode->getRemainingManeuverTime();
|
||||||
if (maneuverTime) {
|
if (maneuverTime)
|
||||||
|
{
|
||||||
String lineTwo = "";
|
String lineTwo = "";
|
||||||
lineTwo.concat(maneuverTime);
|
lineTwo.concat(maneuverTime);
|
||||||
lineTwo.concat(" secs");
|
lineTwo.concat(" secs");
|
||||||
this->print("Maneuver time:", lineTwo);
|
this->print("Maneuver time:", lineTwo);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
this->maneuverInAction = false;
|
this->maneuverInAction = false;
|
||||||
this->printMenu();
|
this->printMenu();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuTestModeWrapper::MenuTestModeWrapper(MenuTestMode* menu, TestModeFunctionSingle testModeFunction)
|
MenuTestModeWrapper::MenuTestModeWrapper(MenuTestMode *menu, TestModeFunctionSingle testModeFunction)
|
||||||
: menu {menu},
|
: menu{menu},
|
||||||
testModeFunctionSingle {testModeFunction},
|
testModeFunctionSingle{testModeFunction},
|
||||||
testMode {menu->getTestMode()}
|
testMode{menu->getTestMode()}
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuTestModeWrapper::MenuTestModeWrapper(MenuTestMode* menu, TestModeFunctionDouble testModeFunction)
|
MenuTestModeWrapper::MenuTestModeWrapper(MenuTestMode *menu, TestModeFunctionDouble testModeFunction)
|
||||||
: menu {menu},
|
: menu{menu},
|
||||||
testModeFunctionDouble {testModeFunction},
|
testModeFunctionDouble{testModeFunction},
|
||||||
testMode {menu->getTestMode()}
|
testMode{menu->getTestMode()}
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuTestModeWrapper::action(int16_t* values, uint8_t length) {
|
void MenuTestModeWrapper::action(int16_t *values, uint8_t length)
|
||||||
|
{
|
||||||
// This function calls a member function with a pointer
|
// This function calls a member function with a pointer
|
||||||
// Very helpful site:
|
// Very helpful site:
|
||||||
// https://isocpp.org/wiki/faq/pointers-to-members#fnptr-vs-memfnptr-types
|
// https://isocpp.org/wiki/faq/pointers-to-members#fnptr-vs-memfnptr-types
|
||||||
|
|
||||||
bool res = false;
|
bool res = false;
|
||||||
|
|
||||||
if (length == 2 && static_cast<bool>(this->testModeFunctionDouble)) {
|
if (length == 2 && static_cast<bool>(this->testModeFunctionDouble))
|
||||||
|
{
|
||||||
res = (this->testMode->*this->testModeFunctionDouble)(values[0], values[1]);
|
res = (this->testMode->*this->testModeFunctionDouble)(values[0], values[1]);
|
||||||
}
|
}
|
||||||
else if (length == 1 && static_cast<bool>(this->testModeFunctionSingle)) {
|
else if (length == 1 && static_cast<bool>(this->testModeFunctionSingle))
|
||||||
|
{
|
||||||
res = (this->testMode->*this->testModeFunctionSingle)(values[0]);
|
res = (this->testMode->*this->testModeFunctionSingle)(values[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res) {
|
if (res)
|
||||||
|
{
|
||||||
this->menu->printManeuverTime();
|
this->menu->printManeuverTime();
|
||||||
this->menu->maneuverStarted();
|
this->menu->maneuverStarted();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,9 @@
|
|||||||
* @brief Contains a class to use and print information about the TestMode.
|
* @brief Contains a class to use and print information about the TestMode.
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
* @date 2022-09-08
|
* @date 2022-09-08
|
||||||
*
|
*
|
||||||
* @copyright Copyright (c) 2022
|
* @copyright Copyright (c) 2022
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#ifndef MENU_TEST_MODE_H
|
#ifndef MENU_TEST_MODE_H
|
||||||
#define MENU_TEST_MODE_H
|
#define MENU_TEST_MODE_H
|
||||||
@@ -20,80 +20,82 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Interact with the TestMode
|
* @brief Interact with the TestMode
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class MenuTestMode : public MenuControl {
|
class MenuTestMode : public MenuControl
|
||||||
public:
|
{
|
||||||
/**
|
public:
|
||||||
* @brief Construct a new Menu Test Mode object
|
/**
|
||||||
*
|
* @brief Construct a new Menu Test Mode object
|
||||||
* @param driveManager
|
*
|
||||||
*/
|
* @param driveManager
|
||||||
MenuTestMode(DriveManager *driveManager);
|
*/
|
||||||
~MenuTestMode();
|
MenuTestMode(DriveManager *driveManager);
|
||||||
|
~MenuTestMode();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Prints the last informations
|
* @brief Prints the last informations
|
||||||
*
|
*
|
||||||
* On first call this function calls the init function.
|
* On first call this function calls the init function.
|
||||||
* On every call this functions call the printMenu function from
|
* On every call this functions call the printMenu function from
|
||||||
* the mainMenu of this class.
|
* the mainMenu of this class.
|
||||||
*/
|
*/
|
||||||
void printMenu() override;
|
void printMenu() override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Prints maneuver Timer
|
* @brief Prints maneuver Timer
|
||||||
*
|
*
|
||||||
* Aside from that the function looks if the maneuver is done and
|
* Aside from that the function looks if the maneuver is done and
|
||||||
* give the user input free.
|
* give the user input free.
|
||||||
*/
|
*/
|
||||||
void printManeuverTime();
|
void printManeuverTime();
|
||||||
|
|
||||||
void down() override;
|
void down() override;
|
||||||
void up() override;
|
void up() override;
|
||||||
void right() override;
|
void right() override;
|
||||||
void left() override;
|
void left() override;
|
||||||
void yes() override;
|
void yes() override;
|
||||||
void no() override;
|
void no() override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Calls the printManeuverTime function if a maneuver is in process.
|
* @brief Calls the printManeuverTime function if a maneuver is in process.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void update() override;
|
void update() override;
|
||||||
|
|
||||||
TestMode* getTestMode() const { return this->testMode; }
|
TestMode *getTestMode() const { return this->testMode; }
|
||||||
void maneuverStarted() { this->maneuverInAction = true; }
|
void maneuverStarted() { this->maneuverInAction = true; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init();
|
void init();
|
||||||
bool checkInput();
|
bool checkInput();
|
||||||
|
|
||||||
DriveManager* driveManager;
|
DriveManager *driveManager;
|
||||||
TestMode* testMode = nullptr;
|
TestMode *testMode = nullptr;
|
||||||
Menu* mainMenu = nullptr;
|
Menu *mainMenu = nullptr;
|
||||||
|
|
||||||
bool isInit = false;
|
bool isInit = false;
|
||||||
bool maneuverInAction = false;
|
bool maneuverInAction = false;
|
||||||
|
|
||||||
uint32_t lastUpdateTime = 0;
|
uint32_t lastUpdateTime = 0;
|
||||||
uint16_t updateDelay = 1000;
|
uint16_t updateDelay = 1000;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef bool (TestMode::*TestModeFunctionSingle)(int16_t);
|
typedef bool (TestMode::*TestModeFunctionSingle)(int16_t);
|
||||||
typedef bool (TestMode::*TestModeFunctionDouble)(int16_t, int16_t);
|
typedef bool (TestMode::*TestModeFunctionDouble)(int16_t, int16_t);
|
||||||
class MenuTestModeWrapper : public MenuIntInputWrapper {
|
class MenuTestModeWrapper : public MenuIntInputWrapper
|
||||||
public:
|
{
|
||||||
MenuTestModeWrapper(MenuTestMode* menu, TestModeFunctionSingle testModeFunction);
|
public:
|
||||||
MenuTestModeWrapper(MenuTestMode* menu, TestModeFunctionDouble testModeFunction);
|
MenuTestModeWrapper(MenuTestMode *menu, TestModeFunctionSingle testModeFunction);
|
||||||
|
MenuTestModeWrapper(MenuTestMode *menu, TestModeFunctionDouble testModeFunction);
|
||||||
|
|
||||||
void action(int16_t* values, uint8_t length) override;
|
void action(int16_t *values, uint8_t length) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MenuTestMode* menu;
|
MenuTestMode *menu;
|
||||||
TestMode* testMode;
|
TestMode *testMode;
|
||||||
TestModeFunctionSingle testModeFunctionSingle = nullptr;
|
TestModeFunctionSingle testModeFunctionSingle = nullptr;
|
||||||
TestModeFunctionDouble testModeFunctionDouble = nullptr;
|
TestModeFunctionDouble testModeFunctionDouble = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MENU_TEST_MODE_H
|
#endif // MENU_TEST_MODE_H
|
||||||
|
|||||||
@@ -4,50 +4,54 @@
|
|||||||
* @brief Contains the implementation of the class SpeedometerTest.
|
* @brief Contains the implementation of the class SpeedometerTest.
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
* @date 2023-01-24
|
* @date 2023-01-24
|
||||||
*
|
*
|
||||||
* @copyright Copyright (c) 2023
|
* @copyright Copyright (c) 2023
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "speedometerTest.h"
|
#include "speedometerTest.h"
|
||||||
|
|
||||||
SpeedometerTest::SpeedometerTest(Speedometer* speedometer)
|
SpeedometerTest::SpeedometerTest(Speedometer *speedometer)
|
||||||
: speedometer {speedometer}
|
: speedometer{speedometer}
|
||||||
{
|
{
|
||||||
this->speedometer->setDirection(Speedometer::Forward);
|
this->speedometer->setDirection(Speedometer::Forward);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SpeedometerTest::printMenu()
|
||||||
|
{
|
||||||
|
switch (this->state)
|
||||||
|
{
|
||||||
|
case State::Off:
|
||||||
|
this->print("Press Yes (O)", "to start");
|
||||||
|
break;
|
||||||
|
|
||||||
void SpeedometerTest::printMenu() {
|
case State::Running:
|
||||||
switch (this->state) {
|
this->print("Running, Yes (O)", "to stop");
|
||||||
case State::Off :
|
break;
|
||||||
this->print("Press Yes (O)", "to start");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case State::Running :
|
case State::Finished:
|
||||||
this->print("Running, Yes (O)", "to stop");
|
{
|
||||||
break;
|
String res = "";
|
||||||
|
res.concat(this->result);
|
||||||
|
this->print("Result: ", res);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case State::Finished : {
|
default:
|
||||||
String res = "";
|
this->print("Error in", "MenuTest.cpp");
|
||||||
res.concat(this->result);
|
break;
|
||||||
this->print("Result: ", res);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
this->print("Error in", "MenuTest.cpp");
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SpeedometerTest::left()
|
||||||
void SpeedometerTest::left() {
|
{
|
||||||
this->no();
|
this->no();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpeedometerTest::no() {
|
void SpeedometerTest::no()
|
||||||
if (this->state == State::Running){
|
{
|
||||||
|
if (this->state == State::Running)
|
||||||
|
{
|
||||||
speedometer->calibrationMeasurementStop();
|
speedometer->calibrationMeasurementStop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,27 +59,29 @@ void SpeedometerTest::no() {
|
|||||||
this->parentMenu->printMenu();
|
this->parentMenu->printMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpeedometerTest::yes() {
|
void SpeedometerTest::yes()
|
||||||
switch (this->state) {
|
{
|
||||||
case State::Off :
|
switch (this->state)
|
||||||
this->state = State::Running;
|
{
|
||||||
this->speedometer->calibrationMeasurementStart();
|
case State::Off:
|
||||||
this->printMenu();
|
this->state = State::Running;
|
||||||
break;
|
this->speedometer->calibrationMeasurementStart();
|
||||||
|
this->printMenu();
|
||||||
|
break;
|
||||||
|
|
||||||
case State::Running :
|
case State::Running:
|
||||||
this->state = State::Finished;
|
this->state = State::Finished;
|
||||||
this->result = this->speedometer->calibrationMeasurementStop();
|
this->result = this->speedometer->calibrationMeasurementStop();
|
||||||
this->printMenu();
|
this->printMenu();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case State::Finished :
|
|
||||||
this->state = State::Running;
|
|
||||||
this->speedometer->calibrationMeasurementStart();
|
|
||||||
this->printMenu();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
case State::Finished:
|
||||||
break;
|
this->state = State::Running;
|
||||||
|
this->speedometer->calibrationMeasurementStart();
|
||||||
|
this->printMenu();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,9 @@
|
|||||||
* @brief Contains a class to test the wheel encoder.
|
* @brief Contains a class to test the wheel encoder.
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
* @date 2023-01-24
|
* @date 2023-01-24
|
||||||
*
|
*
|
||||||
* @copyright Copyright (c) 2023
|
* @copyright Copyright (c) 2023
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
@@ -16,49 +16,51 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Tests the wheel encoder.
|
* @brief Tests the wheel encoder.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class SpeedometerTest : public MenuControl {
|
class SpeedometerTest : public MenuControl
|
||||||
public:
|
{
|
||||||
/**
|
public:
|
||||||
* @brief The states of the test.
|
/**
|
||||||
*/
|
* @brief The states of the test.
|
||||||
enum State {
|
*/
|
||||||
Off,
|
enum State
|
||||||
Running,
|
{
|
||||||
Finished
|
Off,
|
||||||
};
|
Running,
|
||||||
|
Finished
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Construct a new Speedometer Test object
|
* @brief Construct a new Speedometer Test object
|
||||||
*
|
*
|
||||||
* @param speedometer
|
* @param speedometer
|
||||||
*/
|
*/
|
||||||
SpeedometerTest(Speedometer* speedometer);
|
SpeedometerTest(Speedometer *speedometer);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Prints the actual state of the test.
|
* @brief Prints the actual state of the test.
|
||||||
*/
|
*/
|
||||||
void printMenu() override;
|
void printMenu() override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Calls no.
|
* @brief Calls no.
|
||||||
*/
|
*/
|
||||||
void left() override;
|
void left() override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Exit the menu or end the test.
|
* @brief Exit the menu or end the test.
|
||||||
*/
|
*/
|
||||||
void no() override;
|
void no() override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Starts or restarts the test.
|
* @brief Starts or restarts the test.
|
||||||
*/
|
*/
|
||||||
void yes() override;
|
void yes() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Speedometer* speedometer;
|
Speedometer *speedometer;
|
||||||
State state = State::Off;
|
State state = State::Off;
|
||||||
|
|
||||||
uint16_t result = 0;
|
uint16_t result = 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,79 +4,114 @@
|
|||||||
* @brief Contains an implementation of the class MenuDriveMode
|
* @brief Contains an implementation of the class MenuDriveMode
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
* @date 2022-01-31
|
* @date 2022-01-31
|
||||||
*
|
*
|
||||||
* @copyright Copyright (c) 2022
|
* @copyright Copyright (c) 2022
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "menuDriveMode.h"
|
#include "menuDriveMode.h"
|
||||||
|
|
||||||
MenuDriveMode::MenuDriveMode(DriveManager* driveManager)
|
MenuDriveMode::MenuDriveMode(DriveManager *driveManager)
|
||||||
: driveManager {driveManager}
|
: driveManager{driveManager}
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuDriveMode::left() {
|
MenuDriveMode::~MenuDriveMode()
|
||||||
if (static_cast<bool>(this->activeMenu)) {
|
{
|
||||||
if (static_cast<bool>(this->activeMenu)) {
|
if (this->selfCreatedMenuSpeed)
|
||||||
this->activeMenu->left();
|
{
|
||||||
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->firstPrint = true;
|
this->firstPrint = true;
|
||||||
this->configureOnLeave();
|
this->configureOnLeave();
|
||||||
delete this->menuSpeed;
|
delete this->menuSpeed;
|
||||||
this->driveManager->changeModus();
|
this->driveManager->changeModus();
|
||||||
MenuInformationSites::left();
|
MenuInformationSites::left();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuDriveMode::right() {
|
void MenuDriveMode::right()
|
||||||
if (static_cast<bool>(this->activeMenu)) {
|
{
|
||||||
|
if (static_cast<bool>(this->activeMenu))
|
||||||
|
{
|
||||||
this->activeMenu->right();
|
this->activeMenu->right();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MenuInformationSites::right();
|
MenuInformationSites::right();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuDriveMode::up() {
|
void MenuDriveMode::up()
|
||||||
if (static_cast<bool>(this->activeMenu)) {
|
{
|
||||||
|
if (static_cast<bool>(this->activeMenu))
|
||||||
|
{
|
||||||
this->activeMenu->up();
|
this->activeMenu->up();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MenuInformationSites::up();
|
MenuInformationSites::up();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuDriveMode::down() {
|
void MenuDriveMode::down()
|
||||||
if (static_cast<bool>(this->activeMenu)) {
|
{
|
||||||
|
if (static_cast<bool>(this->activeMenu))
|
||||||
|
{
|
||||||
this->activeMenu->down();
|
this->activeMenu->down();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MenuInformationSites::down();
|
MenuInformationSites::down();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuDriveMode::yes() {
|
void MenuDriveMode::yes()
|
||||||
if (static_cast<bool>(this->activeMenu)) {
|
{
|
||||||
|
if (static_cast<bool>(this->activeMenu))
|
||||||
|
{
|
||||||
this->activeMenu->yes();
|
this->activeMenu->yes();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MenuInformationSites::yes();
|
MenuInformationSites::yes();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuDriveMode::no() {
|
void MenuDriveMode::no()
|
||||||
if (static_cast<bool>(this->activeMenu)) {
|
{
|
||||||
|
if (static_cast<bool>(this->activeMenu))
|
||||||
|
{
|
||||||
this->activeMenu->no();
|
this->activeMenu->no();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MenuInformationSites::no();
|
MenuInformationSites::no();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuDriveMode::prepareReenterMenu() {
|
void MenuDriveMode::prepareReenterMenu()
|
||||||
|
{
|
||||||
this->activeMenu = nullptr;
|
this->activeMenu = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuDriveMode::printMenu() {
|
void MenuDriveMode::printMenu()
|
||||||
if (static_cast<bool>(this->activeMenu)) {
|
{
|
||||||
|
if (static_cast<bool>(this->activeMenu))
|
||||||
|
{
|
||||||
this->activeMenu->printMenu();
|
this->activeMenu->printMenu();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -84,40 +119,53 @@ void MenuDriveMode::printMenu() {
|
|||||||
MenuInformationSites::printMenu();
|
MenuInformationSites::printMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuDriveMode::init() {
|
void MenuDriveMode::init()
|
||||||
|
{
|
||||||
this->activeMenu = nullptr;
|
this->activeMenu = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuDriveMode::activateSpeedMenu() {
|
void MenuDriveMode::activateSpeedMenu()
|
||||||
if (!this->driveManager->isActive()) {
|
{
|
||||||
|
if (!this->driveManager->isActive())
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DrivingSpeeds& speeds = this->driveManager->getDriveModiPtr()->getSpeedsRef();
|
if (this->selfCreatedMenuSpeed)
|
||||||
|
{
|
||||||
|
delete this->menuSpeed;
|
||||||
|
}
|
||||||
|
|
||||||
|
DrivingSpeeds &speeds = this->driveManager->getDriveModiPtr()->getSpeedsRef();
|
||||||
auto *menu = new MenuIntInput(2, new MenuSpeed(speeds));
|
auto *menu = new MenuIntInput(2, new MenuSpeed(speeds));
|
||||||
|
|
||||||
menu->setMinMax(5, UINT8_MAX);
|
menu->setMinMax(5, UINT8_MAX);
|
||||||
menu->setEntry(0, "x m/s e-1", driveManager->getDrivingSpeedsRef().x * 10);
|
menu->setEntry(0, "x m/s e-1", driveManager->getDrivingSpeedsRef().x * 10);
|
||||||
menu->setEntry(1, "z rad/s e-1", driveManager->getDrivingSpeedsRef().rot * 10);
|
menu->setEntry(1, "z rad/s e-1", driveManager->getDrivingSpeedsRef().rot * 10);
|
||||||
|
|
||||||
|
this->selfCreatedMenuSpeed = true;
|
||||||
this->addSpeedMenu(menu);
|
this->addSpeedMenu(menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuDriveMode::enterSpeedMenu() {
|
void MenuDriveMode::enterSpeedMenu()
|
||||||
|
{
|
||||||
this->activeMenu = this->menuSpeed;
|
this->activeMenu = this->menuSpeed;
|
||||||
this->enterMenu();
|
this->enterMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuDriveMode::enterSensorMenu() {
|
void MenuDriveMode::enterSensorMenu()
|
||||||
|
{
|
||||||
this->activeMenu = this->menuSensor;
|
this->activeMenu = this->menuSensor;
|
||||||
this->enterMenu();
|
this->enterMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuDriveMode::enterMenu() {
|
void MenuDriveMode::enterMenu()
|
||||||
if (!static_cast<bool>(this->activeMenu)) {
|
{
|
||||||
|
if (!static_cast<bool>(this->activeMenu))
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->activeMenu->printMenu();
|
this->activeMenu->printMenu();
|
||||||
this->activeMenu->setParentMenu(this);
|
this->activeMenu->setParentMenu(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,9 @@
|
|||||||
* @brief Contains a base class for Menus about DriveModi
|
* @brief Contains a base class for Menus about DriveModi
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
* @date 2022-01-31
|
* @date 2022-01-31
|
||||||
*
|
*
|
||||||
* @copyright Copyright (c) 2022
|
* @copyright Copyright (c) 2022
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#ifndef MENU_DRIVE_MODI_H
|
#ifndef MENU_DRIVE_MODI_H
|
||||||
#define MENU_DRIVE_MODI_H
|
#define MENU_DRIVE_MODI_H
|
||||||
@@ -18,49 +18,80 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief A base class for Menus about DriveModi
|
* @brief A base class for Menus about DriveModi
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class MenuDriveMode : public MenuInformationSites {
|
class MenuDriveMode : public MenuInformationSites
|
||||||
public:
|
{
|
||||||
/**
|
public:
|
||||||
* @brief Construct a new Menu Drive Mode object
|
/**
|
||||||
*
|
* @brief Construct a new Menu Drive Mode object
|
||||||
* @param driveManager
|
*
|
||||||
*/
|
* @param driveManager
|
||||||
MenuDriveMode(DriveManager* driveManager);
|
*/
|
||||||
|
MenuDriveMode(DriveManager *driveManager);
|
||||||
|
|
||||||
void addSensorMenu(MenuSensorData* menuSensor) { this->menuSensor = menuSensor; }
|
~MenuDriveMode();
|
||||||
void addSpeedMenu(MenuIntInput* menuSpeed) { this->menuSpeed = menuSpeed; }
|
|
||||||
|
|
||||||
/**
|
void addSensorMenu(MenuSensorData *menuSensor) { this->menuSensor = menuSensor; }
|
||||||
* @brief Goes back to the parentMenu.
|
void addSpeedMenu(MenuIntInput *menuSpeed);
|
||||||
*/
|
|
||||||
void left() override;
|
|
||||||
void right() override;
|
|
||||||
void up() override;
|
|
||||||
void down() override;
|
|
||||||
void yes() override;
|
|
||||||
void no() override;
|
|
||||||
|
|
||||||
void prepareReenterMenu() override;
|
/**
|
||||||
void printMenu() override;
|
* @brief Goes back to the parentMenu.
|
||||||
|
*/
|
||||||
|
void left() override;
|
||||||
|
void right() override;
|
||||||
|
void up() override;
|
||||||
|
void down() override;
|
||||||
|
void yes() override;
|
||||||
|
void no() override;
|
||||||
|
|
||||||
protected:
|
void prepareReenterMenu() override;
|
||||||
void init() override;
|
void printMenu() override;
|
||||||
virtual void configureOnLeave() {}
|
|
||||||
void activateSpeedMenu();
|
|
||||||
void enterSpeedMenu();
|
|
||||||
void enterSensorMenu();
|
|
||||||
|
|
||||||
DriveManager* driveManager;
|
protected:
|
||||||
|
void init() override;
|
||||||
bool firstPrint = true;
|
|
||||||
|
|
||||||
private:
|
/**
|
||||||
void enterMenu();
|
* @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() {}
|
||||||
|
|
||||||
MenuControl* activeMenu = nullptr;
|
/**
|
||||||
MenuSensorData* menuSensor = nullptr;
|
* @brief Creates an own SpeedMenu
|
||||||
MenuIntInput* menuSpeed = nullptr;
|
*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
bool firstPrint = true;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void enterMenu();
|
||||||
|
|
||||||
|
MenuControl *activeMenu = nullptr;
|
||||||
|
MenuSensorData *menuSensor = nullptr;
|
||||||
|
MenuIntInput *menuSpeed = nullptr;
|
||||||
|
|
||||||
|
bool selfCreatedMenuSpeed = false;
|
||||||
};
|
};
|
||||||
#endif // MENU_DRIVE_MODI_H
|
#endif // MENU_DRIVE_MODI_H
|
||||||
|
|||||||
@@ -4,15 +4,14 @@
|
|||||||
* @brief Contains a class which use the navigate class to drive automaticaly
|
* @brief Contains a class which use the navigate class to drive automaticaly
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
* @date 2022-02-02
|
* @date 2022-02-02
|
||||||
*
|
*
|
||||||
* @copyright Copyright (c) 2022
|
* @copyright Copyright (c) 2022
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef AUTOPILOT_H
|
#ifndef AUTOPILOT_H
|
||||||
#define AUTOPILOT_H
|
#define AUTOPILOT_H
|
||||||
|
|
||||||
|
|
||||||
#include "navigation.h"
|
#include "navigation.h"
|
||||||
#include "driveModi/Modi/ManualControl/manualControl.h"
|
#include "driveModi/Modi/ManualControl/manualControl.h"
|
||||||
|
|
||||||
@@ -20,110 +19,113 @@ class DirectionChangeSignal;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This class use the navigate class to drive automaticaly
|
* @brief This class use the navigate class to drive automaticaly
|
||||||
*
|
*
|
||||||
* This class get the information from the navigate class. When an
|
* This class get the information from the navigate class. When an
|
||||||
* object of this class is constructed the rover can be driven manually.
|
* 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
|
* When the Rover is near to the first position of the Route, you can
|
||||||
* switch to automatic drive.
|
* switch to automatic drive.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class Autopilot : public ManualControl {
|
class Autopilot : public ManualControl
|
||||||
public:
|
{
|
||||||
enum State {
|
public:
|
||||||
InsufficientAccuracy = -2,
|
enum State
|
||||||
NoRoute = -1,
|
{
|
||||||
None = 0,
|
InsufficientAccuracy = -2,
|
||||||
NavigationStarted,
|
NoRoute = -1,
|
||||||
GetToStartPoint,
|
None = 0,
|
||||||
SelfDrivingAvailable,
|
NavigationStarted,
|
||||||
SelfDriving,
|
GetToStartPoint,
|
||||||
SelfDrivingRotate,
|
SelfDrivingAvailable,
|
||||||
TargetReached
|
SelfDriving,
|
||||||
};
|
SelfDrivingRotate,
|
||||||
|
TargetReached
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Destroy the Autopilot object
|
* @brief Destroy the Autopilot object
|
||||||
*
|
*
|
||||||
* Disconnect the NTRIP-Client
|
* Disconnect the NTRIP-Client
|
||||||
*/
|
*/
|
||||||
~Autopilot();
|
~Autopilot();
|
||||||
|
|
||||||
void restart();
|
void restart();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the Route Info object
|
* @brief Get the Route Info object
|
||||||
*
|
*
|
||||||
* @return RouteInfo
|
* @return RouteInfo
|
||||||
*/
|
*/
|
||||||
RouteInfo getRouteInfo() const { return this->routeInfo; }
|
RouteInfo getRouteInfo() const { return this->routeInfo; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the Course Correction object
|
* @brief Get the Course Correction object
|
||||||
*
|
*
|
||||||
* @return CourseCorrection
|
* @return CourseCorrection
|
||||||
*/
|
*/
|
||||||
CourseCorrection getCourseCorrection() const { return this->courseCorrection; }
|
CourseCorrection getCourseCorrection() const { return this->courseCorrection; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the State object
|
* @brief Get the State object
|
||||||
*
|
*
|
||||||
* @return State
|
* @return State
|
||||||
*/
|
*/
|
||||||
State getState() const { return this->state; }
|
State getState() const { return this->state; }
|
||||||
Navigation* getNavigation() const { return this->navigation; }
|
Navigation *getNavigation() const { return this->navigation; }
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Tells if there are new informations to display
|
|
||||||
*
|
|
||||||
* @return true
|
|
||||||
* @return false
|
|
||||||
*/
|
|
||||||
bool shouldUpdate();
|
|
||||||
void testRotate(int16_t degree);
|
|
||||||
void endRotate();
|
|
||||||
void switchLoopMode() { this->loopMode = !this->loopMode; }
|
|
||||||
bool getLoopMode() const { return this->loopMode; }
|
|
||||||
|
|
||||||
private:
|
/**
|
||||||
void init();
|
* @brief Tells if there are new informations to display
|
||||||
void drive();
|
*
|
||||||
void beginRotate();
|
* @return true
|
||||||
void rotate();
|
* @return false
|
||||||
void run() override;
|
*/
|
||||||
void checkButtonInput();
|
bool shouldUpdate();
|
||||||
void askNavigationForOrder();
|
void testRotate(int16_t degree);
|
||||||
void selfDriving();
|
void endRotate();
|
||||||
void restartLoop();
|
void switchLoopMode() { this->loopMode = !this->loopMode; }
|
||||||
void afterActivate() override;
|
bool getLoopMode() const { return this->loopMode; }
|
||||||
|
|
||||||
Navigation* navigation = nullptr;
|
private:
|
||||||
CourseCorrection courseCorrection{0, 0};
|
void init();
|
||||||
RouteInfo routeInfo{0, 0};
|
void drive();
|
||||||
State state = State::None;
|
void beginRotate();
|
||||||
State lastState = State::None;
|
void rotate();
|
||||||
Navigation::Status lastOrderStatus;
|
void run() override;
|
||||||
DirectionChangeSignal* directionChangeSignal = nullptr;
|
void checkButtonInput();
|
||||||
|
void askNavigationForOrder();
|
||||||
|
void selfDriving();
|
||||||
|
void restartLoop();
|
||||||
|
void afterActivate() override;
|
||||||
|
|
||||||
bool updateDisplay = false;
|
Navigation *navigation = nullptr;
|
||||||
bool loopMode = false;
|
CourseCorrection courseCorrection{0, 0};
|
||||||
|
RouteInfo routeInfo{0, 0};
|
||||||
|
State state = State::None;
|
||||||
|
State lastState = State::None;
|
||||||
|
Navigation::Status lastOrderStatus;
|
||||||
|
DirectionChangeSignal *directionChangeSignal = nullptr;
|
||||||
|
|
||||||
uint8_t maxCourseDeviationBeforeAct = 5;
|
bool updateDisplay = false;
|
||||||
uint16_t autopilotChangeDelayMillis = 500;
|
bool loopMode = false;
|
||||||
uint32_t lastAutopilotChangeMillis = 0;
|
|
||||||
|
|
||||||
int16_t rotationAimAzimuth = 0;
|
uint8_t maxCourseDeviationBeforeAct = 5;
|
||||||
|
uint16_t autopilotChangeDelayMillis = 500;
|
||||||
|
uint32_t lastAutopilotChangeMillis = 0;
|
||||||
|
|
||||||
double minRemainingDistance = 0.25;
|
int16_t rotationAimAzimuth = 0;
|
||||||
|
|
||||||
|
double minRemainingDistance = 0.25;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DirectionChangeSignal : public DirectionChangeWrapper {
|
class DirectionChangeSignal : public DirectionChangeWrapper
|
||||||
public:
|
{
|
||||||
DirectionChangeSignal(Autopilot* pilot);
|
public:
|
||||||
~DirectionChangeSignal();
|
DirectionChangeSignal(Autopilot *pilot);
|
||||||
void action() override;
|
~DirectionChangeSignal();
|
||||||
|
void action() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Autopilot* pilot;
|
Autopilot *pilot;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // AUTOPILOT_H
|
#endif // AUTOPILOT_H
|
||||||
|
|||||||
@@ -1,22 +1,25 @@
|
|||||||
/**
|
/**
|
||||||
* @file calibrateCompassM.cpp
|
* @file calibrateCompassM.cpp
|
||||||
* @author Alexander Klein (alex@kleiax.de)
|
* @author Alexander Klein (alex@kleiax.de)
|
||||||
* @brief
|
* @brief
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
* @date 2023-09-03
|
* @date 2023-09-03
|
||||||
*
|
*
|
||||||
* @copyright Copyright (c) 2023
|
* @copyright Copyright (c) 2023
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "calibrateCompassM.h"
|
#include "calibrateCompassM.h"
|
||||||
|
|
||||||
|
void CalibrateCompassM::setCalibrateCompass(CalibrateCompass *caliCompass)
|
||||||
void CalibrateCompassM::setCalibrateCompass(CalibrateCompass *caliCompass) {
|
{
|
||||||
if (static_cast<bool>(caliCompass)) {
|
if (static_cast<bool>(caliCompass))
|
||||||
|
{
|
||||||
this->caliCompass = caliCompass;
|
this->caliCompass = caliCompass;
|
||||||
this->addChildComponent(this->caliCompass);
|
this->addChildComponent(this->caliCompass);
|
||||||
} else if (static_cast<bool>(this->caliCompass)) {
|
}
|
||||||
|
else if (static_cast<bool>(this->caliCompass))
|
||||||
|
{
|
||||||
this->removeChildComponent(this->caliCompass);
|
this->removeChildComponent(this->caliCompass);
|
||||||
this->caliCompass = caliCompass;
|
this->caliCompass = caliCompass;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
/**
|
/**
|
||||||
* @file calibrateCompassM.h
|
* @file calibrateCompassM.h
|
||||||
* @author Alexander Klein (alex@kleiax.de)
|
* @author Alexander Klein (alex@kleiax.de)
|
||||||
* @brief
|
* @brief Contains a Menu class to calibrate the compass
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
* @date 2023-09-03
|
* @date 2023-09-03
|
||||||
*
|
*
|
||||||
* @copyright Copyright (c) 2023
|
* @copyright Copyright (c) 2023
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef CALIBRATE_COMPASS_M_H
|
#ifndef CALIBRATE_COMPASS_M_H
|
||||||
@@ -16,12 +16,21 @@
|
|||||||
|
|
||||||
#include "driveModi/Modi/ManualControl/manualControl.h"
|
#include "driveModi/Modi/ManualControl/manualControl.h"
|
||||||
|
|
||||||
class CalibrateCompassM : public ManualControl {
|
/**
|
||||||
public:
|
* @brief A Menu class to interact with CalibrateCompass class
|
||||||
void setCalibrateCompass(CalibrateCompass* caliCompass = nullptr);
|
*/
|
||||||
|
class CalibrateCompassM : public ManualControl
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Set the CalibrateCompass object
|
||||||
|
*
|
||||||
|
* @param caliCompass
|
||||||
|
*/
|
||||||
|
void setCalibrateCompass(CalibrateCompass *caliCompass = nullptr);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CalibrateCompass* caliCompass = nullptr;
|
CalibrateCompass *caliCompass = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //CALIBRATE_COMPASS_M_H
|
#endif // CALIBRATE_COMPASS_M_H
|
||||||
|
|||||||
@@ -4,9 +4,9 @@
|
|||||||
* @brief Contains a class to capture a driven route
|
* @brief Contains a class to capture a driven route
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
* @date 2022-02-15
|
* @date 2022-02-15
|
||||||
*
|
*
|
||||||
* @copyright Copyright (c) 2022
|
* @copyright Copyright (c) 2022
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef CAPTURE_ROUTE_H
|
#ifndef CAPTURE_ROUTE_H
|
||||||
@@ -19,61 +19,57 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief A class to capture a driven class
|
* @brief A class to capture a driven class
|
||||||
*
|
*
|
||||||
* This class inherits ManualControl so you can drive
|
* This class inherits ManualControl so you can drive
|
||||||
* normally as in ManualControl. If GPS signal is valid
|
* normally as in ManualControl. If GPS signal is valid
|
||||||
* you can add a Point everytime you want.
|
* you can add a Point everytime you want.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class CaptureRoute : public ManualControl {
|
class CaptureRoute : public ManualControl
|
||||||
public:
|
{
|
||||||
/**
|
public:
|
||||||
* @brief Destroy the Capture Route object
|
/**
|
||||||
*
|
* @brief Destroy the Capture Route object
|
||||||
* Disconnect the NTRIP-Client
|
*
|
||||||
*/
|
* Disconnect the NTRIP-Client
|
||||||
~CaptureRoute();
|
*/
|
||||||
|
~CaptureRoute();
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * @brief Get the Navigation object
|
* @brief Get the Route Info object
|
||||||
// *
|
*
|
||||||
// * @return Navigation*
|
* @return RouteInfo
|
||||||
// */
|
*/
|
||||||
// Navigation* getNavigation() const { return this->navigation; }
|
RouteInfo getRouteInfo() const { return this->routeInfo; }
|
||||||
|
|
||||||
/**
|
Navigation::Status getLastStatus() const { return this->status; }
|
||||||
* @brief Get the Route Info object
|
Navigation *getNavigation() const { return this->navigation; }
|
||||||
*
|
|
||||||
* @return RouteInfo
|
|
||||||
*/
|
|
||||||
RouteInfo getRouteInfo() const { return this->routeInfo; }
|
|
||||||
Navigation::Status getLastStatus() const { return this->status; }
|
|
||||||
Navigation* getNavigation() const { return this->navigation; }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the distance to the last saved oint
|
* @brief Get the distance to the last saved oint
|
||||||
*
|
*
|
||||||
* @return double in meters
|
* @return double in meters
|
||||||
*/
|
*/
|
||||||
double getDistanceToLastPoint() const;
|
double getDistanceToLastPoint() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Tells if there are new informations to display
|
* @brief Tells if there are new informations to display
|
||||||
*
|
*
|
||||||
* @return true
|
* @return true
|
||||||
* @return false
|
* @return false
|
||||||
*/
|
*/
|
||||||
bool shouldUpdate();
|
bool shouldUpdate();
|
||||||
private:
|
|
||||||
void run() override;
|
|
||||||
void afterActivate() override;
|
|
||||||
|
|
||||||
Navigation* navigation = nullptr;
|
private:
|
||||||
RouteInfo routeInfo;
|
void run() override;
|
||||||
Point lastSavedPoint;
|
void afterActivate() override;
|
||||||
Navigation::Status status = Navigation::Status::Complete;
|
|
||||||
|
|
||||||
bool updateDisplay = false;
|
Navigation *navigation = nullptr;
|
||||||
|
RouteInfo routeInfo;
|
||||||
|
Point lastSavedPoint;
|
||||||
|
Navigation::Status status = Navigation::Status::Complete;
|
||||||
|
|
||||||
|
bool updateDisplay = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CAPTURE_ROUTE_H
|
#endif // CAPTURE_ROUTE_H
|
||||||
|
|||||||
@@ -4,53 +4,70 @@
|
|||||||
* @brief A small class to drive the Rover by the controller joystick.
|
* @brief A small class to drive the Rover by the controller joystick.
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
* @date 2021-12-13
|
* @date 2021-12-13
|
||||||
*
|
*
|
||||||
* @copyright Copyright (c) 2021
|
* @copyright Copyright (c) 2021
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#ifndef MANUAL_CONTROL_H
|
#ifndef MANUAL_CONTROL_H
|
||||||
#define MANUAL_CONTROL_H
|
#define MANUAL_CONTROL_H
|
||||||
|
|
||||||
#include "driveModi/driveModi.h"
|
#include "driveModi/driveModi.h"
|
||||||
|
|
||||||
class DirectionChangeWrapper {
|
class DirectionChangeWrapper
|
||||||
public:
|
{
|
||||||
virtual void action() = 0;
|
public:
|
||||||
|
virtual void action() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Drive the Rover with a Joystick
|
* @brief Drive the Rover with a Joystick
|
||||||
*
|
*
|
||||||
* This class gets the x and y value from the PS3 controller
|
* This class gets the x and y value from the ControlPad
|
||||||
* and map the values to moveControl
|
* and map the values to moveControl
|
||||||
*
|
*
|
||||||
* @see MoveControl
|
* @see MoveControl
|
||||||
*/
|
*/
|
||||||
class ManualControl : public DriveModi {
|
class ManualControl : public DriveModi
|
||||||
public:
|
{
|
||||||
enum class InputMode : uint8_t {
|
public:
|
||||||
Analog,
|
/**
|
||||||
Digital
|
* @brief The enum is used to change the interpretation of the joystick data
|
||||||
};
|
*/
|
||||||
|
enum class InputMode : uint8_t
|
||||||
|
{
|
||||||
|
Analog,
|
||||||
|
Digital
|
||||||
|
};
|
||||||
|
|
||||||
void switchInputMode();
|
/**
|
||||||
void setInputMode(InputMode mode) { this->inputMode = mode; }
|
* @brief Change the InputMode to the opposite
|
||||||
InputMode getInputMode() const { return this->inputMode; }
|
*/
|
||||||
void setDirectionChangeCallback(DirectionChangeWrapper* callback) { this->directionChangeWrapper = callback; }
|
void switchInputMode();
|
||||||
|
void setInputMode(InputMode mode) { this->inputMode = mode; }
|
||||||
|
InputMode getInputMode() const { return this->inputMode; }
|
||||||
|
|
||||||
uint16_t getDutycycleLeft() const { return this->moveControl->getDutycycleLeft(); }
|
/**
|
||||||
uint16_t getDutycycleRight() const { return this->moveControl->getDutycycleRight(); }
|
* @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; }
|
||||||
|
|
||||||
protected:
|
uint16_t getDutycycleLeft() const { return this->moveControl->getDutycycleLeft(); }
|
||||||
void run() override;
|
uint16_t getDutycycleRight() const { return this->moveControl->getDutycycleRight(); }
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
void analogControl();
|
void run() override;
|
||||||
void digitalControl();
|
|
||||||
|
|
||||||
bool lastLoopTurned = false;
|
private:
|
||||||
DirectionChangeWrapper* directionChangeWrapper = nullptr;
|
void analogControl();
|
||||||
InputMode inputMode = InputMode::Analog;
|
void digitalControl();
|
||||||
|
|
||||||
|
bool lastLoopTurned = false;
|
||||||
|
DirectionChangeWrapper *directionChangeWrapper = nullptr;
|
||||||
|
InputMode inputMode = InputMode::Analog;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MANUAL_CONTROL_H
|
#endif // MANUAL_CONTROL_H
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ void TestMode::run()
|
|||||||
if (this->maneuver == Maneuver::Turn)
|
if (this->maneuver == Maneuver::Turn)
|
||||||
{
|
{
|
||||||
uint16_t delta = abs(this->azimuth - this->getSensorData()->getRealAzimuth());
|
uint16_t delta = abs(this->azimuth - this->getSensorData()->getRealAzimuth());
|
||||||
if (delta > this->degree) {
|
if (delta > this->degree)
|
||||||
|
{
|
||||||
this->abort = true;
|
this->abort = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -31,7 +32,8 @@ void TestMode::run()
|
|||||||
|
|
||||||
bool TestMode::drive(int16_t cmDistance, int16_t degree)
|
bool TestMode::drive(int16_t cmDistance, int16_t degree)
|
||||||
{
|
{
|
||||||
if (this->busy){
|
if (this->busy)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,10 +45,12 @@ bool TestMode::drive(int16_t cmDistance, int16_t degree)
|
|||||||
// Only left or right
|
// Only left or right
|
||||||
this->moveControl->setSpeed(0);
|
this->moveControl->setSpeed(0);
|
||||||
|
|
||||||
if (degree < 0){
|
if (degree < 0)
|
||||||
|
{
|
||||||
this->moveControl->setRotationSpeed(-this->maxSpeeds.rot);
|
this->moveControl->setRotationSpeed(-this->maxSpeeds.rot);
|
||||||
}
|
}
|
||||||
else if (degree > 0){
|
else if (degree > 0)
|
||||||
|
{
|
||||||
this->moveControl->setRotationSpeed(this->maxSpeeds.rot);
|
this->moveControl->setRotationSpeed(this->maxSpeeds.rot);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,10 +66,12 @@ bool TestMode::drive(int16_t cmDistance, int16_t degree)
|
|||||||
// Only forward or backward
|
// Only forward or backward
|
||||||
this->moveControl->setRotationSpeed(0);
|
this->moveControl->setRotationSpeed(0);
|
||||||
|
|
||||||
if (cmDistance < 0){
|
if (cmDistance < 0)
|
||||||
|
{
|
||||||
this->moveControl->setSpeed(-this->maxSpeeds.x);
|
this->moveControl->setSpeed(-this->maxSpeeds.x);
|
||||||
}
|
}
|
||||||
else if (cmDistance > 0){
|
else if (cmDistance > 0)
|
||||||
|
{
|
||||||
this->moveControl->setSpeed(this->maxSpeeds.x);
|
this->moveControl->setSpeed(this->maxSpeeds.x);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,10 +84,12 @@ bool TestMode::drive(int16_t cmDistance, int16_t degree)
|
|||||||
{
|
{
|
||||||
// forward or backward and left or right
|
// forward or backward and left or right
|
||||||
// TODO: Calculate roationspeed
|
// TODO: Calculate roationspeed
|
||||||
if (cmDistance < 0){
|
if (cmDistance < 0)
|
||||||
|
{
|
||||||
this->moveControl->setSpeed(-this->maxSpeeds.x);
|
this->moveControl->setSpeed(-this->maxSpeeds.x);
|
||||||
}
|
}
|
||||||
else if (cmDistance > 0){
|
else if (cmDistance > 0)
|
||||||
|
{
|
||||||
this->moveControl->setSpeed(this->maxSpeeds.x);
|
this->moveControl->setSpeed(this->maxSpeeds.x);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,7 +145,8 @@ void TestMode::abortManeuver()
|
|||||||
|
|
||||||
uint8_t TestMode::getRemainingManeuverTime() const
|
uint8_t TestMode::getRemainingManeuverTime() const
|
||||||
{
|
{
|
||||||
if (this->busy){
|
if (this->busy)
|
||||||
|
{
|
||||||
return static_cast<uint8_t>((this->maneuverTime - (millis() - this->actionStart)) / 1000);
|
return static_cast<uint8_t>((this->maneuverTime - (millis() - this->actionStart)) / 1000);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@@ -145,13 +154,16 @@ uint8_t TestMode::getRemainingManeuverTime() const
|
|||||||
|
|
||||||
bool TestMode::engineInit(int16_t powerPercentage, int16_t seconds)
|
bool TestMode::engineInit(int16_t powerPercentage, int16_t seconds)
|
||||||
{
|
{
|
||||||
if (this->busy){
|
if (this->busy)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (powerPercentage > TestMode::maxPercentage || powerPercentage < -TestMode::maxPercentage){
|
if (powerPercentage > TestMode::maxPercentage || powerPercentage < -TestMode::maxPercentage)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (seconds < 0){
|
if (seconds < 0)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ class TestMode : public DriveModi
|
|||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Different states to test the engine
|
* @brief Different states to test the engine
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
enum Maneuver
|
enum Maneuver
|
||||||
{
|
{
|
||||||
@@ -38,6 +37,14 @@ public:
|
|||||||
Drive
|
Drive
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Let the rover drive
|
||||||
|
*
|
||||||
|
* @param cmDistance to drive
|
||||||
|
* @param degree degree to rotate over the hole distance
|
||||||
|
* @return true
|
||||||
|
* @return false
|
||||||
|
*/
|
||||||
bool drive(int16_t cmDistance = 0, int16_t degree = 0);
|
bool drive(int16_t cmDistance = 0, int16_t degree = 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -89,6 +96,7 @@ public:
|
|||||||
* @return false
|
* @return false
|
||||||
*/
|
*/
|
||||||
bool getBusy() const { return this->busy; }
|
bool getBusy() const { return this->busy; }
|
||||||
|
|
||||||
Maneuver getManeuver() const { return this->maneuver; }
|
Maneuver getManeuver() const { return this->maneuver; }
|
||||||
Speedometer *getSpeedometerLeft() const { return this->moveControl->getSpeedometerLeft(); }
|
Speedometer *getSpeedometerLeft() const { return this->moveControl->getSpeedometerLeft(); }
|
||||||
Speedometer *getSpeedometerRight() const { return this->moveControl->getSpeedometerRight(); }
|
Speedometer *getSpeedometerRight() const { return this->moveControl->getSpeedometerRight(); }
|
||||||
|
|||||||
@@ -4,9 +4,9 @@
|
|||||||
* @brief Contains a class to switch the DriveModi
|
* @brief Contains a class to switch the DriveModi
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
* @date 2021-12-14
|
* @date 2021-12-14
|
||||||
*
|
*
|
||||||
* @copyright Copyright (c) 2021
|
* @copyright Copyright (c) 2021
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef DRIVE_MANAGER_H
|
#ifndef DRIVE_MANAGER_H
|
||||||
@@ -20,58 +20,61 @@
|
|||||||
#include "component.h"
|
#include "component.h"
|
||||||
#include "sensorData.h"
|
#include "sensorData.h"
|
||||||
|
|
||||||
class DriveManager : public Component {
|
/**
|
||||||
public:
|
* @brief A class to manage and hold the different DriveModi
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class DriveManager : public Component
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Drive Manager object
|
||||||
|
*
|
||||||
|
* @param moveControl
|
||||||
|
* @param sensorData
|
||||||
|
* @param input
|
||||||
|
*/
|
||||||
|
DriveManager(MoveControl *moveControl, const SensorData *sensorData, const ControlPadInput *input);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Construct a new Drive Manager object
|
* @brief Construct a new Drive Manager object
|
||||||
*
|
*
|
||||||
* @param moveControl
|
* @param params
|
||||||
* @param sensorData
|
*/
|
||||||
* @param input
|
DriveManager(DriveModiParams params);
|
||||||
*/
|
|
||||||
DriveManager(MoveControl *moveControl, const SensorData* sensorData, const ControlPadInput *input);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Construct a new Drive Manager object
|
* @brief Change the DriveModi to a specific value
|
||||||
*
|
*
|
||||||
* @param params
|
* Sets MoveControl to a safe state, delete the last
|
||||||
*/
|
* DriveModi and than set the new DriveModi
|
||||||
DriveManager(DriveModiParams params);
|
*
|
||||||
|
* @param modus
|
||||||
|
*/
|
||||||
|
void changeModus(DriveModi *modus = nullptr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Change the DriveModi to a specific value
|
* @brief Get the DriveModi Ptr object
|
||||||
*
|
*
|
||||||
* Sets MoveControl to a safe state, delete the last
|
* This is a pointer to the Object of the current DriveMode.
|
||||||
* DriveModi and than set the new DriveModi
|
* If you know which DriveMode is active, you can cast this
|
||||||
*
|
* pointer to it.
|
||||||
* @param modus
|
*
|
||||||
*/
|
* @see getDriveModi
|
||||||
void changeModus(DriveModi* modus = nullptr);
|
* @return DriveModi*
|
||||||
|
*/
|
||||||
|
DriveModi *getDriveModiPtr() const { return this->currentModusPtr; }
|
||||||
|
DrivingSpeeds &getDrivingSpeedsRef() { return this->drivingSpeeds; }
|
||||||
|
|
||||||
/**
|
bool isActive() const { return this->currentModusPtr; }
|
||||||
* @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() const { return this->currentModusPtr; }
|
|
||||||
DrivingSpeeds& getDrivingSpeedsRef() { return this->drivingSpeeds; }
|
|
||||||
|
|
||||||
bool isActive() const { return this->currentModusPtr; }
|
private:
|
||||||
|
void run() override{};
|
||||||
|
void init();
|
||||||
|
|
||||||
private:
|
DriveModi *currentModusPtr = nullptr;
|
||||||
void run() override {};
|
DriveModiParams driveModiParams;
|
||||||
void init();
|
DrivingSpeeds drivingSpeeds = {1, 7};
|
||||||
|
|
||||||
DriveModi *currentModusPtr = nullptr;
|
|
||||||
DriveModiParams driveModiParams;
|
|
||||||
DrivingSpeeds drivingSpeeds = {1, 7};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // DRIVE_MANAGER_H
|
#endif // DRIVE_MANAGER_H
|
||||||
|
|||||||
@@ -1,26 +1,30 @@
|
|||||||
#include "driveModi.h"
|
#include "driveModi.h"
|
||||||
|
|
||||||
DriveModi::~DriveModi() {
|
DriveModi::~DriveModi()
|
||||||
|
{
|
||||||
this->moveControl->setSpeed(0);
|
this->moveControl->setSpeed(0);
|
||||||
this->moveControl->setRotationSpeed(0);
|
this->moveControl->setRotationSpeed(0);
|
||||||
this->moveControl->setDrivingStatus(MoveControl::Status::Stop);
|
this->moveControl->setDrivingStatus(MoveControl::Status::Stop);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DriveModi::activate(MoveControl* moveControl, ControlPadInput* input, SensorData* sensorData) {
|
void DriveModi::activate(MoveControl *moveControl, ControlPadInput *input, SensorData *sensorData)
|
||||||
|
{
|
||||||
this->moveControl = moveControl;
|
this->moveControl = moveControl;
|
||||||
this->input = input;
|
this->input = input;
|
||||||
this->sensorData = sensorData;
|
this->sensorData = sensorData;
|
||||||
this->init();
|
this->init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DriveModi::activate(DriveModiParams params){
|
void DriveModi::activate(DriveModiParams params)
|
||||||
|
{
|
||||||
this->moveControl = params.moveControl;
|
this->moveControl = params.moveControl;
|
||||||
this->input = params.input;
|
this->input = params.input;
|
||||||
this->sensorData = params.sensorData;
|
this->sensorData = params.sensorData;
|
||||||
this->init();
|
this->init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DriveModi::init() {
|
void DriveModi::init()
|
||||||
|
{
|
||||||
this->moveControl->setDrivingStatus(MoveControl::Status::Drive);
|
this->moveControl->setDrivingStatus(MoveControl::Status::Drive);
|
||||||
this->loopDelay = DriveModi::defaultDelay;
|
this->loopDelay = DriveModi::defaultDelay;
|
||||||
this->afterActivate();
|
this->afterActivate();
|
||||||
|
|||||||
+47
-25
@@ -4,9 +4,9 @@
|
|||||||
* @brief Contains a virtual class for all Modi
|
* @brief Contains a virtual class for all Modi
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
* @date 2021-12-14
|
* @date 2021-12-14
|
||||||
*
|
*
|
||||||
* @copyright Copyright (c) 2021
|
* @copyright Copyright (c) 2021
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef DRIVEMODI_H
|
#ifndef DRIVEMODI_H
|
||||||
@@ -17,42 +17,64 @@
|
|||||||
#include "controlPadInput.h"
|
#include "controlPadInput.h"
|
||||||
#include "sensorData.h"
|
#include "sensorData.h"
|
||||||
|
|
||||||
struct DriveModiParams {
|
/**
|
||||||
MoveControl* moveControl;
|
* @brief The struct contains all objects needed by a DriveMode
|
||||||
const ControlPadInput* input;
|
*/
|
||||||
const SensorData* sensorData;
|
struct DriveModiParams
|
||||||
|
{
|
||||||
|
MoveControl *moveControl;
|
||||||
|
const ControlPadInput *input;
|
||||||
|
const SensorData *sensorData;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Baseclass to build DriveModi
|
* @brief Baseclass to build DriveModi
|
||||||
*
|
*
|
||||||
* This class must be inherited by other classes which want to be
|
* This class must be inherited by other classes which want to be
|
||||||
* act as a DriveModi, because the DriveModi structure uses polymorphism.
|
* act as a DriveModi, because the DriveModi structure uses polymorphism.
|
||||||
*/
|
*/
|
||||||
class DriveModi : public Component {
|
class DriveModi : public Component
|
||||||
public:
|
{
|
||||||
virtual ~DriveModi();
|
public:
|
||||||
|
virtual ~DriveModi();
|
||||||
|
|
||||||
const SensorData* getSensorData() const { return this->sensorData; }
|
const SensorData *getSensorData() const { return this->sensorData; }
|
||||||
|
|
||||||
void activate(MoveControl* moveControl, ControlPadInput* input, SensorData* sensorData);
|
/**
|
||||||
void activate(DriveModiParams params);
|
* @brief This activates a DriveMode
|
||||||
|
*
|
||||||
|
* This function have to be called to provide the DriveMode
|
||||||
|
* with this objects
|
||||||
|
*
|
||||||
|
* @param moveControl
|
||||||
|
* @param input
|
||||||
|
* @param sensorData
|
||||||
|
*/
|
||||||
|
void activate(MoveControl *moveControl, ControlPadInput *input, SensorData *sensorData);
|
||||||
|
void activate(DriveModiParams params);
|
||||||
|
|
||||||
void setSpeeds(DrivingSpeeds speeds) { this->maxSpeeds = speeds; }
|
void setSpeeds(DrivingSpeeds speeds) { this->maxSpeeds = speeds; }
|
||||||
DrivingSpeeds getSpeeds() const { return this->maxSpeeds; }
|
DrivingSpeeds getSpeeds() const { return this->maxSpeeds; }
|
||||||
DrivingSpeeds& getSpeedsRef() { return this->maxSpeeds; }
|
DrivingSpeeds &getSpeedsRef() { return this->maxSpeeds; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void afterActivate() {}
|
/**
|
||||||
|
* @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;
|
MoveControl *moveControl = nullptr;
|
||||||
DrivingSpeeds maxSpeeds = {1, 7};
|
DrivingSpeeds maxSpeeds = {1, 7};
|
||||||
const ControlPadInput* input = nullptr;
|
const ControlPadInput *input = nullptr;
|
||||||
const SensorData* sensorData = nullptr;
|
const SensorData *sensorData = nullptr;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
static constexpr uint8_t defaultDelay = 40;
|
static constexpr uint8_t defaultDelay = 40;
|
||||||
};
|
};
|
||||||
#endif // DRIVEMODI_H
|
#endif // DRIVEMODI_H
|
||||||
|
|||||||
+9
-9
@@ -92,14 +92,14 @@ void setup()
|
|||||||
lcd->clear();
|
lcd->clear();
|
||||||
lcd->noBacklight();
|
lcd->noBacklight();
|
||||||
|
|
||||||
network = new Network(static_cast<const char*>(NetworkConfig::ssid),
|
network = new Network(static_cast<const char *>(NetworkConfig::ssid),
|
||||||
static_cast<const char*>(NetworkConfig::password),
|
static_cast<const char *>(NetworkConfig::password),
|
||||||
setIPs());
|
setIPs());
|
||||||
network->activateEspNow(receiveCallback, sendCallback);
|
network->activateEspNow(receiveCallback, sendCallback);
|
||||||
if (NetworkConfig::mqtt)
|
if (NetworkConfig::mqtt)
|
||||||
{
|
{
|
||||||
if (network->activateMqtt(static_cast<const char*>(MqttConfig::user),
|
if (network->activateMqtt(static_cast<const char *>(MqttConfig::user),
|
||||||
static_cast<const char*>(MqttConfig::password)))
|
static_cast<const char *>(MqttConfig::password)))
|
||||||
{
|
{
|
||||||
DebugMqtt::init(network->getMqttClient(), Loglevel::debug);
|
DebugMqtt::init(network->getMqttClient(), Loglevel::debug);
|
||||||
debugMqtt = new DebugMqtt("Console");
|
debugMqtt = new DebugMqtt("Console");
|
||||||
@@ -125,11 +125,11 @@ void setup()
|
|||||||
sensorData = new SensorData();
|
sensorData = new SensorData();
|
||||||
sensorData->enableGnss(spiPort, PinNumbers::gnssSpiCs);
|
sensorData->enableGnss(spiPort, PinNumbers::gnssSpiCs);
|
||||||
sensorData->enableRealCompass();
|
sensorData->enableRealCompass();
|
||||||
sensorData->enableNtrip(static_cast<const char*>(NtripConfig::host),
|
sensorData->enableNtrip(static_cast<const char *>(NtripConfig::host),
|
||||||
NtripConfig::port,
|
NtripConfig::port,
|
||||||
static_cast<const char*>(NtripConfig::mountPoint),
|
static_cast<const char *>(NtripConfig::mountPoint),
|
||||||
static_cast<const char*>(NtripConfig::user),
|
static_cast<const char *>(NtripConfig::user),
|
||||||
static_cast<const char*>(NtripConfig::password));
|
static_cast<const char *>(NtripConfig::password));
|
||||||
// sensorData->enableGyroscope();
|
// sensorData->enableGyroscope();
|
||||||
driveManager = new DriveManager(&moveController, sensorData, controlPad->getControlPadDataPtr());
|
driveManager = new DriveManager(&moveController, sensorData, controlPad->getControlPadDataPtr());
|
||||||
|
|
||||||
|
|||||||
+12
-12
@@ -17,19 +17,19 @@ MoveControl::MoveControl()
|
|||||||
leftSpeedometer{new Speedometer(PinNumbers::LeftMotor::encoder, Settings::wheelDiameter, Settings::encoderSteps)},
|
leftSpeedometer{new Speedometer(PinNumbers::LeftMotor::encoder, Settings::wheelDiameter, Settings::encoderSteps)},
|
||||||
rightSpeedometer{new Speedometer(PinNumbers::RightMotor::encoder, Settings::wheelDiameter, Settings::encoderSteps)},
|
rightSpeedometer{new Speedometer(PinNumbers::RightMotor::encoder, Settings::wheelDiameter, Settings::encoderSteps)},
|
||||||
leftPid{new PID(&this->wheelspeedLeft,
|
leftPid{new PID(&this->wheelspeedLeft,
|
||||||
&this->leftPidOut,
|
&this->leftPidOut,
|
||||||
&this->wheelspeedLeftTarget,
|
&this->wheelspeedLeftTarget,
|
||||||
Settings::Pid::Left::P,
|
Settings::Pid::Left::P,
|
||||||
Settings::Pid::Left::I,
|
Settings::Pid::Left::I,
|
||||||
Settings::Pid::Left::D,
|
Settings::Pid::Left::D,
|
||||||
DIRECT)},
|
DIRECT)},
|
||||||
rightPid{new PID(&this->wheelspeedRight,
|
rightPid{new PID(&this->wheelspeedRight,
|
||||||
&this->rightPidOut,
|
&this->rightPidOut,
|
||||||
&this->wheelspeedRightTarget,
|
&this->wheelspeedRightTarget,
|
||||||
Settings::Pid::Right::P,
|
Settings::Pid::Right::P,
|
||||||
Settings::Pid::Right::I,
|
Settings::Pid::Right::I,
|
||||||
Settings::Pid::Right::D,
|
Settings::Pid::Right::D,
|
||||||
DIRECT)}
|
DIRECT)}
|
||||||
{
|
{
|
||||||
this->leftPid->SetOutputLimits(Settings::Pid::outMin, Settings::Pid::outMax);
|
this->leftPid->SetOutputLimits(Settings::Pid::outMin, Settings::Pid::outMax);
|
||||||
this->leftPid->SetSampleTime(Settings::Pid::sampleTime);
|
this->leftPid->SetSampleTime(Settings::Pid::sampleTime);
|
||||||
|
|||||||
Reference in New Issue
Block a user