documentation checked and edit
for all files in lib folder
This commit is contained in:
Vendored
+5
@@ -123,11 +123,13 @@
|
||||
"Ahnung",
|
||||
"akku",
|
||||
"ardui",
|
||||
"Baseclass",
|
||||
"blox",
|
||||
"bluedroid",
|
||||
"carr",
|
||||
"CIPO",
|
||||
"COPI",
|
||||
"Doxygen",
|
||||
"Dutycycle",
|
||||
"gast",
|
||||
"GNSS",
|
||||
@@ -137,9 +139,12 @@
|
||||
"Keine",
|
||||
"kleiax",
|
||||
"Lebennig",
|
||||
"microcontroller",
|
||||
"MQTT",
|
||||
"NMEA",
|
||||
"NMEAGPGGA",
|
||||
"NTRIP",
|
||||
"pcnt",
|
||||
"pidl",
|
||||
"pidr",
|
||||
"Punica",
|
||||
|
||||
@@ -51,7 +51,7 @@ PROJECT_BRIEF = "A small verhicle which should be drive a route with GP
|
||||
# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy
|
||||
# the logo to the output directory.
|
||||
|
||||
PROJECT_LOGO = C:/Users/alex1/git/projektarbeit/doc/Doxygen/logo.png
|
||||
PROJECT_LOGO = logo.png
|
||||
|
||||
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path
|
||||
# into which the generated documentation will be written. If a relative path is
|
||||
@@ -606,7 +606,7 @@ HIDE_COMPOUND_REFERENCE= NO
|
||||
# will show which file needs to be included to use the class.
|
||||
# The default value is: YES.
|
||||
|
||||
SHOW_HEADERFILE = YES
|
||||
# SHOW_HEADERFILE = YES
|
||||
|
||||
# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of
|
||||
# the files that are included by a file in the documentation of that file.
|
||||
@@ -824,7 +824,7 @@ WARN_IF_DOC_ERROR = YES
|
||||
# parameters have no documentation without warning.
|
||||
# The default value is: YES.
|
||||
|
||||
WARN_IF_INCOMPLETE_DOC = YES
|
||||
# WARN_IF_INCOMPLETE_DOC = YES
|
||||
|
||||
# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that
|
||||
# are documented, but have no documentation for their parameters or return
|
||||
@@ -1608,7 +1608,7 @@ GENERATE_TREEVIEW = YES
|
||||
# The default value is: NO.
|
||||
# This tag requires that the tag GENERATE_HTML is set to YES.
|
||||
|
||||
FULL_SIDEBAR = NO
|
||||
# FULL_SIDEBAR = NO
|
||||
|
||||
# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that
|
||||
# doxygen will group on one line in the generated HTML documentation.
|
||||
@@ -1691,7 +1691,7 @@ USE_MATHJAX = NO
|
||||
# The default value is: MathJax_2.
|
||||
# This tag requires that the tag USE_MATHJAX is set to YES.
|
||||
|
||||
MATHJAX_VERSION = MathJax_2
|
||||
# MATHJAX_VERSION = MathJax_2
|
||||
|
||||
# When MathJax is enabled you can set the default output format to be used for
|
||||
# the MathJax output. For more details about the output format see MathJax
|
||||
|
||||
@@ -28,6 +28,8 @@ Do later:
|
||||
-> update sparkfun gnss auf v3 für SPI korrekturdatenüvbetragung
|
||||
-> Rover Objekt mit Error zustand freeze, damit das wenn möglich auch auf dem Display angezeigt wird.
|
||||
-> ESP und Sensoren in den DeepSleep für Auschalten oder Akkuschutz
|
||||
-> Doxygen comments
|
||||
- navigation
|
||||
|
||||
|
||||
Do now:
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
void KomponenteA::loop() {
|
||||
this->komponenteB->loop();
|
||||
this->komponenteC->loop();
|
||||
|
||||
if (millis() - this->lastMillis < this->delayMillis)
|
||||
return;
|
||||
|
||||
this->doSomething();
|
||||
}
|
||||
+2
-3
@@ -1,9 +1,8 @@
|
||||
|
||||
// AUTO GENERATED FILE, DO NOT EDIT
|
||||
#ifndef VERSION
|
||||
#define VERSION "0.8.36"
|
||||
#define VERSION "1.8.36"
|
||||
#endif
|
||||
#ifndef BUILD_TIMESTAMP
|
||||
#define BUILD_TIMESTAMP "2023-08-13 15:13:34.491991"
|
||||
#define BUILD_TIMESTAMP "2023-10-13 15:13:34.491991"
|
||||
#endif
|
||||
|
||||
+16
-12
@@ -22,12 +22,12 @@
|
||||
#include "debugTimes.h"
|
||||
#include "component.h"
|
||||
|
||||
|
||||
/**
|
||||
* @brief A struct to easy set the speed
|
||||
*
|
||||
*/
|
||||
struct DrivingSpeeds {
|
||||
struct DrivingSpeeds
|
||||
{
|
||||
double x;
|
||||
double rot;
|
||||
};
|
||||
@@ -40,23 +40,27 @@ struct DrivingSpeeds {
|
||||
* given target speed to calculate a new duty cycle for the motors.
|
||||
*
|
||||
*/
|
||||
class MoveControl : public Component {
|
||||
class MoveControl : public Component
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief used to set driving status
|
||||
* @brief Used to set driving status
|
||||
*
|
||||
* When set to stop all motors are set to halt
|
||||
*
|
||||
* When set to Raw the PIDs are not used. The target
|
||||
* values must be given withe @see setRawPowerLeft and
|
||||
* @see setRawPowerRight.
|
||||
* values must be given withe setRawPowerLeft() and
|
||||
* setRawPowerRight().
|
||||
*
|
||||
* Drive is the normal working mode.
|
||||
*
|
||||
*/
|
||||
enum Status {Stop,
|
||||
enum Status
|
||||
{
|
||||
Stop,
|
||||
Drive,
|
||||
Raw};
|
||||
|
||||
Raw
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Construct a new Move Control object
|
||||
@@ -111,10 +115,11 @@ class MoveControl : public Component {
|
||||
/**
|
||||
* @brief Set the speeds
|
||||
*
|
||||
* This function is a combination of @see setSpeed and
|
||||
* @see setRotationSpeed. The struct @see DrivingSpeeds
|
||||
* This function is a combination of the functions setSpeed() and
|
||||
* setRotationSpeed(). The struct DrivingSpeeds
|
||||
* is used for this.
|
||||
*
|
||||
*
|
||||
* @param drivingSpeeds
|
||||
*/
|
||||
void setSpeeds(DrivingSpeeds drivingSpeeds);
|
||||
@@ -194,6 +199,5 @@ class MoveControl : public Component {
|
||||
static constexpr int8_t maxPercentage = 100;
|
||||
static constexpr float minSpeed = 0.2;
|
||||
static constexpr uint8_t loopDelay = 20;
|
||||
|
||||
};
|
||||
#endif // MOVE_CONTROL_H
|
||||
|
||||
+10
-5
@@ -17,7 +17,8 @@
|
||||
#define HW1
|
||||
|
||||
#ifdef HOTSPOT
|
||||
namespace NetworkConfig {
|
||||
namespace NetworkConfig
|
||||
{
|
||||
const char ssid[] = "Kleiax Handy";
|
||||
const char password[] = "12345677";
|
||||
const char ip[] = "192.168.43.4";
|
||||
@@ -29,7 +30,8 @@ namespace NetworkConfig {
|
||||
#endif // HOTSPOT
|
||||
|
||||
#ifdef HW1
|
||||
namespace NetworkConfig {
|
||||
namespace NetworkConfig
|
||||
{
|
||||
const char ssid[] = "hw1_gast";
|
||||
const char password[] = "KeineAhnung";
|
||||
const char ip[] = "192.168.0.4";
|
||||
@@ -42,7 +44,8 @@ namespace NetworkConfig {
|
||||
|
||||
// Network config Rhede
|
||||
#ifdef RHEDE
|
||||
namespace NetworkConfig {
|
||||
namespace NetworkConfig
|
||||
{
|
||||
const char ssid[] = "LebennigHuus";
|
||||
const char password[] = "Punica-699";
|
||||
const char ip[] = "192.168.11.4";
|
||||
@@ -53,14 +56,16 @@ namespace NetworkConfig {
|
||||
}
|
||||
#endif // RHEDE
|
||||
|
||||
namespace MqttConfig {
|
||||
namespace MqttConfig
|
||||
{
|
||||
const char server[] = "192.168.1.7";
|
||||
const uint16_t port = 1883;
|
||||
const char user[] = "kleiax";
|
||||
const char password[] = "p?{$_~5%hBM7wrcFkr55KWr#";
|
||||
}
|
||||
|
||||
namespace NtripConfig {
|
||||
namespace NtripConfig
|
||||
{
|
||||
const char host[] = "rtk2go.com";
|
||||
const uint16_t port = 2101;
|
||||
// const char mountPoint[] = "GER-Dortmund";
|
||||
|
||||
@@ -37,12 +37,12 @@ void Battery::run()
|
||||
this->readAdcToBuf();
|
||||
this->loopCounter++;
|
||||
|
||||
if (this->loopCounter >= this->calulationDelayMultiplier)
|
||||
if (this->loopCounter >= this->calculateDelayMultiplier)
|
||||
{
|
||||
this->calculateBatteryVoltage();
|
||||
this->calculateBatteryPercent();
|
||||
this->loopCounter = 0;
|
||||
this->calculatetNewValues = true;
|
||||
this->calculatedNewValues = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,12 +89,12 @@ bool Battery::isBatteryLow(double voltage) const
|
||||
|
||||
bool Battery::isNewValue()
|
||||
{
|
||||
if (!this->calculatetNewValues)
|
||||
if (!this->calculatedNewValues)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
this->calculatetNewValues = false;
|
||||
this->calculatedNewValues = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ double Battery::calculateInputVoltage()
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -this->adcCurveCoeficient[0] * pow(reading, 4) + this->adcCurveCoeficient[1] * pow(reading, 3) - this->adcCurveCoeficient[2] * pow(reading, 2) + this->adcCurveCoeficient[3] * reading + this->adcCurveCoeficient[4];
|
||||
return -this->adcCurveCoefficient[0] * pow(reading, 4) + this->adcCurveCoefficient[1] * pow(reading, 3) - this->adcCurveCoefficient[2] * pow(reading, 2) + this->adcCurveCoefficient[3] * reading + this->adcCurveCoefficient[4];
|
||||
}
|
||||
|
||||
void Battery::calculateBatteryVoltage()
|
||||
|
||||
+62
-7
@@ -24,12 +24,20 @@
|
||||
*
|
||||
* This class reads the voltage from an analog pin to calculate the
|
||||
* charge level of a 3 Cell Li-Poly battery pack. The battery pack have
|
||||
* to be after a voltage diveder, so that maximum voltage for the
|
||||
* to be after a voltage divider, so that maximum voltage for the
|
||||
* microcontroller is 3.3 Volt.
|
||||
*/
|
||||
class Battery : public Component
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief States when the calibration modes is active
|
||||
*
|
||||
* - None means that no calibration is running
|
||||
* - Reading means that the adc takes multiple values to calculate an average
|
||||
* - Waiting means that the user has to set the new wanted voltage
|
||||
* - Finished means that all measurements was taken
|
||||
*/
|
||||
enum CalibrationState
|
||||
{
|
||||
None,
|
||||
@@ -41,15 +49,25 @@ public:
|
||||
/**
|
||||
* @brief Construct a new Battery object
|
||||
*
|
||||
* The voltage devider have to be calculated, so that the input
|
||||
* The voltage divider have to be calculated, so that the input
|
||||
* voltage from 3.3 Volt is never exceeded. It is assumed that
|
||||
* the microcontroller is connected to the second resistor.
|
||||
*
|
||||
* @param pin The analog to read from.
|
||||
* @param firstResistor First resistor of the voltage devider.
|
||||
* @param secondResistor Second resistor of the voltage devider.
|
||||
* @param firstResistor First resistor of the voltage divider.
|
||||
* @param secondResistor Second resistor of the voltage divider.
|
||||
*/
|
||||
Battery(uint8_t pin, uint32_t firstResistor, uint32_t secondResistor);
|
||||
|
||||
/**
|
||||
* @brief Construct a new Battery object
|
||||
*
|
||||
* With this constructor the real voltage is not calculated with the
|
||||
* voltage divider but with a table which contains the raw reading from
|
||||
* the adc mapped to a specific voltage
|
||||
*
|
||||
* @param pin
|
||||
*/
|
||||
Battery(uint8_t pin);
|
||||
|
||||
/**
|
||||
@@ -79,13 +97,50 @@ public:
|
||||
*/
|
||||
bool isBatteryLow(double voltage) const;
|
||||
|
||||
/**
|
||||
* @brief Check if a new voltage was been calculated
|
||||
*
|
||||
* @return true
|
||||
* @return false
|
||||
*/
|
||||
bool isNewValue();
|
||||
|
||||
// Calibration
|
||||
CalibrationState getCalibrationState() const { return this->calibrationState; }
|
||||
|
||||
/**
|
||||
* @brief Get the current calibration voltage target
|
||||
*
|
||||
* The returned value stand for the index of the table for this reason
|
||||
* the real value have to be calculated. After the returned voltage has been set
|
||||
* you have to call nextVoltageIsReady().
|
||||
*
|
||||
* @return uint8_t voltage multiply with 0,1 and add 7
|
||||
*/
|
||||
uint8_t getCurrentCalibrationVoltage() const { return this->currentCalibrationVoltage; }
|
||||
|
||||
/**
|
||||
* @brief Read next wanted voltage
|
||||
*
|
||||
* If this function is called, the calibration mode reads the new voltage
|
||||
* and save the value in the table.
|
||||
*/
|
||||
void nextVoltageIsReady();
|
||||
|
||||
/**
|
||||
* @brief Calibrate the battery readings
|
||||
*
|
||||
* This calibration has only an effect if the Component
|
||||
* uses the table with the raw adc values. The calibration gives
|
||||
* the user different voltages that have to be set with a
|
||||
* laboratory power supply. The power supply have to be connected
|
||||
* instead of the battery.
|
||||
*/
|
||||
void startCalibration();
|
||||
|
||||
/**
|
||||
* @brief abort the calibration
|
||||
*/
|
||||
void finishCalibration();
|
||||
|
||||
private:
|
||||
@@ -109,14 +164,14 @@ private:
|
||||
uint8_t batteryPercent = 0;
|
||||
uint8_t batteryLowPercent = 10;
|
||||
uint8_t bufferPos = 0;
|
||||
uint8_t calulationDelayMultiplier = 5;
|
||||
uint8_t calculateDelayMultiplier = 5;
|
||||
uint8_t loopCounter = 0;
|
||||
uint8_t currentCalibrationVoltage = 0; // *0.1 + 7
|
||||
uint16_t adcBuffer[bufferSize];
|
||||
uint16_t *newRawAdcVoltages = nullptr;
|
||||
uint32_t firstResistor = 0;
|
||||
uint32_t secondResistor = 0;
|
||||
bool calculatetNewValues = false;
|
||||
bool calculatedNewValues = false;
|
||||
double batteryVoltage = 0;
|
||||
double batteryVoltageFactor;
|
||||
|
||||
@@ -137,7 +192,7 @@ private:
|
||||
2920, 2956, 2983, 3019, 3054, 3088, 3121, 3158, 3189, 3226,
|
||||
3264, 3300, 3339, 3379, 3414, 3453, 3500, 3544, 3598, 3636,
|
||||
3682, 3730, 3781, 3837, 3887, 3943, 3997, 4054, 4093, 4095};
|
||||
const double adcCurveCoeficient[5] = {0.000000000000016,
|
||||
const double adcCurveCoefficient[5] = {0.000000000000016,
|
||||
0.000000000118171,
|
||||
0.000000301211691,
|
||||
0.001109019271794,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file calcAzimuth.h
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief
|
||||
* @brief Contains a class that calculates the azimuth from a last and a current position
|
||||
* @version 0.1
|
||||
* @date 2023-09-03
|
||||
*
|
||||
@@ -15,9 +15,18 @@
|
||||
#include "component.h"
|
||||
#include "point.h"
|
||||
|
||||
/**
|
||||
* @brief A class to calculate an azimuth
|
||||
*
|
||||
* This class calculates the current Azimuth with the last position
|
||||
* where the rover has been rotated and the current position
|
||||
*/
|
||||
class CalcAzimuth : public Component
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief States which represent the quality of the current calculated azimuth
|
||||
*/
|
||||
enum State
|
||||
{
|
||||
Invalid,
|
||||
@@ -27,13 +36,40 @@ public:
|
||||
Super
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Construct a new Calc Azimuth object
|
||||
*
|
||||
* @param point current position
|
||||
*/
|
||||
CalcAzimuth(Point point);
|
||||
|
||||
/**
|
||||
* @brief Have to be called if the rover rotates
|
||||
*
|
||||
* @param point current position
|
||||
*/
|
||||
void drivingDirectionChange(Point point);
|
||||
|
||||
/**
|
||||
* @brief update the current position
|
||||
*
|
||||
* This function should be called if the rover has moved in
|
||||
* a straight direction, to calculated the current Azimuth.
|
||||
* More distance to the point given to drivingDirectionChange()
|
||||
* increase the accuracy of the calculation.
|
||||
*
|
||||
* @param point current position
|
||||
*/
|
||||
void updateCurrentPosition(Point point);
|
||||
void disableCalcAzimuth() { this->directionChangeMode = false; }
|
||||
|
||||
int16_t getAzimuth() const { return this->calcAzimuth; }
|
||||
|
||||
/**
|
||||
* @brief Get the State struct
|
||||
*
|
||||
* @return State current quality of the calculation
|
||||
*/
|
||||
State getState() const { return this->state; }
|
||||
|
||||
static String stateToString(State state);
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
/**
|
||||
* @file calibrateCompass.h
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief Contains a class to calibrate the compass module
|
||||
* @version 0.1
|
||||
* @date 2023-05-23
|
||||
*
|
||||
* @copyright Copyright (c) 2023
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QMC5883LCompass.h>
|
||||
#include <Preferences.h>
|
||||
#include <iostream>
|
||||
|
||||
#include "component.h"
|
||||
|
||||
/**
|
||||
* @brief A Class to calibrate the compass
|
||||
*
|
||||
* This class reads the raw values of the compass while
|
||||
* the rove have to be moved. The lowest and highest values
|
||||
* are used to calibrate the compass to the current location.
|
||||
*/
|
||||
class CalibrateCompass : public Component
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief State of the calibration process
|
||||
*/
|
||||
enum State
|
||||
{
|
||||
Ready,
|
||||
Calibrating,
|
||||
Finished
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Type for calibration data
|
||||
*
|
||||
* The data consist of 6 values. For each for the 3 axis
|
||||
* are to integer needed.
|
||||
*/
|
||||
struct CalibrationData
|
||||
{
|
||||
int data[3][2];
|
||||
};
|
||||
|
||||
CalibrateCompass(QMC5883LCompass *compass);
|
||||
|
||||
/**
|
||||
* @brief Starts the calibration
|
||||
*/
|
||||
void start();
|
||||
|
||||
/**
|
||||
* @brief Use the measured calibration data
|
||||
*/
|
||||
void useData();
|
||||
|
||||
/**
|
||||
* @brief Remove the measured calibration data
|
||||
*/
|
||||
void removeCalibration();
|
||||
|
||||
/**
|
||||
* @brief Reset the calibration process to start again
|
||||
*/
|
||||
void reset();
|
||||
|
||||
/**
|
||||
* @brief Save the measured calibration data to the flash
|
||||
*/
|
||||
void saveData();
|
||||
|
||||
/**
|
||||
* @brief Load the measured calibration data from the flash
|
||||
*
|
||||
*/
|
||||
void loadData();
|
||||
|
||||
State getState() const { return this->state; }
|
||||
CalibrationData getCalibrationData() const { return this->data; }
|
||||
|
||||
/**
|
||||
* @brief Makes the calibration data printable with std::cout()
|
||||
*
|
||||
* @param stream
|
||||
* @param caliComp
|
||||
* @return std::ostream&
|
||||
*/
|
||||
friend std::ostream &operator<<(std::ostream &stream, const CalibrateCompass &caliComp);
|
||||
|
||||
private:
|
||||
void runAsChild() override;
|
||||
void run() override;
|
||||
void checkDataValidity();
|
||||
|
||||
QMC5883LCompass *compass;
|
||||
State state = State::Ready;
|
||||
CalibrationData data{};
|
||||
|
||||
void clearData();
|
||||
|
||||
bool dataValid = false;
|
||||
const uint16_t maxTimeWithoutChange = 10000;
|
||||
uint32_t lastChange = 0;
|
||||
};
|
||||
@@ -19,7 +19,7 @@ void Component::loop()
|
||||
(*it)->loop();
|
||||
}
|
||||
}
|
||||
this->runAsChild();
|
||||
this->runAsChild();F
|
||||
|
||||
if (this->onlyChilds)
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file component.h
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief
|
||||
* @brief Contains an interface to make non blocking components with delay.
|
||||
* @version 0.1
|
||||
* @date 2023-08-16
|
||||
*
|
||||
@@ -15,31 +15,123 @@
|
||||
|
||||
#include <list>
|
||||
|
||||
/**
|
||||
* @brief An Interface to make components
|
||||
*
|
||||
* A component is a task that be called in a loop which not
|
||||
* runs every loop, so every component has a non blocking delay.
|
||||
*
|
||||
* A component can manage other components which called children components.
|
||||
*/
|
||||
class Component
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a new Component object
|
||||
*
|
||||
* With the default constructor the created component is
|
||||
* by default inactive. This does not affect the execution of
|
||||
* the children components.
|
||||
*/
|
||||
Component() {}
|
||||
|
||||
/**
|
||||
* @brief Construct a new Component object
|
||||
*
|
||||
* If the given parameter is zero, there are no differences to the
|
||||
* default constructor.
|
||||
*
|
||||
* @param loopDelay the minimum time in milliseconds before the task runs
|
||||
*/
|
||||
Component(uint16_t loopDelay);
|
||||
|
||||
/**
|
||||
* @brief Runs the children components and the task
|
||||
*
|
||||
* The loop() function of the children is called every time this
|
||||
* loop is called.
|
||||
*
|
||||
* The run() function which presents the task of this component is
|
||||
* only called if the delay is reached.
|
||||
*/
|
||||
void loop();
|
||||
|
||||
/**
|
||||
* @brief Deactivate this component
|
||||
*
|
||||
* If the component is deactivated the call of loop() ha no effect
|
||||
*/
|
||||
void deactivate() { this->active = false; }
|
||||
void activate() { this->active = false; }
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief Override this function to avoid the delay
|
||||
*/
|
||||
virtual void runAsChild() {}
|
||||
|
||||
/**
|
||||
* @brief Runs befor the run() function
|
||||
*
|
||||
* This function is only called, if the delay
|
||||
* is reached.
|
||||
* The function do nothing, except the function is overwritten
|
||||
* by the class which inherits this class.
|
||||
*/
|
||||
virtual void beforeRun() {}
|
||||
|
||||
/**
|
||||
* @brief The actual task
|
||||
*
|
||||
* This function have to be overwritten by the inheriting class.
|
||||
*/
|
||||
virtual void run() = 0;
|
||||
|
||||
/**
|
||||
* @brief Runs after the run() function
|
||||
*
|
||||
* This function is only called, if the delay
|
||||
* is reached.
|
||||
* The function do nothing, except the function is overwritten
|
||||
* by the class which inherits this class.
|
||||
*/
|
||||
virtual void afterRun() {}
|
||||
|
||||
/**
|
||||
* @brief Adds a child component
|
||||
*
|
||||
* The child component will be called every time the loop() function
|
||||
* is called.
|
||||
*
|
||||
* @param child
|
||||
*/
|
||||
void addChildComponent(Component *child);
|
||||
void removeChildComponent(Component *child);
|
||||
|
||||
void activateOnlyChilds() { this->onlyChilds = true; }
|
||||
|
||||
/**
|
||||
* @brief Skip the actual task
|
||||
*
|
||||
* Same as set the loopDelay to zero.
|
||||
*/
|
||||
void deactivateOnlyChilds() { this->onlyChilds = false; }
|
||||
|
||||
/**
|
||||
* @brief Set the timer after task
|
||||
*
|
||||
* If this function is called once the measurement of the delay
|
||||
* starts after task has finished. The default is, that the
|
||||
* measurement begins at the start of the task.
|
||||
*/
|
||||
void setTimerAfterTask() { this->timeUpdateAfter = true; }
|
||||
|
||||
/**
|
||||
* @brief the minimum time in milliseconds before the task runs
|
||||
*
|
||||
* If this value is zero, the functions beforeRun(), run() and
|
||||
* afterRun() would not be called
|
||||
*/
|
||||
uint16_t loopDelay = 0;
|
||||
|
||||
private:
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
#include "controlPad.h"
|
||||
|
||||
ControlPad::ControlPad() : Component(5), controlInput{0, 0, 0, 0} {}
|
||||
ControlPad::ControlPad() : Component(10), controlInput{0, 0, 0, 0} {}
|
||||
|
||||
void ControlPad::run()
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file controlPad.h
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief
|
||||
* @brief Contains a class that gets the input data
|
||||
* @version 0.1
|
||||
* @date 2023-03-30
|
||||
*
|
||||
@@ -16,15 +16,46 @@
|
||||
#include <controlPadInput.h>
|
||||
#include <component.h>
|
||||
|
||||
/**
|
||||
* @brief A class to manage inputs
|
||||
*
|
||||
* This class converts the incoming data to the buttons and
|
||||
* the axis from the joystick. The converted data will be send
|
||||
* to the menu.
|
||||
*/
|
||||
class ControlPad : public Component
|
||||
{
|
||||
public:
|
||||
ControlPad();
|
||||
|
||||
/**
|
||||
* @brief Insert the incoming data to convert
|
||||
*
|
||||
* The data is converted to the ControlPadInput struct.
|
||||
*
|
||||
* @param data have to be 4 byte long
|
||||
*/
|
||||
void insertData(const uint8_t *data);
|
||||
|
||||
/**
|
||||
* @brief Set the MenuControl object
|
||||
*
|
||||
* The MenuControl object is used to control the Menu.
|
||||
*
|
||||
* @see Menu
|
||||
* @see ControlPadInput
|
||||
*
|
||||
* @param menuControl
|
||||
*/
|
||||
void setMenuControl(MenuControl *menuControl) { this->menuControl = menuControl; }
|
||||
|
||||
/**
|
||||
* @brief Get the Control Pad Data
|
||||
*
|
||||
* The pointer holds the lates data from the ControlPad
|
||||
*
|
||||
* @return const ControlPadInput*
|
||||
*/
|
||||
const ControlPadInput *getControlPadDataPtr() const { return &this->controlInput; }
|
||||
|
||||
bool isControlPadConnected() const { return this->connected; }
|
||||
|
||||
+45
-1
@@ -1,21 +1,65 @@
|
||||
/**
|
||||
* @file counter.h
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief Contains a class that abstract the hardware counter from the esp32
|
||||
* @version 0.1
|
||||
* @date 2023-10-12
|
||||
*
|
||||
* @copyright Copyright (c) 2023
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <driver/pcnt.h>
|
||||
#include <cinttypes>
|
||||
|
||||
/**
|
||||
* @brief A class that abstract the hardware counter from the esp32
|
||||
*/
|
||||
class Counter
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a new Counter object
|
||||
*
|
||||
* @param pin with incoming pulses
|
||||
*/
|
||||
Counter(uint8_t pin);
|
||||
|
||||
/**
|
||||
* @brief Pause the pulse counting
|
||||
*/
|
||||
void pause();
|
||||
|
||||
/**
|
||||
* @brief Resume the pulse counting
|
||||
*/
|
||||
void resume();
|
||||
|
||||
/**
|
||||
* @brief Start counting by zero again
|
||||
*/
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* @brief Get the counted pulses
|
||||
*
|
||||
* @return int16_t
|
||||
*/
|
||||
int16_t getValue() const;
|
||||
|
||||
/**
|
||||
* @brief Set the filter value
|
||||
*
|
||||
* The filter skip all pulses after a pulse for the filter time.
|
||||
* The filter time depends on the frequency of the processor. The time
|
||||
* for a whole tact multiplied with the filter value results the filter time.
|
||||
*
|
||||
* @param value max 1023
|
||||
*/
|
||||
void setFilterValue(uint16_t value);
|
||||
|
||||
void filterEnable();
|
||||
void filterDisable();
|
||||
|
||||
@@ -26,7 +70,7 @@ private:
|
||||
|
||||
static uint8_t amountOfCounter;
|
||||
|
||||
bool initalised = false;
|
||||
bool initalized = false;
|
||||
|
||||
uint8_t pulsePin;
|
||||
pcnt_unit_t unit;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @file displayWrapper.cpp
|
||||
* @file LcdWrapper.cpp
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief Contains the implementation of the class LcdWrapper
|
||||
* @version 0.1
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @file displayWrapper.h
|
||||
* @file LcdWrapper.h
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief Contains the LcdWrapper class
|
||||
* @version 0.1
|
||||
@@ -37,7 +37,6 @@ public:
|
||||
|
||||
/**
|
||||
* @brief Empty the buffer
|
||||
*
|
||||
*/
|
||||
void clear() override;
|
||||
|
||||
|
||||
+30
-17
@@ -17,76 +17,90 @@ bool DebugMqtt::isInit = false;
|
||||
char DebugMqtt::msg[MQTT_BUFFER_SIZE];
|
||||
char DebugMqtt::topic[MQTT_BUFFER_SIZE];
|
||||
|
||||
|
||||
DebugMqtt::DebugMqtt(const char *name, uint8_t bufSize)
|
||||
: name{name}
|
||||
{
|
||||
if (bufSize != 0) {
|
||||
if (bufSize != 0)
|
||||
{
|
||||
this->bufSize = bufSize;
|
||||
}
|
||||
this->buf = new char[this->bufSize];
|
||||
}
|
||||
|
||||
DebugMqtt::~DebugMqtt() {
|
||||
DebugMqtt::~DebugMqtt()
|
||||
{
|
||||
delete this->buf;
|
||||
}
|
||||
|
||||
void DebugMqtt::sendMsg(Loglevel loglevel, String topic, String msg) {
|
||||
void DebugMqtt::sendMsg(Loglevel loglevel, String topic, String msg)
|
||||
{
|
||||
snprintf(static_cast<char *>(DebugMqtt::msg), MQTT_BUFFER_SIZE, static_cast<const char *>("%s: %s"), this->name, msg.c_str());
|
||||
this->sendData(loglevel, topic, static_cast<const char *>(DebugMqtt::msg));
|
||||
}
|
||||
|
||||
void DebugMqtt::sendMsg(Loglevel loglevel, String msg) {
|
||||
void DebugMqtt::sendMsg(Loglevel loglevel, String msg)
|
||||
{
|
||||
this->sendMsg(loglevel, "", msg);
|
||||
}
|
||||
|
||||
void DebugMqtt::sendData(Loglevel loglevel, String topic, String data) {
|
||||
if (!DebugMqtt::isInit) {
|
||||
void DebugMqtt::sendData(Loglevel loglevel, String topic, String data)
|
||||
{
|
||||
if (!DebugMqtt::isInit)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (loglevel <= DebugMqtt::loglevel && loglevel > Loglevel::none) {
|
||||
if (loglevel <= DebugMqtt::loglevel && loglevel > Loglevel::none)
|
||||
{
|
||||
snprintf(static_cast<char *>(DebugMqtt::topic), MQTT_BUFFER_SIZE, static_cast<const char *>("%s%s"), DebugMqtt::enum_to_string(loglevel).c_str(), topic.c_str());
|
||||
snprintf(static_cast<char *>(DebugMqtt::msg), MQTT_BUFFER_SIZE, static_cast<const char *>("%s"), data.c_str());
|
||||
client->publish(DebugMqtt::topic, static_cast<const char *>(DebugMqtt::msg));
|
||||
}
|
||||
}
|
||||
|
||||
void DebugMqtt::sendData(Loglevel loglevel, String data){
|
||||
void DebugMqtt::sendData(Loglevel loglevel, String data)
|
||||
{
|
||||
DebugMqtt::sendData(loglevel, "", data);
|
||||
}
|
||||
|
||||
void DebugMqtt::writeToInflux(String measurement_name, String field_set, float measurement, uint64_t nanos) {
|
||||
void DebugMqtt::writeToInflux(String measurement_name, String field_set, float measurement, uint64_t nanos)
|
||||
{
|
||||
// Example String: "weather temperature=82 1465839830100400200";
|
||||
|
||||
snprintf(static_cast<char *>(DebugMqtt::msg), MQTT_BUFFER_SIZE, static_cast<const char *>("%s %s=%f %llu"), measurement_name.c_str(), field_set.c_str(), measurement, nanos);
|
||||
this->sendData(Loglevel::influx, static_cast<const char *>(DebugMqtt::msg));
|
||||
}
|
||||
|
||||
void DebugMqtt::addCharacter(char character) {
|
||||
void DebugMqtt::addCharacter(char character)
|
||||
{
|
||||
this->buf[this->bufPos] = character;
|
||||
this->bufPos++;
|
||||
if (character == '\n' || this->bufPos >= this->bufSize - 1) {
|
||||
if (character == '\n' || this->bufPos >= this->bufSize - 1)
|
||||
{
|
||||
this->buf[this->bufPos - 1] = '\0';
|
||||
this->sendMsg(Loglevel::info, buf);
|
||||
this->bufPos = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void DebugMqtt::init(PubSubClient *client, Loglevel max_loglevel) {
|
||||
void DebugMqtt::init(PubSubClient *client, Loglevel max_loglevel)
|
||||
{
|
||||
DebugMqtt::client = client;
|
||||
DebugMqtt::loglevel = max_loglevel;
|
||||
DebugMqtt::isInit = true;
|
||||
}
|
||||
|
||||
void DebugMqtt::changeLoglevel(Loglevel loglevel) {
|
||||
void DebugMqtt::changeLoglevel(Loglevel loglevel)
|
||||
{
|
||||
DebugMqtt::loglevel = loglevel;
|
||||
}
|
||||
|
||||
String DebugMqtt::enum_to_string(Loglevel loglevel) {
|
||||
String DebugMqtt::enum_to_string(Loglevel loglevel)
|
||||
{
|
||||
String topic = "";
|
||||
topic += MQTT_DEBUG_TOPIC;
|
||||
switch(loglevel){
|
||||
switch (loglevel)
|
||||
{
|
||||
case Loglevel::error:
|
||||
topic += "/Error";
|
||||
break;
|
||||
@@ -108,4 +122,3 @@ String DebugMqtt::enum_to_string(Loglevel loglevel) {
|
||||
}
|
||||
return topic;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
#include <iostream>
|
||||
#include <PubSubClient.h>
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
@@ -48,12 +47,15 @@
|
||||
* @see sendData()
|
||||
*
|
||||
*/
|
||||
enum Loglevel { none,
|
||||
enum Loglevel
|
||||
{
|
||||
none,
|
||||
error,
|
||||
warn,
|
||||
info,
|
||||
debug,
|
||||
influx};
|
||||
influx
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A class to send debug messages over MQTT
|
||||
@@ -64,7 +66,8 @@ enum Loglevel { none,
|
||||
*
|
||||
* @see Loglevel
|
||||
*/
|
||||
class DebugMqtt {
|
||||
class DebugMqtt
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a new Debug Mqtt object.
|
||||
|
||||
@@ -52,9 +52,10 @@ public:
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Construct a new Navigation object and using I2C
|
||||
* @brief Construct a new Navigation object
|
||||
*
|
||||
* @param route with which to navigate
|
||||
* @param sensorData
|
||||
* @param route
|
||||
*/
|
||||
Navigation(const SensorData *sensorData, Route *route = nullptr);
|
||||
|
||||
@@ -89,11 +90,9 @@ public:
|
||||
/**
|
||||
* @brief Get the Course Correction object
|
||||
*
|
||||
* This should be called by the driver to get new instructions.
|
||||
*
|
||||
* @param correction passed as refernce to get the data
|
||||
* @return true if new correction data provided
|
||||
* @return false if route is finished
|
||||
* @param correction
|
||||
* @param forceUpdate
|
||||
* @return Status
|
||||
*/
|
||||
Status getCourseCorrection(CourseCorrection &correction, bool forceUpdate = false);
|
||||
|
||||
|
||||
+13
-13
@@ -21,18 +21,18 @@ Network::Network(const char *ssid, const char *passphrase)
|
||||
this->init(ssid, passphrase);
|
||||
}
|
||||
|
||||
Network::Network(const char *ssid, const char *passphrase, NetworkAdresses adresses)
|
||||
: adresses{adresses}
|
||||
Network::Network(const char *ssid, const char *passphrase, NetworkAddresses adresses)
|
||||
: addresses{adresses}
|
||||
{
|
||||
if (!WiFiGenericClass::mode(WIFI_AP_STA))
|
||||
{
|
||||
std::cout << "Network::connectWiFi failed WiFi.mode" << std::endl;
|
||||
}
|
||||
|
||||
if (!WiFi.config(this->adresses.localIP,
|
||||
this->adresses.gateway,
|
||||
this->adresses.subnet,
|
||||
this->adresses.dnsServer))
|
||||
if (!WiFi.config(this->addresses.localIP,
|
||||
this->addresses.gateway,
|
||||
this->addresses.subnet,
|
||||
this->addresses.dnsServer))
|
||||
{
|
||||
std::cout << "STA Failed to configure" << std::endl;
|
||||
}
|
||||
@@ -45,7 +45,7 @@ Network::~Network()
|
||||
delete mqttClient;
|
||||
}
|
||||
|
||||
bool Network::activateEspNow(recieveCallbackPtr reci, sendCallbackPtr send)
|
||||
bool Network::activateEspNow(receiveCallbackPtr reci, sendCallbackPtr send)
|
||||
{
|
||||
if (esp_now_init() != ESP_OK)
|
||||
{
|
||||
@@ -76,7 +76,7 @@ bool Network::activateMqtt(const char *user, const char *passphrase)
|
||||
this->mqttPassphrase = passphrase;
|
||||
|
||||
this->mqttClient = new PubSubClient(this->wifiClient);
|
||||
this->mqttClient->setServer(this->adresses.mqttServer, this->adresses.mqttPort);
|
||||
this->mqttClient->setServer(this->addresses.mqttServer, this->addresses.mqttPort);
|
||||
this->mqttClient->setSocketTimeout(1);
|
||||
|
||||
if (this->wifiConnected)
|
||||
@@ -116,7 +116,7 @@ uint8_t Network::getCurrentChannel()
|
||||
|
||||
void Network::runAsChild()
|
||||
{
|
||||
if (!this->initSucessful)
|
||||
if (!this->initSuccessful)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -154,21 +154,21 @@ void Network::init(const char *ssid, const char *passphrase)
|
||||
|
||||
void Network::checkWifi()
|
||||
{
|
||||
if ((WiFiSTAClass::status() != WL_CONNECTED) && (millis() - this->lastWifiRecoonectAttemp >= Network::wifiReconnectDelay))
|
||||
if ((WiFiSTAClass::status() != WL_CONNECTED) && (millis() - this->lastWifiReconnectAttempt >= Network::wifiReconnectDelay))
|
||||
{
|
||||
std::cout << "Reconnecting to WiFi..." << std::endl;
|
||||
WiFi.disconnect();
|
||||
this->wifiConnected = WiFi.reconnect();
|
||||
this->lastWifiRecoonectAttemp = millis();
|
||||
this->lastWifiReconnectAttempt = millis();
|
||||
}
|
||||
}
|
||||
|
||||
void Network::checkMqtt()
|
||||
{
|
||||
if (!this->mqttClient->connected() && millis() - this->lastMqttReconnectAttemp > Network::mqttReconnectDelay)
|
||||
if (!this->mqttClient->connected() && millis() - this->lastMqttReconnectAttempt > Network::mqttReconnectDelay)
|
||||
{
|
||||
this->mqttConnected = this->connectMqtt();
|
||||
this->lastMqttReconnectAttemp = millis();
|
||||
this->lastMqttReconnectAttempt = millis();
|
||||
}
|
||||
|
||||
if (this->mqttConnected)
|
||||
|
||||
+59
-8
@@ -20,10 +20,20 @@
|
||||
#include <esp_now.h>
|
||||
#include <esp_wifi.h>
|
||||
|
||||
typedef void (*recieveCallbackPtr)(const uint8_t *mac, const uint8_t *incomingData, int len);
|
||||
/**
|
||||
* @brief Typedef to easy handle the receive Callback
|
||||
*/
|
||||
typedef void (*receiveCallbackPtr)(const uint8_t *mac, const uint8_t *incomingData, int len);
|
||||
|
||||
/**
|
||||
* @brief Typedef to easy handle the send Callback
|
||||
*/
|
||||
typedef void (*sendCallbackPtr)(const uint8_t *mac_addr, esp_now_send_status_t status);
|
||||
|
||||
struct NetworkAdresses
|
||||
/**
|
||||
* @brief A Struct to hold all network addresses
|
||||
*/
|
||||
struct NetworkAddresses
|
||||
{
|
||||
IPAddress localIP;
|
||||
IPAddress gateway;
|
||||
@@ -33,17 +43,58 @@ struct NetworkAdresses
|
||||
uint16_t mqttPort = 1883;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A class to manage the wireless connections
|
||||
*/
|
||||
class Network : public Component
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a new Network object
|
||||
*
|
||||
* With this constructor the esp gets its ip from a Dhcp server
|
||||
*
|
||||
* @param ssid
|
||||
* @param passphrase
|
||||
*/
|
||||
Network(const char *ssid, const char *passphrase);
|
||||
Network(const char *ssid, const char *passphrase, NetworkAdresses adresses);
|
||||
|
||||
/**
|
||||
* @brief Construct a new Network object
|
||||
*
|
||||
* This constructor is used for a static ip setup
|
||||
*
|
||||
* @param ssid
|
||||
* @param passphrase
|
||||
* @param addresses
|
||||
*/
|
||||
Network(const char *ssid, const char *passphrase, NetworkAddresses addresses);
|
||||
|
||||
~Network();
|
||||
|
||||
bool activateEspNow(recieveCallbackPtr reci, sendCallbackPtr send);
|
||||
/**
|
||||
* @brief Activate ESP-NOW to communicate with the remote Control
|
||||
*
|
||||
* @param receive
|
||||
* @param send
|
||||
* @return true
|
||||
* @return false
|
||||
*/
|
||||
bool activateEspNow(receiveCallbackPtr receive, sendCallbackPtr send);
|
||||
|
||||
/**
|
||||
* @brief Activate MQTT to send debug messages
|
||||
*
|
||||
* @param user
|
||||
* @param passphrase
|
||||
* @return true
|
||||
* @return false
|
||||
*/
|
||||
bool activateMqtt(const char *user = nullptr, const char *passphrase = nullptr);
|
||||
|
||||
/**
|
||||
* @brief Print the current used IPs
|
||||
*/
|
||||
const void printIPs();
|
||||
|
||||
bool isWifiConnected() const { return this->wifiConnected; }
|
||||
@@ -61,11 +112,11 @@ private:
|
||||
void checkMqtt();
|
||||
bool connectMqtt();
|
||||
|
||||
NetworkAdresses adresses;
|
||||
NetworkAddresses addresses;
|
||||
WiFiClient wifiClient;
|
||||
PubSubClient *mqttClient = nullptr;
|
||||
|
||||
bool initSucessful = false;
|
||||
bool initSuccessful = false;
|
||||
bool wifiConnected = false;
|
||||
bool mqttConnected = false;
|
||||
|
||||
@@ -73,8 +124,8 @@ private:
|
||||
const char *mqttPassphrase = nullptr;
|
||||
|
||||
uint8_t broadcastAddress[6] = {0xC8, 0xC9, 0xA3, 0xC8, 0x57, 0x10};
|
||||
uint32_t lastWifiRecoonectAttemp = 0;
|
||||
uint32_t lastMqttReconnectAttemp = 0;
|
||||
uint32_t lastWifiReconnectAttempt = 0;
|
||||
uint32_t lastMqttReconnectAttempt = 0;
|
||||
|
||||
static constexpr uint8_t wifiConnectTimeout = 20;
|
||||
static constexpr uint16_t wifiConnectLoopTime = 500;
|
||||
|
||||
+6
-7
@@ -18,9 +18,9 @@
|
||||
#define ROUTE_DISTANCE_BETWEEN_LATITUDE 111300
|
||||
|
||||
/**
|
||||
* @brief A to handle points on the earth
|
||||
* @brief A class to handle points on the earth
|
||||
*
|
||||
* The points inherits latidue and longitude as doubles
|
||||
* The points inherits latitude and longitude as doubles
|
||||
*
|
||||
*/
|
||||
class Point
|
||||
@@ -58,11 +58,10 @@ public:
|
||||
/**
|
||||
* @brief Construct a new Point object
|
||||
*
|
||||
* @param lat latitude
|
||||
* @param lon longitude
|
||||
* @param horizontalAccuracy mm
|
||||
* @param coords Coordinates
|
||||
* @param imported if true than highest accuracy
|
||||
* @param lat
|
||||
* @param lon
|
||||
* @param horizontalAccuracy
|
||||
* @param creationTime
|
||||
*/
|
||||
Point(double lat, double lon, uint32_t horizontalAccuracy = 0, uint32_t creationTime = 0);
|
||||
Point(int32_t lat, int32_t lon, uint32_t horizontalAccuracy = 0, uint32_t creationTime = 0);
|
||||
|
||||
+6
-6
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file route.h
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief Contains the class Point and Route
|
||||
* @brief Contains the class Route
|
||||
* @version 0.1
|
||||
* @date 2022-01-31
|
||||
*
|
||||
@@ -21,7 +21,8 @@
|
||||
* @brief Holds some route information
|
||||
*
|
||||
*/
|
||||
struct RouteInfo{
|
||||
struct RouteInfo
|
||||
{
|
||||
/**
|
||||
* @brief Selected number of Points
|
||||
*/
|
||||
@@ -38,7 +39,8 @@ struct RouteInfo{
|
||||
*
|
||||
* The list of point presents a route which can be driven
|
||||
*/
|
||||
class Route {
|
||||
class Route
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Adds a point to the list.
|
||||
@@ -48,8 +50,7 @@ class Route {
|
||||
void addPointToRoute(Point point);
|
||||
|
||||
/**
|
||||
* @brief Delete all points.
|
||||
*
|
||||
* @brief Delete all points
|
||||
*/
|
||||
void clear();
|
||||
|
||||
@@ -105,7 +106,6 @@ class Route {
|
||||
|
||||
std::list<Point> points;
|
||||
std::list<Point>::iterator it;
|
||||
|
||||
};
|
||||
|
||||
#endif // ROUTE_H
|
||||
|
||||
+20
-20
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @file senors.cpp
|
||||
* @file sensorData.cpp
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief
|
||||
* @version 0.1
|
||||
@@ -83,32 +83,32 @@ void SensorData::enableCalcCompass()
|
||||
// TODO: !!! implementieren
|
||||
}
|
||||
|
||||
void SensorData::enableGyroskop()
|
||||
void SensorData::enableGyroscope()
|
||||
{
|
||||
this->gyroskop = new MPU6050();
|
||||
this->gyroskop->initialize();
|
||||
if (!this->gyroskop->testConnection())
|
||||
this->gyroscope = new MPU6050();
|
||||
this->gyroscope->initialize();
|
||||
if (!this->gyroscope->testConnection())
|
||||
{
|
||||
std::cout << "SensorData::enableGyroskop: Gyroskop is not conntected. Freeze!" << std::endl;
|
||||
std::cout << "SensorData::enableGyroscope: Gyroskop is not conntected. Freeze!" << std::endl;
|
||||
while (true)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
const uint8_t deviceStatus = this->gyroskop->dmpInitialize();
|
||||
const uint8_t deviceStatus = this->gyroscope->dmpInitialize();
|
||||
|
||||
// TODO: !!! MagicNumer 6x
|
||||
this->gyroskop->setXGyroOffset(220);
|
||||
this->gyroskop->setYGyroOffset(76);
|
||||
this->gyroskop->setZGyroOffset(-85);
|
||||
this->gyroskop->setZAccelOffset(1788);
|
||||
this->gyroscope->setXGyroOffset(220);
|
||||
this->gyroscope->setYGyroOffset(76);
|
||||
this->gyroscope->setZGyroOffset(-85);
|
||||
this->gyroscope->setZAccelOffset(1788);
|
||||
|
||||
if (deviceStatus == 0)
|
||||
{
|
||||
this->gyroskop->CalibrateAccel(6);
|
||||
this->gyroskop->CalibrateGyro(6);
|
||||
this->gyroskop->PrintActiveOffsets();
|
||||
this->gyroskop->setDMPEnabled(true);
|
||||
this->gyroscope->CalibrateAccel(6);
|
||||
this->gyroscope->CalibrateGyro(6);
|
||||
this->gyroscope->PrintActiveOffsets();
|
||||
this->gyroscope->setDMPEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -116,7 +116,7 @@ void SensorData::enableGyroskop()
|
||||
// 1 = initial memory load failed
|
||||
// 2 = DMP configuration updates failed
|
||||
// (if it's going to break, usually the code will be 1)
|
||||
std::cout << "SensorData::enableGyroskop: DMP Initialization failed (code" << static_cast<int>(deviceStatus) << "). Freeze!" << std::endl;
|
||||
std::cout << "SensorData::enableGyroscope: DMP Initialization failed (code" << static_cast<int>(deviceStatus) << "). Freeze!" << std::endl;
|
||||
while (true)
|
||||
{
|
||||
}
|
||||
@@ -236,11 +236,11 @@ void SensorData::run()
|
||||
this->realAzimuth = this->realCompass->getAzimuth();
|
||||
}
|
||||
|
||||
if (static_cast<bool>(this->gyroskop) && this->gyroskop->dmpGetCurrentFIFOPacket(static_cast<uint8_t *>(this->gyroBuffer)))
|
||||
if (static_cast<bool>(this->gyroscope) && this->gyroscope->dmpGetCurrentFIFOPacket(static_cast<uint8_t *>(this->gyroBuffer)))
|
||||
{
|
||||
this->gyroskop->dmpGetQuaternion(&this->quaternion, static_cast<uint8_t *>(this->gyroBuffer));
|
||||
this->gyroskop->dmpGetGravity(&this->gravity, &this->quaternion);
|
||||
this->gyroskop->dmpGetYawPitchRoll(static_cast<float *>(this->yawPitchRoll), &this->quaternion, &this->gravity);
|
||||
this->gyroscope->dmpGetQuaternion(&this->quaternion, static_cast<uint8_t *>(this->gyroBuffer));
|
||||
this->gyroscope->dmpGetGravity(&this->gravity, &this->quaternion);
|
||||
this->gyroscope->dmpGetYawPitchRoll(static_cast<float *>(this->yawPitchRoll), &this->quaternion, &this->gravity);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file sensorData.h
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief
|
||||
* @brief Contains the SensorData class
|
||||
* @version 0.1
|
||||
* @date 2023-09-02
|
||||
*
|
||||
@@ -26,8 +26,12 @@
|
||||
#include "ntripClient.h"
|
||||
|
||||
#include "point.h"
|
||||
class Sensors;
|
||||
|
||||
/**
|
||||
* @brief A class to manage all sensors
|
||||
*
|
||||
* Each sensor have separately to be enabled
|
||||
*/
|
||||
class SensorData : public Component
|
||||
{
|
||||
public:
|
||||
@@ -35,26 +39,89 @@ public:
|
||||
~SensorData();
|
||||
|
||||
void enableNtrip(String host, uint16_t port, String mountPoint, String user, String password);
|
||||
|
||||
/**
|
||||
* @brief Enable the gnss module over spi
|
||||
*
|
||||
* @param spiPort
|
||||
* @param csPin
|
||||
*/
|
||||
void enableGnss(SPIClass *spiPort, uint8_t csPin);
|
||||
|
||||
/**
|
||||
* @brief Enable the gnss module over i2c
|
||||
*/
|
||||
void enableGnss();
|
||||
|
||||
void enableRealCompass();
|
||||
void enableCalcCompass();
|
||||
void enableGyroskop();
|
||||
void enableGyroscope();
|
||||
|
||||
// Interface Const kram
|
||||
// Interface Const
|
||||
/**
|
||||
* @brief Get the azimuth measured by the compass module
|
||||
*
|
||||
* @return int16_t
|
||||
*/
|
||||
int16_t getRealAzimuth() const { return this->realAzimuth; }
|
||||
|
||||
/**
|
||||
* @brief Get the azimuth calculated by CalcAzimuth
|
||||
*
|
||||
* Consider to call getCalcAzimuthState() to check, if the data is valid.
|
||||
*
|
||||
* @return int16_t
|
||||
*/
|
||||
int16_t getCalcAzimuth() const { return this->calcAzimuth; }
|
||||
|
||||
/**
|
||||
* @brief Get the CalcAzimuth::State object
|
||||
*
|
||||
* Needed to check the quality of calculated azimuth
|
||||
*
|
||||
* @return CalcAzimuth::State
|
||||
*/
|
||||
CalcAzimuth::State getCalcAzimuthState() const;
|
||||
|
||||
Point getCurrentPos() const { return this->currentPosition; }
|
||||
const UBX_NAV_PVT_data_t *getGnssData() const { return this->gnssData; };
|
||||
NTRIPClientStates getNtripState() const;
|
||||
|
||||
/**
|
||||
* @brief Get the data from the gyroscope
|
||||
*
|
||||
* The returned float pointer is an array of 3 floats
|
||||
* - Yaw
|
||||
* - Pitch
|
||||
* - Roll
|
||||
*
|
||||
* @return const float*
|
||||
*/
|
||||
const float *getGyroData() const { return this->yawPitchRoll; }
|
||||
|
||||
/**
|
||||
* @brief Get the CalcCompass object
|
||||
* @return CalcAzimuth*
|
||||
*/
|
||||
CalcAzimuth *getCalcCompass() const { return this->calcCompass; }
|
||||
|
||||
/**
|
||||
* @brief Get the RealCompass object
|
||||
* @return QMC5883LCompass*
|
||||
*/
|
||||
QMC5883LCompass *getRealCompass() const { return this->realCompass; }
|
||||
|
||||
/**
|
||||
* @brief Get the NTRIPClient object
|
||||
* @return NTRIPClient*
|
||||
*/
|
||||
NTRIPClient *getNtripClient() const { return this->ntripClient; }
|
||||
MPU6050 *getGyroskop() const { return this->gyroskop; }
|
||||
|
||||
/**
|
||||
* @brief Get the Gyroscope object
|
||||
* @return MPU6050*
|
||||
*/
|
||||
MPU6050 *getGyroscope() const { return this->gyroscope; }
|
||||
|
||||
// static
|
||||
/**
|
||||
@@ -77,7 +144,7 @@ private:
|
||||
CalcAzimuth *calcCompass = nullptr;
|
||||
SFE_UBLOX_GNSS *gnss = nullptr;
|
||||
NTRIPClient *ntripClient = nullptr;
|
||||
MPU6050 *gyroskop = nullptr;
|
||||
MPU6050 *gyroscope = nullptr;
|
||||
|
||||
UBX_NAV_PVT_data_t *gnssData = nullptr;
|
||||
Point currentPosition;
|
||||
|
||||
@@ -48,7 +48,7 @@ public:
|
||||
*
|
||||
* @param pin Pin on the Esp from the encoder.
|
||||
* @param diameter Diameter of the wheel in meters.
|
||||
* @param steps Encodersteps for a complete wheel rotation.
|
||||
* @param steps EncoderSteps for a complete wheel rotation.
|
||||
*/
|
||||
Speedometer(uint8_t pin, double diameter, uint16_t steps);
|
||||
|
||||
@@ -78,12 +78,24 @@ public:
|
||||
Direction getDirection() const { return this->currentDirection; }
|
||||
|
||||
/**
|
||||
* @brief Get the calculated speed of the Wheel
|
||||
* @brief Get the calculated speed of the wheel
|
||||
*
|
||||
* @return double speed in m/s
|
||||
*/
|
||||
double getSpeed() const { return this->speed; }
|
||||
|
||||
/**
|
||||
* @brief Get the calculated speed of the wheel
|
||||
*
|
||||
* @return double speed in rad/s
|
||||
*/
|
||||
double getSpeedRad() const { return this->rad; };
|
||||
|
||||
/**
|
||||
* @brief Get the calculated average speed of the wheel
|
||||
*
|
||||
* @return double speed in m/s
|
||||
*/
|
||||
double getAvgSpeed() const;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file debugTimes.cpp
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief Implemention of the class debugTimes.h.
|
||||
* @brief Implementation of the class debugTimes.h.
|
||||
* @version 0.1
|
||||
* @date 2021-12-13
|
||||
*
|
||||
@@ -19,7 +19,7 @@ DebugTimes::DebugTimes()
|
||||
if (DebugTimes::printWarning)
|
||||
{
|
||||
std::cout << std::endl
|
||||
<< "Warning: DebugTimes is muuted, no times are be shown." << std::endl
|
||||
<< "Warning: DebugTimes is muted, no times are be shown." << std::endl
|
||||
<< std::endl;
|
||||
DebugTimes::printWarning = false;
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
/**
|
||||
* @brief Print the elapsed time to consol
|
||||
*
|
||||
* @param name Functionname to print
|
||||
* @param name FunctionName to print
|
||||
* @param minTime A minimum time before printing
|
||||
*
|
||||
* @return uint16_t elapsed milliseconds
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
/**
|
||||
* @file calibrateCompass.h
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2023-05-23
|
||||
*
|
||||
* @copyright Copyright (c) 2023
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QMC5883LCompass.h>
|
||||
#include <Preferences.h>
|
||||
#include <iostream>
|
||||
|
||||
#include "component.h"
|
||||
|
||||
class CalibrateCompass : public Component
|
||||
{
|
||||
public:
|
||||
enum State
|
||||
{
|
||||
Ready,
|
||||
Calibrating,
|
||||
Finished
|
||||
};
|
||||
|
||||
struct CallibrationData
|
||||
{
|
||||
int data[3][2];
|
||||
};
|
||||
|
||||
CalibrateCompass(QMC5883LCompass *compass);
|
||||
|
||||
void start();
|
||||
void useData();
|
||||
void removeCalibration();
|
||||
void reset();
|
||||
void saveData();
|
||||
void loadData();
|
||||
|
||||
State getState() const { return this->state; }
|
||||
CallibrationData getCallibrationData() const { return this->data; }
|
||||
|
||||
friend std::ostream &operator<<(std::ostream &stream, const CalibrateCompass &caliComp);
|
||||
|
||||
private:
|
||||
void runAsChild() override;
|
||||
void run() override;
|
||||
void checkDataValidity();
|
||||
|
||||
QMC5883LCompass *compass;
|
||||
State state = State::Ready;
|
||||
CallibrationData data{};
|
||||
|
||||
void clearData();
|
||||
|
||||
bool dataValid = false;
|
||||
const uint16_t maxTimeWithoutChange = 10000;
|
||||
uint32_t lastChange = 0;
|
||||
};
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @file outputBufMqtt.cpp
|
||||
* @file outputBuf.cpp
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief Contains the implementation of the class OutputBufMqtt
|
||||
* @version 0.1
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @file outputBufMqtt.h
|
||||
* @file outputBuf.h
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief Contains a small class that provide a streambuf
|
||||
*
|
||||
@@ -38,6 +38,7 @@ class OutputBuf : public std::streambuf {
|
||||
* @brief Construct a new Output Buf Mqtt object
|
||||
*
|
||||
* @param debugMqtt
|
||||
* @param serialBT
|
||||
*/
|
||||
OutputBuf(DebugMqtt* debugMqtt = nullptr, BluetoothSerial* serialBT = nullptr);
|
||||
|
||||
|
||||
@@ -32,7 +32,6 @@ class MenuSysteminformation : public MenuInformationSites {
|
||||
* @brief Construct a new Menu Systeminformation object
|
||||
*
|
||||
* @param mainBattery
|
||||
* @param gamepad
|
||||
*/
|
||||
MenuSysteminformation(Battery* mainBattery);
|
||||
|
||||
|
||||
@@ -81,23 +81,23 @@ void MenuCalibrateCompass::printPage() const {
|
||||
|
||||
case 8:
|
||||
lineOne = "X min: ";
|
||||
lineOne.concat(this->caliCompass->getCallibrationData().data[0][0]);
|
||||
lineOne.concat(this->caliCompass->getCalibrationData().data[0][0]);
|
||||
lineTwo = "X max: ";
|
||||
lineTwo.concat(this->caliCompass->getCallibrationData().data[0][1]);
|
||||
lineTwo.concat(this->caliCompass->getCalibrationData().data[0][1]);
|
||||
break;
|
||||
|
||||
case 9:
|
||||
lineOne = "Y min: ";
|
||||
lineOne.concat(this->caliCompass->getCallibrationData().data[1][0]);
|
||||
lineOne.concat(this->caliCompass->getCalibrationData().data[1][0]);
|
||||
lineTwo = "Y max: ";
|
||||
lineTwo.concat(this->caliCompass->getCallibrationData().data[1][1]);
|
||||
lineTwo.concat(this->caliCompass->getCalibrationData().data[1][1]);
|
||||
break;
|
||||
|
||||
case 10:
|
||||
lineOne = "Z min: ";
|
||||
lineOne.concat(this->caliCompass->getCallibrationData().data[2][0]);
|
||||
lineOne.concat(this->caliCompass->getCalibrationData().data[2][0]);
|
||||
lineTwo = "Z max: ";
|
||||
lineTwo.concat(this->caliCompass->getCallibrationData().data[2][1]);
|
||||
lineTwo.concat(this->caliCompass->getCalibrationData().data[2][1]);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
@@ -164,7 +164,7 @@ void MenuTestMode::init() {
|
||||
auto *lightBlueAction = new MenuAction("Blue", dummy);
|
||||
auto *lightOffAction = new MenuAction("Off", dummy);
|
||||
|
||||
// Add entrys to the menus
|
||||
// Add entries to the menus
|
||||
this->mainMenu->addEntry(engineAction);
|
||||
this->mainMenu->addEntry(drivingAction);
|
||||
this->mainMenu->addEntry(encoderAction);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @file menuTest.cpp
|
||||
* @file speedometerTest.cpp
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief Contains the implementation of the class SpeedometerTest.
|
||||
* @version 0.1
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @file menuTest.h
|
||||
* @file speedometerTest.h
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief Contains a class to test the wheel encoder.
|
||||
* @version 0.1
|
||||
|
||||
@@ -22,14 +22,21 @@
|
||||
|
||||
class DriveManager : public Component {
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief Construct a new Drive Manager object
|
||||
*
|
||||
* Creates a Navigation object
|
||||
*
|
||||
* @param moveControl
|
||||
* @param sensorData
|
||||
* @param input
|
||||
*/
|
||||
DriveManager(MoveControl *moveControl, const SensorData* sensorData, const ControlPadInput *input);
|
||||
|
||||
/**
|
||||
* @brief Construct a new Drive Manager object
|
||||
*
|
||||
* @param params
|
||||
*/
|
||||
DriveManager(DriveModiParams params);
|
||||
|
||||
/**
|
||||
|
||||
+4
-4
@@ -70,7 +70,7 @@ void restart();
|
||||
void receiveCallback(const uint8_t *mac, const uint8_t *incomingData, int len);
|
||||
void sendCallback(const uint8_t *mac_addr, esp_now_send_status_t status);
|
||||
void lcdWrapperCallback(const char data[][LcdWrapper::totalRows], uint8_t lines, uint8_t rows);
|
||||
NetworkAdresses setIPs();
|
||||
NetworkAddresses setIPs();
|
||||
|
||||
void setup()
|
||||
{
|
||||
@@ -130,7 +130,7 @@ void setup()
|
||||
static_cast<const char*>(NtripConfig::mountPoint),
|
||||
static_cast<const char*>(NtripConfig::user),
|
||||
static_cast<const char*>(NtripConfig::password));
|
||||
// sensorData->enableGyroskop();
|
||||
// sensorData->enableGyroscope();
|
||||
driveManager = new DriveManager(&moveController, sensorData, controlPad->getControlPadDataPtr());
|
||||
|
||||
char wifiIndicator = 'X';
|
||||
@@ -355,9 +355,9 @@ void lcdWrapperCallback(const char data[][LcdWrapper::totalRows], uint8_t lines,
|
||||
}
|
||||
}
|
||||
|
||||
NetworkAdresses setIPs()
|
||||
NetworkAddresses setIPs()
|
||||
{
|
||||
NetworkAdresses adresses;
|
||||
NetworkAddresses adresses;
|
||||
adresses.localIP.fromString(static_cast<const char *>(NetworkConfig::ip));
|
||||
adresses.subnet.fromString(static_cast<const char *>(NetworkConfig::subnet));
|
||||
adresses.gateway.fromString(static_cast<const char *>(NetworkConfig::gateway));
|
||||
|
||||
Reference in New Issue
Block a user