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;
|
||||
|
||||
Reference in New Issue
Block a user