added more functions for capture route

This commit is contained in:
2022-02-01 18:26:57 +01:00
parent 44be2b2b77
commit 894f3439bd
12 changed files with 59 additions and 15 deletions
+1
View File
@@ -26,6 +26,7 @@ class MenuDriveMode : public MenuControl {
void yes(){}
virtual void printMenu() = 0;
void update(){}
protected:
DriveManager* driveManager;
@@ -7,8 +7,16 @@ CaptureRoute::CaptureRoute(MoveControl* moveControl, Navigation* navigation)
void CaptureRoute::loop() {
ManualControl::loop();
if (millis() - this->last_millis < delay) {
return;
}
this->runCaptureRoute();
this->last_millis = millis();
}
void CaptureRoute::runCaptureRoute() {
if (Ps3.data.button.triangle) {
this->navigation->addCurrentPosToRoute();
}
}
@@ -6,6 +6,7 @@
#include "driveModi/Modi/ManualControl/manualControl.h"
#include "navigation.h"
class CaptureRoute : public ManualControl {
public:
CaptureRoute(MoveControl* moveControl, Navigation* navigation);
@@ -15,6 +16,9 @@ class CaptureRoute : public ManualControl {
private:
Navigation* navigation;
uint32_t last_millis = 0;
uint16_t delay = 200;
};
#endif // CAPTURE_ROUTE_H
@@ -22,12 +22,11 @@ ManualControl::~ManualControl() {
}
void ManualControl::loop() {
static uint32_t last_millis = 0;
if (millis() - last_millis < delay) {
if (millis() - this->last_millis < delay) {
return;
}
this->runManualControl();
last_millis = millis();
this->last_millis = millis();
}
void ManualControl::runManualControl() {
@@ -11,8 +11,6 @@
#ifndef MANUAL_CONTROL_H
#define MANUAL_CONTROL_H
#include <Ps3Controller.h>
#include "moveControl.h"
#include "driveModi/driveModi.h"
@@ -74,6 +72,7 @@ class ManualControl : public DriveModi{
private:
MoveControl *moveControl;
uint32_t last_millis = 0;
uint8_t delay = 10;
double max_speed = 1;
double max_rotation = 7;
+5
View File
@@ -17,6 +17,11 @@ Modi& operator++(Modi& m, int) {
DriveManager::DriveManager(MoveControl *moveControl) {
this->moveControl = moveControl;
this->navigation = new Navigation(17, 16);
}
DriveManager::~DriveManager() {
delete this->navigation;
}
void DriveManager::loop() {
+2 -1
View File
@@ -42,6 +42,7 @@ enum class Modi {
class DriveManager {
public:
DriveManager(MoveControl *moveControl);
~DriveManager();
void loop();
void nextModus();
@@ -54,7 +55,7 @@ class DriveManager {
private:
Modi currentModus = Modi::Off;
MoveControl *moveControl;
DriveModi *currentModusPtr;
DriveModi *currentModusPtr = nullptr;
Navigation* navigation;
};
+2
View File
@@ -12,6 +12,8 @@
#ifndef DRIVEMODI_H
#define DRIVEMODI_H
#include <Ps3Controller.h>
class DriveModi {
public:
DriveModi(){}
+4
View File
@@ -39,6 +39,7 @@ void exitDriveMode() {driveManager.changeModus(Modi::Off);}
void setup() {
Serial.begin(115200);
std::cout << "Welcome to Kleiax-Rover" << std::endl;
std::cout << "All actions from the main programm run on" << xPortGetCoreID() << std::endl;
Wire.begin(21, 19);
// i2cScanner();
@@ -146,10 +147,13 @@ void callbackControllerAction() {
isDelayReached(true);
}
// This have to be stand here because it have to be run on the other Core
main_m->update();
}
void callbackControllerConnect() {
std::cout << "Controller connected to ESP32" << std::endl;
std::cout << "All actions from the Controller run on" << xPortGetCoreID() << std::endl;
// TODO: Display is not functional without this seconde init, first init is in setup()
lcd->init();