bauen klappt wieder, navigation ist kaputt, todo: und fixme: beachten!

This commit is contained in:
2022-08-17 16:37:47 +02:00
parent f2d57cc13f
commit c7cb0d3895
7 changed files with 104 additions and 71 deletions
+5 -2
View File
@@ -39,7 +39,8 @@ Navigation::~Navigation() {
}
void Navigation::loop() {
this->gps->checkUbloxI2C();
//FIXME: Hier sollte funktion zum aktualisieren des GPS Moduls stehen
//this->gps->checkUbloxI2C();
}
void Navigation::newRoute() {
@@ -76,7 +77,9 @@ CourseCorrection Navigation::getCourseCorrection() {
}
}
double currentCourse = this->gps->course.deg();
//FIXME: next line
double currentCourse = 0;
//double currentCourse = this->gps->course.deg();
int16_t correction = currentCourse - targetCourse;
if (correction > 180)
correction -= 360;
+2 -2
View File
@@ -110,9 +110,9 @@ class Navigation {
/**
* @brief Returns the GPS object
*
* @return TinyGPSPlus*
* @return SFE_UBLOX_GNSS*
*/
TinyGPSPlus* getGPS() { return this->gps; }
SFE_UBLOX_GNSS* getGPS() { return this->gps; }
/**
* @brief Get the Route Info object
+30
View File
@@ -8,3 +8,33 @@
* @copyright Copyright (c) 2022
*
*/
#include "navigationUtils.h"
double NavigationUtils::getCurrentCourse(Point p1) {
//TODO: write it!!!
return 0;
}
void NavigationUtils::setLastPoint(Point p1) {
this->lastPoint = p1;
}
double NavigationUtils::courseTo(Point p1, Point p2) {
//TODO: write it!!!
return 0;
}
double NavigationUtils::courseTo(double lat1, double lon1, double lat2, double lon2) {
return NavigationUtils::courseTo(Point(lat1, lon1), Point(lat2, lon2));
}
double NavigationUtils::distanceBetween(Point p1, Point p2) {
//TODO: write it!!!
return 0;
}
double NavigationUtils::distanceBetween(double lat1, double lon1, double lat2, double lon2) {
return NavigationUtils::distanceBetween(Point(lat1, lon1), Point(lat2, lon2));
}
+1 -1
View File
@@ -15,7 +15,7 @@
class NavigationUtils {
public:
void getCurrentCourse(Point p1);
double getCurrentCourse(Point p1);
void setLastPoint(Point p1);
static double courseTo(Point p1, Point p2);
+62 -61
View File
@@ -11,7 +11,7 @@
#include "menuGPS.h"
MenuGPS::MenuGPS(TinyGPSPlus* gps) {
MenuGPS::MenuGPS(SFE_UBLOX_GNSS* gps) {
this->gps = gps;
this->last_millis = millis();
}
@@ -62,67 +62,68 @@ void MenuGPS::update() {
}
void MenuGPS::printPage(uint8_t page) const {
switch (this->currentPage) {
case 0:
if (this->lcd) {
lcd->clear();
lcd->setCursor(0, 0);
if (gps->satellites.isValid() && gps->satellites.value() > 2) {
lcd->printf("Sats: %3.d", gps->satellites.value());
lcd->setCursor(0, 1);
lcd->printf("HDOP: %f", gps->hdop.hdop());
} else {
lcd->printf("Data isn't valid");
lcd->setCursor(0, 1);
lcd->printf("or no GPS signal");
}
}
if (gps->satellites.isValid() && gps->satellites.value() > 2)
std::cout << "Sats: " << gps->satellites.value()
<< "HDOP: " << gps->hdop.hdop() << std::endl;
else
std::cout << "Data isn't valid or no GPS signal" << std::endl;
break;
//FIXME: new gpslib
// switch (this->currentPage) {
// case 0:
// if (this->lcd) {
// lcd->clear();
// lcd->setCursor(0, 0);
// if (gps->satellites.isValid() && gps->satellites.value() > 2) {
// lcd->printf("Sats: %3.d", gps->satellites.value());
// lcd->setCursor(0, 1);
// lcd->printf("HDOP: %f", gps->hdop.hdop());
// } else {
// lcd->printf("Data isn't valid");
// lcd->setCursor(0, 1);
// lcd->printf("or no GPS signal");
// }
// }
// if (gps->satellites.isValid() && gps->satellites.value() > 2)
// std::cout << "Sats: " << gps->satellites.value()
// << "HDOP: " << gps->hdop.hdop() << std::endl;
// else
// std::cout << "Data isn't valid or no GPS signal" << std::endl;
// break;
case 1:
if (this->lcd) {
lcd->clear();
lcd->setCursor(0, 0);
if (gps->location.isValid() && gps->satellites.value() > 2) {
lcd->printf("Lat: %9.6f", gps->location.lat());
lcd->setCursor(0, 1);
lcd->printf("Lng: %9.6f", gps->location.lng());
} else {
lcd->printf("Data isn't valid");
lcd->setCursor(0, 1);
lcd->printf("or NO GPS signal");
}
}
if (gps->satellites.isValid() && gps->satellites.value() > 2)
std::cout << "Lat: " << gps->location.lat()
<< "Lng: " << gps->location.lng() << std::endl;
else
std::cout << "Data isn't valid or NO GPS signal" << std::endl;
break;
// case 1:
// if (this->lcd) {
// lcd->clear();
// lcd->setCursor(0, 0);
// if (gps->location.isValid() && gps->satellites.value() > 2) {
// lcd->printf("Lat: %9.6f", gps->location.lat());
// lcd->setCursor(0, 1);
// lcd->printf("Lng: %9.6f", gps->location.lng());
// } else {
// lcd->printf("Data isn't valid");
// lcd->setCursor(0, 1);
// lcd->printf("or NO GPS signal");
// }
// }
// if (gps->satellites.isValid() && gps->satellites.value() > 2)
// std::cout << "Lat: " << gps->location.lat()
// << "Lng: " << gps->location.lng() << std::endl;
// else
// std::cout << "Data isn't valid or NO GPS signal" << std::endl;
// break;
case 2:
if (this->lcd) {
lcd->clear();
lcd->setCursor(0, 0);
lcd->printf("Chars processed");
lcd->setCursor(0, 1);
lcd->printf("-> %u", gps->charsProcessed());
}
std::cout << "Chars processed: " << gps->charsProcessed() << std::endl;
break;
// case 2:
// if (this->lcd) {
// lcd->clear();
// lcd->setCursor(0, 0);
// lcd->printf("Chars processed");
// lcd->setCursor(0, 1);
// lcd->printf("-> %u", gps->charsProcessed());
// }
// std::cout << "Chars processed: " << gps->charsProcessed() << std::endl;
// break;
default:
if (this->lcd) {
lcd->clear();
lcd->setCursor(0, 0);
lcd->printf("Page: %u", page);
}
std::cout << "Page: " << (int) page << std::endl;
break;
}
// default:
// if (this->lcd) {
// lcd->clear();
// lcd->setCursor(0, 0);
// lcd->printf("Page: %u", page);
// }
// std::cout << "Page: " << (int) page << std::endl;
// break;
// }
}
+3 -3
View File
@@ -12,7 +12,7 @@
#ifndef MENU_GPS_H
#define MENU_GPS_H
#include <TinyGPS++.h>
#include <SparkFun_u-blox_GNSS_Arduino_Library.h>
#include "menuControl.h"
@@ -27,7 +27,7 @@ class MenuGPS : public MenuControl {
*
* @param gps
*/
MenuGPS(TinyGPSPlus* gps);
MenuGPS(SFE_UBLOX_GNSS* gps);
/**
@@ -79,7 +79,7 @@ class MenuGPS : public MenuControl {
uint8_t currentPage = 0;
void printPage(const uint8_t page) const;
TinyGPSPlus* gps;
SFE_UBLOX_GNSS* gps;
const uint16_t delay = 5000;
uint32_t last_millis = 0;
+1 -2
View File
@@ -17,8 +17,7 @@ Modi& operator++(Modi& m, int) {
DriveManager::DriveManager(MoveControl *moveControl) {
this->moveControl = moveControl;
// TODO: Delete magic numbers
this->navigation = new Navigation(17, 16);
this->navigation = new Navigation();
}
DriveManager::~DriveManager() {