included calibrateCompass to the manualDrive menu
This commit is contained in:
@@ -66,6 +66,9 @@ void CalibrateCompass::loop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CalibrateCompass::start() {
|
void CalibrateCompass::start() {
|
||||||
|
if (this->state != State::Ready)
|
||||||
|
return;
|
||||||
|
|
||||||
this->clearData();
|
this->clearData();
|
||||||
this->state = State::Calibrating;
|
this->state = State::Calibrating;
|
||||||
this->compass->setCalibration(0, 0, 0, 0, 0, 0);
|
this->compass->setCalibration(0, 0, 0, 0, 0, 0);
|
||||||
@@ -85,8 +88,13 @@ void CalibrateCompass::useData() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CalibrateCompass::resetData() {
|
||||||
|
this->reset();
|
||||||
|
this->compass->setCalibration(0, 0, 0, 0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
void CalibrateCompass::reset() {
|
void CalibrateCompass::reset() {
|
||||||
this->start();
|
this->clearData();
|
||||||
this->state = State::Ready;
|
this->state = State::Ready;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
class CalibrateCompass {
|
class CalibrateCompass {
|
||||||
public:
|
public:
|
||||||
enum State {
|
enum State {
|
||||||
None,
|
|
||||||
Ready,
|
Ready,
|
||||||
Calibrating,
|
Calibrating,
|
||||||
Finished
|
Finished
|
||||||
@@ -31,6 +30,7 @@ class CalibrateCompass {
|
|||||||
void loop();
|
void loop();
|
||||||
void start();
|
void start();
|
||||||
void useData();
|
void useData();
|
||||||
|
void resetData();
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
State getState() const { return this->state; }
|
State getState() const { return this->state; }
|
||||||
@@ -38,7 +38,7 @@ class CalibrateCompass {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QMC5883LCompass* compass;
|
QMC5883LCompass* compass;
|
||||||
State state = State::None;
|
State state;
|
||||||
CallibrationData data;
|
CallibrationData data;
|
||||||
|
|
||||||
void clearData();
|
void clearData();
|
||||||
|
|||||||
@@ -10,6 +10,15 @@
|
|||||||
*/
|
*/
|
||||||
#include "menuManualDrive.h"
|
#include "menuManualDrive.h"
|
||||||
|
|
||||||
|
MenuManualControl::MenuManualControl(DriveManager* driveManager) : MenuDriveMode(driveManager) {
|
||||||
|
this->caliCompass = new CalibrateCompass(this->driveManager->getNavigation()->getCompass());
|
||||||
|
}
|
||||||
|
|
||||||
|
MenuManualControl::~MenuManualControl() {
|
||||||
|
delete this->caliCompass;
|
||||||
|
this->manualControl->setCalibrateCompass();
|
||||||
|
}
|
||||||
|
|
||||||
void MenuManualControl::printPage() const {
|
void MenuManualControl::printPage() const {
|
||||||
String lineOne = "";
|
String lineOne = "";
|
||||||
String lineTwo = "";
|
String lineTwo = "";
|
||||||
@@ -53,6 +62,28 @@ void MenuManualControl::printPage() const {
|
|||||||
lineTwo.concat(this->manualControl->getDutycycleRight());
|
lineTwo.concat(this->manualControl->getDutycycleRight());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 7:
|
||||||
|
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;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
this->printDefault();
|
this->printDefault();
|
||||||
return;
|
return;
|
||||||
@@ -87,6 +118,24 @@ void MenuManualControl::runCommand() const {
|
|||||||
case 4:
|
case 4:
|
||||||
this->manualControl->increaseMaxRotation();
|
this->manualControl->increaseMaxRotation();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 7:
|
||||||
|
switch (this->caliCompass->getState()) {
|
||||||
|
case CalibrateCompass::State::Ready :
|
||||||
|
this->manualControl->setCalibrateCompass(this->caliCompass);
|
||||||
|
this->caliCompass->start();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CalibrateCompass::State::Finished:
|
||||||
|
this->manualControl->setCalibrateCompass();
|
||||||
|
this->caliCompass->useData();
|
||||||
|
this->caliCompass->reset();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
#define MENU_MANUAL_DRIVE_H
|
#define MENU_MANUAL_DRIVE_H
|
||||||
|
|
||||||
#include "SpecialMenus/driveModi/menuDriveMode.h"
|
#include "SpecialMenus/driveModi/menuDriveMode.h"
|
||||||
|
#include "calibrateCompass.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief A class to print informations about the class ManualControl
|
* @brief A class to print informations about the class ManualControl
|
||||||
@@ -25,7 +26,8 @@ class MenuManualControl : public MenuDriveMode {
|
|||||||
*
|
*
|
||||||
* @param driveManager
|
* @param driveManager
|
||||||
*/
|
*/
|
||||||
MenuManualControl(DriveManager* driveManager) : MenuDriveMode(driveManager) {}
|
MenuManualControl(DriveManager* driveManager);
|
||||||
|
~MenuManualControl();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Prints the Information to display and console
|
* @brief Prints the Information to display and console
|
||||||
@@ -43,6 +45,7 @@ class MenuManualControl : public MenuDriveMode {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
ManualControl* manualControl;
|
ManualControl* manualControl;
|
||||||
|
CalibrateCompass* caliCompass;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MENU_MANUAL_DRIVE_H
|
#endif // MENU_MANUAL_DRIVE_H
|
||||||
|
|||||||
@@ -23,6 +23,9 @@ ManualControl::~ManualControl() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ManualControl::loop() {
|
void ManualControl::loop() {
|
||||||
|
if (caliCompass)
|
||||||
|
this->caliCompass->loop();
|
||||||
|
|
||||||
if (millis() - this->lastMillis < delay) {
|
if (millis() - this->lastMillis < delay) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#include "moveControl.h"
|
#include "moveControl.h"
|
||||||
#include "driveModi/driveModi.h"
|
#include "driveModi/driveModi.h"
|
||||||
#include "controlPadInput.h"
|
#include "controlPadInput.h"
|
||||||
|
#include "calibrateCompass.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Drive the Rover with a Joystick
|
* @brief Drive the Rover with a Joystick
|
||||||
@@ -76,6 +77,8 @@ class ManualControl : public DriveModi {
|
|||||||
void decreaseMaxRotation(double increase = 0.1) { max_rotation -= increase; }
|
void decreaseMaxRotation(double increase = 0.1) { max_rotation -= increase; }
|
||||||
double getMaxRotation() { return this->max_rotation; }
|
double getMaxRotation() { return this->max_rotation; }
|
||||||
|
|
||||||
|
void setCalibrateCompass(CalibrateCompass* val = nullptr) { this->caliCompass = val; }
|
||||||
|
|
||||||
uint16_t getDutycycleLeft() const { return this->moveControl->getDutycycleLeft(); }
|
uint16_t getDutycycleLeft() const { return this->moveControl->getDutycycleLeft(); }
|
||||||
uint16_t getDutycycleRight() const { return this->moveControl->getDutycycleRight(); }
|
uint16_t getDutycycleRight() const { return this->moveControl->getDutycycleRight(); }
|
||||||
|
|
||||||
@@ -88,6 +91,7 @@ class ManualControl : public DriveModi {
|
|||||||
uint8_t delay = 10;
|
uint8_t delay = 10;
|
||||||
double max_speed = 1;
|
double max_speed = 1;
|
||||||
double max_rotation = 7;
|
double max_rotation = 7;
|
||||||
|
CalibrateCompass* caliCompass = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MANUAL_CONTROL_H
|
#endif // MANUAL_CONTROL_H
|
||||||
|
|||||||
Reference in New Issue
Block a user