refactore
This commit is contained in:
@@ -65,15 +65,6 @@ bool Navigation::startNavigation() {
|
||||
return this->navigationStarted;
|
||||
}
|
||||
|
||||
void Navigation::drivingDirectionChange() {
|
||||
Point tmp = this->currentPosition;
|
||||
if (tmp.isInit() && tmp.isValid()) {
|
||||
this->directionChangeMode = true;
|
||||
this->lastPointDrivingDirectionChange = tmp;
|
||||
this->calcAzimuthState = CalcAzimuthState::Invalid;
|
||||
}
|
||||
}
|
||||
|
||||
Navigation::Status Navigation::getCourseCorrection(CourseCorrection& correction, bool forceUpdate) {
|
||||
if (this->navigationFinished)
|
||||
return Status::Complete;
|
||||
@@ -142,60 +133,6 @@ void Navigation::updateCurrentLocation() {
|
||||
this->currentPosition = Point(coords, this->ubxData->hAcc);
|
||||
}
|
||||
|
||||
void Navigation::updateMagneticDeclination() {
|
||||
if (!this->directionChangeMode
|
||||
|| this->lastPointDrivingDirectionChange.distanceTo(this->currentPosition) < 1.0)
|
||||
{
|
||||
this->calcAzimuthState = CalcAzimuthState::Invalid;
|
||||
this->calcAzimuth = 999;
|
||||
return;
|
||||
}
|
||||
|
||||
this->calcAzimuth = this->lastPointDrivingDirectionChange.courseTo(this->currentPosition);
|
||||
|
||||
// Map point accuracy to CalcAzimuthState
|
||||
if (this->lastPointDrivingDirectionChange.getAccuracy() == Point::Accuracy::oneDigOfCM
|
||||
|| this->currentPosition.getAccuracy() == Point::Accuracy::oneDigOfCM)
|
||||
{
|
||||
this->calcAzimuthState = CalcAzimuthState::Good;
|
||||
}
|
||||
else if (this->lastPointDrivingDirectionChange.getAccuracy() == Point::Accuracy::twoDigOfCM
|
||||
|| this->currentPosition.getAccuracy() == Point::Accuracy::twoDigOfCM)
|
||||
{
|
||||
this->calcAzimuthState = CalcAzimuthState::Ok;
|
||||
}
|
||||
else if (this->lastPointDrivingDirectionChange.getAccuracy() == Point::Accuracy::threeDigOfCM
|
||||
|| this->currentPosition.getAccuracy() == Point::Accuracy::threeDigOfCM)
|
||||
{
|
||||
this->calcAzimuthState = CalcAzimuthState::Bad;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->calcAzimuthState = CalcAzimuthState::Invalid;
|
||||
}
|
||||
|
||||
// Upgrade quality if the range grows up
|
||||
if (this->lastPointDrivingDirectionChange.distanceTo(this->currentPosition) > 2.0) {
|
||||
switch (this->calcAzimuthState) {
|
||||
case CalcAzimuthState::Bad :
|
||||
this->calcAzimuthState = CalcAzimuthState::Ok;
|
||||
break;
|
||||
|
||||
case CalcAzimuthState::Ok :
|
||||
this->calcAzimuthState = CalcAzimuthState::Good;
|
||||
break;
|
||||
|
||||
case CalcAzimuthState::Good :
|
||||
this->calcAzimuthState = CalcAzimuthState::Super;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int16_t Navigation::calculateCourseCorrection(Point& point) {
|
||||
int16_t targetCourse = point.courseTo(this->targetPoint);
|
||||
int16_t correctionCourse;
|
||||
|
||||
@@ -90,8 +90,7 @@ class Navigation : public Component {
|
||||
*/
|
||||
bool startNavigation();
|
||||
void freezeTargetPoint(bool val = true) { this->preventNextPoint = val; };
|
||||
void drivingDirectionChange();
|
||||
void disableCalcAzimuth() { this->directionChangeMode = false; }
|
||||
|
||||
|
||||
double increaseMinDistanceToReachPoint() { return this->minDistanceToReachPoint += 0.1; }
|
||||
double decreaseMinDistanceToReachPoint() { return this->minDistanceToReachPoint -= 0.1; }
|
||||
@@ -148,20 +147,6 @@ class Navigation : public Component {
|
||||
Route* getRoute() const { return this->route; }
|
||||
Point getCurrentPosition() const { return this->currentPosition; }
|
||||
|
||||
/**
|
||||
* @brief Get realAzimuth
|
||||
*
|
||||
* This value represents the angle between north and
|
||||
* the line of sight. Clockwise.
|
||||
*
|
||||
* @return uint16_t degree
|
||||
*/
|
||||
int16_t getAzimuth() const { return this->realAzimuth; }
|
||||
QMC5883LCompass* getCompass() const { return this->compass; }
|
||||
int16_t getCalcAzimuth() const { return this->calcAzimuth; }
|
||||
CalcAzimuthState getCalcAzimuthState() const { return this->calcAzimuthState; }
|
||||
bool getLastUsedCalcAzimuth() const { return this->lastUsedCalcAzimuth; }
|
||||
|
||||
Point::Accuracy getMinAccuracy() const { return this->minAccuracy; }
|
||||
void setMinAccuracy(Point::Accuracy accuracy) { this->minAccuracy = accuracy; }
|
||||
|
||||
@@ -170,7 +155,6 @@ class Navigation : public Component {
|
||||
|
||||
private:
|
||||
void run() override;
|
||||
void updateMagneticDeclination();
|
||||
void init(Route* route);
|
||||
bool nextPoint();
|
||||
bool setTargetPoint(Point target);
|
||||
@@ -206,8 +190,6 @@ class Navigation : public Component {
|
||||
char* user;
|
||||
char* password;
|
||||
|
||||
int16_t calcAzimuth = INT16_MAX;
|
||||
|
||||
uint8_t timeToWait = 200;
|
||||
uint16_t port;
|
||||
uint32_t lastMillis = 0;
|
||||
|
||||
Reference in New Issue
Block a user