doxygen finished
This commit is contained in:
@@ -4,15 +4,14 @@
|
||||
* @brief Contains a class which use the navigate class to drive automaticaly
|
||||
* @version 0.1
|
||||
* @date 2022-02-02
|
||||
*
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef AUTOPILOT_H
|
||||
#define AUTOPILOT_H
|
||||
|
||||
|
||||
#include "navigation.h"
|
||||
#include "driveModi/Modi/ManualControl/manualControl.h"
|
||||
|
||||
@@ -20,110 +19,113 @@ class DirectionChangeSignal;
|
||||
|
||||
/**
|
||||
* @brief This class use the navigate class to drive automaticaly
|
||||
*
|
||||
*
|
||||
* This class get the information from the navigate class. When an
|
||||
* object of this class is constructed the rover can be driven manually.
|
||||
* When the Rover is near to the first position of the Route, you can
|
||||
* switch to automatic drive.
|
||||
*
|
||||
*
|
||||
*/
|
||||
class Autopilot : public ManualControl {
|
||||
public:
|
||||
enum State {
|
||||
InsufficientAccuracy = -2,
|
||||
NoRoute = -1,
|
||||
None = 0,
|
||||
NavigationStarted,
|
||||
GetToStartPoint,
|
||||
SelfDrivingAvailable,
|
||||
SelfDriving,
|
||||
SelfDrivingRotate,
|
||||
TargetReached
|
||||
};
|
||||
class Autopilot : public ManualControl
|
||||
{
|
||||
public:
|
||||
enum State
|
||||
{
|
||||
InsufficientAccuracy = -2,
|
||||
NoRoute = -1,
|
||||
None = 0,
|
||||
NavigationStarted,
|
||||
GetToStartPoint,
|
||||
SelfDrivingAvailable,
|
||||
SelfDriving,
|
||||
SelfDrivingRotate,
|
||||
TargetReached
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Destroy the Autopilot object
|
||||
*
|
||||
* Disconnect the NTRIP-Client
|
||||
*/
|
||||
~Autopilot();
|
||||
/**
|
||||
* @brief Destroy the Autopilot object
|
||||
*
|
||||
* Disconnect the NTRIP-Client
|
||||
*/
|
||||
~Autopilot();
|
||||
|
||||
void restart();
|
||||
void restart();
|
||||
|
||||
/**
|
||||
* @brief Get the Route Info object
|
||||
*
|
||||
* @return RouteInfo
|
||||
*/
|
||||
RouteInfo getRouteInfo() const { return this->routeInfo; }
|
||||
/**
|
||||
* @brief Get the Route Info object
|
||||
*
|
||||
* @return RouteInfo
|
||||
*/
|
||||
RouteInfo getRouteInfo() const { return this->routeInfo; }
|
||||
|
||||
/**
|
||||
* @brief Get the Course Correction object
|
||||
*
|
||||
* @return CourseCorrection
|
||||
*/
|
||||
CourseCorrection getCourseCorrection() const { return this->courseCorrection; }
|
||||
/**
|
||||
* @brief Get the Course Correction object
|
||||
*
|
||||
* @return CourseCorrection
|
||||
*/
|
||||
CourseCorrection getCourseCorrection() const { return this->courseCorrection; }
|
||||
|
||||
/**
|
||||
* @brief Get the State object
|
||||
*
|
||||
* @return State
|
||||
*/
|
||||
State getState() const { return this->state; }
|
||||
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; }
|
||||
/**
|
||||
* @brief Get the State object
|
||||
*
|
||||
* @return State
|
||||
*/
|
||||
State getState() const { return this->state; }
|
||||
Navigation *getNavigation() const { return this->navigation; }
|
||||
|
||||
private:
|
||||
void init();
|
||||
void drive();
|
||||
void beginRotate();
|
||||
void rotate();
|
||||
void run() override;
|
||||
void checkButtonInput();
|
||||
void askNavigationForOrder();
|
||||
void selfDriving();
|
||||
void restartLoop();
|
||||
void afterActivate() override;
|
||||
/**
|
||||
* @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; }
|
||||
|
||||
Navigation* navigation = nullptr;
|
||||
CourseCorrection courseCorrection{0, 0};
|
||||
RouteInfo routeInfo{0, 0};
|
||||
State state = State::None;
|
||||
State lastState = State::None;
|
||||
Navigation::Status lastOrderStatus;
|
||||
DirectionChangeSignal* directionChangeSignal = nullptr;
|
||||
private:
|
||||
void init();
|
||||
void drive();
|
||||
void beginRotate();
|
||||
void rotate();
|
||||
void run() override;
|
||||
void checkButtonInput();
|
||||
void askNavigationForOrder();
|
||||
void selfDriving();
|
||||
void restartLoop();
|
||||
void afterActivate() override;
|
||||
|
||||
bool updateDisplay = false;
|
||||
bool loopMode = false;
|
||||
Navigation *navigation = nullptr;
|
||||
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;
|
||||
uint16_t autopilotChangeDelayMillis = 500;
|
||||
uint32_t lastAutopilotChangeMillis = 0;
|
||||
bool updateDisplay = false;
|
||||
bool loopMode = false;
|
||||
|
||||
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 {
|
||||
public:
|
||||
DirectionChangeSignal(Autopilot* pilot);
|
||||
~DirectionChangeSignal();
|
||||
void action() override;
|
||||
class DirectionChangeSignal : public DirectionChangeWrapper
|
||||
{
|
||||
public:
|
||||
DirectionChangeSignal(Autopilot *pilot);
|
||||
~DirectionChangeSignal();
|
||||
void action() override;
|
||||
|
||||
private:
|
||||
Autopilot* pilot;
|
||||
private:
|
||||
Autopilot *pilot;
|
||||
};
|
||||
|
||||
#endif // AUTOPILOT_H
|
||||
|
||||
@@ -1,22 +1,25 @@
|
||||
/**
|
||||
* @file calibrateCompassM.cpp
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2023-09-03
|
||||
*
|
||||
*
|
||||
* @copyright Copyright (c) 2023
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#include "calibrateCompassM.h"
|
||||
|
||||
|
||||
void CalibrateCompassM::setCalibrateCompass(CalibrateCompass *caliCompass) {
|
||||
if (static_cast<bool>(caliCompass)) {
|
||||
void CalibrateCompassM::setCalibrateCompass(CalibrateCompass *caliCompass)
|
||||
{
|
||||
if (static_cast<bool>(caliCompass))
|
||||
{
|
||||
this->caliCompass = caliCompass;
|
||||
this->addChildComponent(this->caliCompass);
|
||||
} else if (static_cast<bool>(this->caliCompass)) {
|
||||
}
|
||||
else if (static_cast<bool>(this->caliCompass))
|
||||
{
|
||||
this->removeChildComponent(this->caliCompass);
|
||||
this->caliCompass = caliCompass;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/**
|
||||
* @file calibrateCompassM.h
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief
|
||||
* @brief Contains a Menu class to calibrate the compass
|
||||
* @version 0.1
|
||||
* @date 2023-09-03
|
||||
*
|
||||
*
|
||||
* @copyright Copyright (c) 2023
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CALIBRATE_COMPASS_M_H
|
||||
@@ -16,12 +16,21 @@
|
||||
|
||||
#include "driveModi/Modi/ManualControl/manualControl.h"
|
||||
|
||||
class CalibrateCompassM : public ManualControl {
|
||||
public:
|
||||
void setCalibrateCompass(CalibrateCompass* caliCompass = nullptr);
|
||||
/**
|
||||
* @brief A Menu class to interact with CalibrateCompass class
|
||||
*/
|
||||
class CalibrateCompassM : public ManualControl
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Set the CalibrateCompass object
|
||||
*
|
||||
* @param caliCompass
|
||||
*/
|
||||
void setCalibrateCompass(CalibrateCompass *caliCompass = nullptr);
|
||||
|
||||
private:
|
||||
CalibrateCompass* caliCompass = nullptr;
|
||||
private:
|
||||
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
|
||||
* @version 0.1
|
||||
* @date 2022-02-15
|
||||
*
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CAPTURE_ROUTE_H
|
||||
@@ -19,61 +19,57 @@
|
||||
|
||||
/**
|
||||
* @brief A class to capture a driven class
|
||||
*
|
||||
*
|
||||
* This class inherits ManualControl so you can drive
|
||||
* normally as in ManualControl. If GPS signal is valid
|
||||
* you can add a Point everytime you want.
|
||||
*
|
||||
*
|
||||
*/
|
||||
class CaptureRoute : public ManualControl {
|
||||
public:
|
||||
/**
|
||||
* @brief Destroy the Capture Route object
|
||||
*
|
||||
* Disconnect the NTRIP-Client
|
||||
*/
|
||||
~CaptureRoute();
|
||||
class CaptureRoute : public ManualControl
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Destroy the Capture Route object
|
||||
*
|
||||
* Disconnect the NTRIP-Client
|
||||
*/
|
||||
~CaptureRoute();
|
||||
|
||||
// /**
|
||||
// * @brief Get the Navigation object
|
||||
// *
|
||||
// * @return Navigation*
|
||||
// */
|
||||
// Navigation* getNavigation() const { return this->navigation; }
|
||||
/**
|
||||
* @brief Get the Route Info object
|
||||
*
|
||||
* @return RouteInfo
|
||||
*/
|
||||
RouteInfo getRouteInfo() const { return this->routeInfo; }
|
||||
|
||||
/**
|
||||
* @brief Get the Route Info object
|
||||
*
|
||||
* @return RouteInfo
|
||||
*/
|
||||
RouteInfo getRouteInfo() const { return this->routeInfo; }
|
||||
Navigation::Status getLastStatus() const { return this->status; }
|
||||
Navigation* getNavigation() const { return this->navigation; }
|
||||
Navigation::Status getLastStatus() const { return this->status; }
|
||||
Navigation *getNavigation() const { return this->navigation; }
|
||||
|
||||
/**
|
||||
* @brief Get the distance to the last saved oint
|
||||
*
|
||||
* @return double in meters
|
||||
*/
|
||||
double getDistanceToLastPoint() const;
|
||||
/**
|
||||
* @brief Get the distance to the last saved oint
|
||||
*
|
||||
* @return double in meters
|
||||
*/
|
||||
double getDistanceToLastPoint() const;
|
||||
|
||||
/**
|
||||
* @brief Tells if there are new informations to display
|
||||
*
|
||||
* @return true
|
||||
* @return false
|
||||
*/
|
||||
bool shouldUpdate();
|
||||
private:
|
||||
void run() override;
|
||||
void afterActivate() override;
|
||||
/**
|
||||
* @brief Tells if there are new informations to display
|
||||
*
|
||||
* @return true
|
||||
* @return false
|
||||
*/
|
||||
bool shouldUpdate();
|
||||
|
||||
Navigation* navigation = nullptr;
|
||||
RouteInfo routeInfo;
|
||||
Point lastSavedPoint;
|
||||
Navigation::Status status = Navigation::Status::Complete;
|
||||
private:
|
||||
void run() override;
|
||||
void afterActivate() override;
|
||||
|
||||
bool updateDisplay = false;
|
||||
Navigation *navigation = nullptr;
|
||||
RouteInfo routeInfo;
|
||||
Point lastSavedPoint;
|
||||
Navigation::Status status = Navigation::Status::Complete;
|
||||
|
||||
bool updateDisplay = false;
|
||||
};
|
||||
|
||||
#endif // CAPTURE_ROUTE_H
|
||||
|
||||
@@ -4,53 +4,70 @@
|
||||
* @brief A small class to drive the Rover by the controller joystick.
|
||||
* @version 0.1
|
||||
* @date 2021-12-13
|
||||
*
|
||||
*
|
||||
* @copyright Copyright (c) 2021
|
||||
*
|
||||
*
|
||||
*/
|
||||
#ifndef MANUAL_CONTROL_H
|
||||
#define MANUAL_CONTROL_H
|
||||
|
||||
#include "driveModi/driveModi.h"
|
||||
|
||||
class DirectionChangeWrapper {
|
||||
public:
|
||||
virtual void action() = 0;
|
||||
class DirectionChangeWrapper
|
||||
{
|
||||
public:
|
||||
virtual void action() = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Drive the Rover with a Joystick
|
||||
*
|
||||
* This class gets the x and y value from the PS3 controller
|
||||
*
|
||||
* This class gets the x and y value from the ControlPad
|
||||
* and map the values to moveControl
|
||||
*
|
||||
*
|
||||
* @see MoveControl
|
||||
*/
|
||||
class ManualControl : public DriveModi {
|
||||
public:
|
||||
enum class InputMode : uint8_t {
|
||||
Analog,
|
||||
Digital
|
||||
};
|
||||
class ManualControl : public DriveModi
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @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; }
|
||||
InputMode getInputMode() const { return this->inputMode; }
|
||||
void setDirectionChangeCallback(DirectionChangeWrapper* callback) { this->directionChangeWrapper = callback; }
|
||||
/**
|
||||
* @brief Change the InputMode to the opposite
|
||||
*/
|
||||
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:
|
||||
void run() override;
|
||||
uint16_t getDutycycleLeft() const { return this->moveControl->getDutycycleLeft(); }
|
||||
uint16_t getDutycycleRight() const { return this->moveControl->getDutycycleRight(); }
|
||||
|
||||
private:
|
||||
void analogControl();
|
||||
void digitalControl();
|
||||
protected:
|
||||
void run() override;
|
||||
|
||||
bool lastLoopTurned = false;
|
||||
DirectionChangeWrapper* directionChangeWrapper = nullptr;
|
||||
InputMode inputMode = InputMode::Analog;
|
||||
private:
|
||||
void analogControl();
|
||||
void digitalControl();
|
||||
|
||||
bool lastLoopTurned = false;
|
||||
DirectionChangeWrapper *directionChangeWrapper = nullptr;
|
||||
InputMode inputMode = InputMode::Analog;
|
||||
};
|
||||
|
||||
#endif // MANUAL_CONTROL_H
|
||||
|
||||
@@ -15,7 +15,8 @@ void TestMode::run()
|
||||
if (this->maneuver == Maneuver::Turn)
|
||||
{
|
||||
uint16_t delta = abs(this->azimuth - this->getSensorData()->getRealAzimuth());
|
||||
if (delta > this->degree) {
|
||||
if (delta > this->degree)
|
||||
{
|
||||
this->abort = true;
|
||||
}
|
||||
}
|
||||
@@ -31,7 +32,8 @@ void TestMode::run()
|
||||
|
||||
bool TestMode::drive(int16_t cmDistance, int16_t degree)
|
||||
{
|
||||
if (this->busy){
|
||||
if (this->busy)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -43,10 +45,12 @@ bool TestMode::drive(int16_t cmDistance, int16_t degree)
|
||||
// Only left or right
|
||||
this->moveControl->setSpeed(0);
|
||||
|
||||
if (degree < 0){
|
||||
if (degree < 0)
|
||||
{
|
||||
this->moveControl->setRotationSpeed(-this->maxSpeeds.rot);
|
||||
}
|
||||
else if (degree > 0){
|
||||
else if (degree > 0)
|
||||
{
|
||||
this->moveControl->setRotationSpeed(this->maxSpeeds.rot);
|
||||
}
|
||||
|
||||
@@ -62,10 +66,12 @@ bool TestMode::drive(int16_t cmDistance, int16_t degree)
|
||||
// Only forward or backward
|
||||
this->moveControl->setRotationSpeed(0);
|
||||
|
||||
if (cmDistance < 0){
|
||||
if (cmDistance < 0)
|
||||
{
|
||||
this->moveControl->setSpeed(-this->maxSpeeds.x);
|
||||
}
|
||||
else if (cmDistance > 0){
|
||||
else if (cmDistance > 0)
|
||||
{
|
||||
this->moveControl->setSpeed(this->maxSpeeds.x);
|
||||
}
|
||||
|
||||
@@ -78,10 +84,12 @@ bool TestMode::drive(int16_t cmDistance, int16_t degree)
|
||||
{
|
||||
// forward or backward and left or right
|
||||
// TODO: Calculate roationspeed
|
||||
if (cmDistance < 0){
|
||||
if (cmDistance < 0)
|
||||
{
|
||||
this->moveControl->setSpeed(-this->maxSpeeds.x);
|
||||
}
|
||||
else if (cmDistance > 0){
|
||||
else if (cmDistance > 0)
|
||||
{
|
||||
this->moveControl->setSpeed(this->maxSpeeds.x);
|
||||
}
|
||||
|
||||
@@ -137,7 +145,8 @@ void TestMode::abortManeuver()
|
||||
|
||||
uint8_t TestMode::getRemainingManeuverTime() const
|
||||
{
|
||||
if (this->busy){
|
||||
if (this->busy)
|
||||
{
|
||||
return static_cast<uint8_t>((this->maneuverTime - (millis() - this->actionStart)) / 1000);
|
||||
}
|
||||
return 0;
|
||||
@@ -145,13 +154,16 @@ uint8_t TestMode::getRemainingManeuverTime() const
|
||||
|
||||
bool TestMode::engineInit(int16_t powerPercentage, int16_t seconds)
|
||||
{
|
||||
if (this->busy){
|
||||
if (this->busy)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (powerPercentage > TestMode::maxPercentage || powerPercentage < -TestMode::maxPercentage){
|
||||
if (powerPercentage > TestMode::maxPercentage || powerPercentage < -TestMode::maxPercentage)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (seconds < 0){
|
||||
if (seconds < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ class TestMode : public DriveModi
|
||||
public:
|
||||
/**
|
||||
* @brief Different states to test the engine
|
||||
*
|
||||
*/
|
||||
enum Maneuver
|
||||
{
|
||||
@@ -38,6 +37,14 @@ public:
|
||||
Drive
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Let the rover drive
|
||||
*
|
||||
* @param cmDistance to drive
|
||||
* @param degree degree to rotate over the hole distance
|
||||
* @return true
|
||||
* @return false
|
||||
*/
|
||||
bool drive(int16_t cmDistance = 0, int16_t degree = 0);
|
||||
|
||||
/**
|
||||
@@ -89,6 +96,7 @@ public:
|
||||
* @return false
|
||||
*/
|
||||
bool getBusy() const { return this->busy; }
|
||||
|
||||
Maneuver getManeuver() const { return this->maneuver; }
|
||||
Speedometer *getSpeedometerLeft() const { return this->moveControl->getSpeedometerLeft(); }
|
||||
Speedometer *getSpeedometerRight() const { return this->moveControl->getSpeedometerRight(); }
|
||||
|
||||
Reference in New Issue
Block a user