zwischenstand, ich habe Lust mache jetzt weiter :)

This commit is contained in:
2022-01-12 15:21:53 +01:00
parent 29a636060c
commit be6f20d96b
10 changed files with 181 additions and 118 deletions
+1 -4
View File
@@ -1,12 +1,9 @@
#include "driveModi/Modi/Autopilot/autopilot.h"
Autopilot::Autopilot() {
this->debug = new DebugMqtt("Autopilot");
}
void Autopilot::init(Route *route, MoveControl *moveControl) {
this->route = route;
this->moveControl = moveControl;
void Autopilot::init() {
}
void Autopilot::runAutopilot() {
+1 -2
View File
@@ -12,13 +12,12 @@ class Autopilot : DriveModi{
public:
Autopilot();
void init(Route *route, MoveControl *moveControl);
void init();
void loop();
void runAutopilot();
private:
Route *route;
MoveControl *moveControl;
DebugMqtt *debug;
+5 -1
View File
@@ -18,7 +18,7 @@ DriveManager driveManager(&moveController);
void setup() {
Serial.begin(115200);
Serial.println("Welcome...");
Serial.println("Welcome to Kleiax-Rover");
Network::setIps();
Network::connectWifi();
@@ -30,11 +30,15 @@ void setup() {
Ps3.begin();
driveManager.changeModus(Modi::ManualControl);
Serial1.begin(GPS_BAUD, SERIAL_8N1, GPS_RX, GPS_TX);
}
void loop() {
Network::checkMQTT();
driveManager.loop();
while (Serial1.available() > 0)
Serial.print(Serial1.read());
}
void callbackControllerAction() {
+65 -65
View File
@@ -1,80 +1,80 @@
#include "route.h"
#include "config.h"
// #include "route.h"
// #include "config.h"
Route::Route() {
Serial1.begin(GPS_BAUD, SERIAL_8N1, GPS_RX, GPS_TX);
this->debug = new DebugMqtt("Route");
}
// Route::Route() {
// Serial1.begin(GPS_BAUD, SERIAL_8N1, GPS_RX, GPS_TX);
// this->debug = new DebugMqtt("Route");
// }
void Route::runRoute() {
static uint64_t last_millis = 0;
if (millis() - last_millis < 123456789) {
return;
}
last_millis = millis();
// void Route::runRoute() {
// static uint64_t last_millis = 0;
// if (millis() - last_millis < 123456789) {
// return;
// }
// last_millis = millis();
while (Serial1.available() > 0)
gps.encode(Serial1.read());
// while (Serial1.available() > 0)
// gps.encode(Serial1.read());
if (gps.location.isUpdated() && gps.location.isValid()) {
this->currentLocation.lat = gps.location.lat();
this->currentLocation.lon = gps.location.lng();
}
}
// if (gps.location.isUpdated() && gps.location.isValid()) {
// this->currentLocation.lat = gps.location.lat();
// this->currentLocation.lon = gps.location.lng();
// }
// }
void Route::addPointToRoute(Point point) {
this->points.push_back(point);
this->count_points++;
}
// void Route::addPointToRoute(Point point) {
// this->points.push_back(point);
// this->count_points++;
// }
void Route::addCurrentLocationToRoute() {
if (*this->points.end() == this->currentLocation &&
!this->nearlySameLocation(*this->points.end(), this->currentLocation)) {
return;
}
this->addPointToRoute(currentLocation);
}
// void Route::addCurrentLocationToRoute() {
// if (*this->points.end() == this->currentLocation &&
// !this->nearlySameLocation(*this->points.end(), this->currentLocation)) {
// return;
// }
// this->addPointToRoute(currentLocation);
// }
void Route::delRoute() {
this->points.clear();
this->count_points = 0;
}
// void Route::delRoute() {
// this->points.clear();
// this->count_points = 0;
// }
Point Route::startRoute() {
this->route_started = true;
this->route_finished = false;
// Point Route::startRoute() {
// this->route_started = true;
// this->route_finished = false;
this->it = this->points.begin();
return *it;
}
// this->it = this->points.begin();
// return *it;
// }
Point Route::getNextPoint() {
if (this->route_started && !route_finished) {
it++;
return *it;
}
// Point Route::getNextPoint() {
// if (this->route_started && !route_finished) {
// it++;
// return *it;
// }
if (it == this->points.end()) {
this->route_finished = true;
}
// if (it == this->points.end()) {
// this->route_finished = true;
// }
Point fail;
return fail;
}
// Point fail;
// return fail;
// }
uint16_t Route::getNumberOfPoints() {
return this->count_points;
}
// uint16_t Route::getNumberOfPoints() {
// return this->count_points;
// }
double Route::getDis(Point point_1, Point point_2) {
double lat = (point_1.lat + point_2.lat) / 2 * 0.1745;
double dx = 111.3 * cos(lat) * (point_1.lon - point_2.lon);
double dy = 111.3 * (point_1.lat - point_2.lat);
return sqrt(dx * dx + dy * dy);
}
// double Route::getDis(Point point_1, Point point_2) {
// double lat = (point_1.lat + point_2.lat) / 2 * 0.1745;
// double dx = 111.3 * cos(lat) * (point_1.lon - point_2.lon);
// double dy = 111.3 * (point_1.lat - point_2.lat);
// return sqrt(dx * dx + dy * dy);
// }
bool Route::nearlySameLocation(Point p1, Point p2) {
if (this->getDis(p1, p2) < 0.5)
return true;
return false;
}
// bool Route::nearlySameLocation(Point p1, Point p2) {
// if (this->getDis(p1, p2) < 0.5)
// return true;
// return false;
// }