Merge branch 'main' into projektarbeit
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* @file calibrateCompassM.cpp
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2023-09-03
|
||||
*
|
||||
* @copyright Copyright (c) 2023
|
||||
*
|
||||
*/
|
||||
|
||||
#include "calibrateCompassM.h"
|
||||
|
||||
CalibrateCompassM::CalibrateCompassM(DriveModiParams params) : ManualControl(params) {}
|
||||
|
||||
void CalibrateCompassM::setCalibrateCompass(CalibrateCompass *caliCompass) {
|
||||
if (caliCompass) {
|
||||
this->caliCompass = caliCompass;
|
||||
this->addChildComponent(this->caliCompass);
|
||||
} else if (this->caliCompass) {
|
||||
this->removeChildComponent(this->caliCompass);
|
||||
this->caliCompass = caliCompass;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* @file calibrateCompassM.h
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2023-09-03
|
||||
*
|
||||
* @copyright Copyright (c) 2023
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CALIBRATE_COMPASS_M_H
|
||||
#define CALIBRATE_COMPASS_M_H
|
||||
|
||||
#include "calibrateCompass.h"
|
||||
|
||||
#include "driveModi/Modi/ManualControl/manualControl.h"
|
||||
|
||||
class CalibrateCompassM : public ManualControl {
|
||||
public:
|
||||
CalibrateCompassM(DriveModiParams params);
|
||||
|
||||
void setCalibrateCompass(CalibrateCompass* caliCompass = nullptr);
|
||||
|
||||
private:
|
||||
CalibrateCompass* caliCompass = nullptr;
|
||||
};
|
||||
|
||||
#endif //CALIBRATE_COMPASS_M_H
|
||||
@@ -1,13 +0,0 @@
|
||||
/**
|
||||
* @file consolControl.cpp
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2022-02-15
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
|
||||
#include "consolControl.h"
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
/**
|
||||
* @file consolControl.h
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2022-02-15
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CONSOL_CONTROL_H
|
||||
#define CONSOL_CONTROL_H
|
||||
|
||||
#include "driveModi/driveModi.h"
|
||||
class ConsolControl : DriveModi{
|
||||
|
||||
};
|
||||
|
||||
#endif // CONSOL_CONTROL_H
|
||||
@@ -10,15 +10,6 @@
|
||||
*/
|
||||
#include "manualControl.h"
|
||||
|
||||
ManualControl::ManualControl(MoveControl* moveControl, const ControlPadInput *input)
|
||||
: DriveModi(moveControl) {
|
||||
this->input = input;
|
||||
}
|
||||
|
||||
ManualControl::~ManualControl() {
|
||||
|
||||
}
|
||||
|
||||
void ManualControl::run() {
|
||||
switch (this->inputMode) {
|
||||
case InputMode::Analog :
|
||||
@@ -34,16 +25,6 @@ void ManualControl::run() {
|
||||
}
|
||||
}
|
||||
|
||||
void ManualControl::setCalibrateCompass(CalibrateCompass *caliCompass) {
|
||||
if (caliCompass) {
|
||||
this->caliCompass = caliCompass;
|
||||
this->addChildComponent(this->caliCompass);
|
||||
} else if (this->caliCompass) {
|
||||
this->removeChildComponent(this->caliCompass);
|
||||
this->caliCompass = caliCompass;
|
||||
}
|
||||
}
|
||||
|
||||
void ManualControl::switchInputMode() {
|
||||
this->inputMode = (this->inputMode == InputMode::Analog) ? InputMode::Digital : InputMode::Analog;
|
||||
}
|
||||
@@ -51,7 +32,7 @@ void ManualControl::switchInputMode() {
|
||||
void ManualControl::analogControl() {
|
||||
// Have to be int16_t to avoid overflow (int8_t = 255 - 127 = -128)
|
||||
int16_t x = this->input->x - 127;
|
||||
int16_t y = this->input->y - 127;
|
||||
int16_t y = this-> input->y - 127;
|
||||
|
||||
// static int counter = 0;
|
||||
// if (counter % 60 == 0) {
|
||||
|
||||
@@ -11,10 +11,7 @@
|
||||
#ifndef MANUAL_CONTROL_H
|
||||
#define MANUAL_CONTROL_H
|
||||
|
||||
#include "moveControl.h"
|
||||
#include "driveModi/driveModi.h"
|
||||
#include "controlPadInput.h"
|
||||
#include "calibrateCompass.h"
|
||||
|
||||
class DirectionChangeWrapper {
|
||||
public:
|
||||
@@ -36,10 +33,7 @@ class ManualControl : public DriveModi {
|
||||
Digital
|
||||
};
|
||||
|
||||
ManualControl(MoveControl *moveControl, const ControlPadInput *input);
|
||||
~ManualControl();
|
||||
|
||||
void setCalibrateCompass(CalibrateCompass* caliCompass = nullptr);
|
||||
ManualControl(DriveModiParams params) : DriveModi(params){};
|
||||
|
||||
void switchInputMode();
|
||||
void setInputMode(InputMode mode) { this->inputMode = mode; }
|
||||
@@ -51,14 +45,12 @@ class ManualControl : public DriveModi {
|
||||
|
||||
protected:
|
||||
void run() override;
|
||||
const ControlPadInput* input;
|
||||
|
||||
private:
|
||||
void analogControl();
|
||||
void digitalControl();
|
||||
|
||||
bool lastLoopTurned = false;
|
||||
CalibrateCompass* caliCompass = nullptr;
|
||||
DirectionChangeWrapper* directionChangeWrapper = nullptr;
|
||||
InputMode inputMode = InputMode::Analog;
|
||||
};
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
*/
|
||||
#include "testMode.h"
|
||||
|
||||
TestMode::TestMode(MoveControl *moveControl, Navigation* navigation)
|
||||
: DriveModi(moveControl) {
|
||||
TestMode::TestMode(DriveModiParams params, Navigation* navigation)
|
||||
: DriveModi(params) {
|
||||
this->navigation = navigation;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ TestMode::~TestMode() {
|
||||
|
||||
void TestMode::run() {
|
||||
if (this->maneuver == Maneuver::Turn) {
|
||||
uint16_t delta = abs(this->azimuth - this->navigation->getAzimuth());
|
||||
uint16_t delta = abs(this->azimuth - this->getSensorData()->getRealAzimuth());
|
||||
if (delta > this->degree)
|
||||
this->abort = true;
|
||||
}
|
||||
@@ -50,7 +50,7 @@ bool TestMode::drive(int16_t cm, int16_t degree) {
|
||||
else if (degree > 0)
|
||||
this->moveControl->setRotationSpeed(this->maxRotationSpeed);
|
||||
|
||||
this->azimuth = this->navigation->getAzimuth();
|
||||
this->azimuth = this->getSensorData()->getRealAzimuth();
|
||||
this->degree = degree;
|
||||
|
||||
this->maneuverTime = 5 * 1000;
|
||||
|
||||
@@ -44,7 +44,7 @@ class TestMode : public DriveModi {
|
||||
* @param moveControl
|
||||
* @param navigation
|
||||
*/
|
||||
TestMode(MoveControl *moveControl, Navigation* navigation);
|
||||
TestMode(DriveModiParams params, Navigation* navigation);
|
||||
~TestMode();
|
||||
|
||||
bool drive(int16_t cm = 0, int16_t degree = 0);
|
||||
|
||||
Reference in New Issue
Block a user