added extra function for azimuth overflow
This commit is contained in:
@@ -263,17 +263,8 @@ int16_t Navigation::calculateCourseCorrection(Point& point) {
|
|||||||
correctionCourse = targetCourse - this->realAzimuth;
|
correctionCourse = targetCourse - this->realAzimuth;
|
||||||
this->lastUsedCalcAzimuth = false;
|
this->lastUsedCalcAzimuth = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (correctionCourse > 180)
|
return Navigation::fixDegree(correctionCourse);
|
||||||
correctionCourse -= 360;
|
|
||||||
else if (correctionCourse < -180)
|
|
||||||
correctionCourse += 360;
|
|
||||||
|
|
||||||
//Rotate result by 180° to corrigate Azimuth
|
|
||||||
correctionCourse += 180;
|
|
||||||
correctionCourse = correctionCourse > 180 ? correctionCourse -360 : correctionCourse;
|
|
||||||
|
|
||||||
return correctionCourse;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Navigation::nextPoint() {
|
bool Navigation::nextPoint() {
|
||||||
@@ -294,6 +285,16 @@ void Navigation::setOutputStatusPrintPVTdata(bool status) {
|
|||||||
Navigation::outputStatusPrintPVTdata = status;
|
Navigation::outputStatusPrintPVTdata = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int16_t Navigation::fixDegree(int16_t degree) {
|
||||||
|
while (degree < -180 || degree > 180) {
|
||||||
|
if (degree > 180)
|
||||||
|
degree -= 360;
|
||||||
|
else if (degree < -180)
|
||||||
|
degree += 360;
|
||||||
|
}
|
||||||
|
return degree;
|
||||||
|
}
|
||||||
|
|
||||||
void Navigation::printPVTdata(UBX_NAV_PVT_data_t *ubxDataStruct) {
|
void Navigation::printPVTdata(UBX_NAV_PVT_data_t *ubxDataStruct) {
|
||||||
if (!Navigation::outputStatusPrintPVTdata)
|
if (!Navigation::outputStatusPrintPVTdata)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -210,6 +210,8 @@ class Navigation {
|
|||||||
* @param status
|
* @param status
|
||||||
*/
|
*/
|
||||||
static void setOutputStatusPrintPVTdata(bool status);
|
static void setOutputStatusPrintPVTdata(bool status);
|
||||||
|
// map input in range from -180 to 180 degree
|
||||||
|
static int16_t fixDegree(int16_t degree);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateCurrentLocation();
|
void updateCurrentLocation();
|
||||||
|
|||||||
Reference in New Issue
Block a user