Skip to content

Commit 42ced25

Browse files
authored
Merge pull request #9111 from M0j0Risin/release_6.1.1
Proposed fix for "dolphining" bug in 6.1
2 parents 4fa62aa + 00a4eb1 commit 42ced25

File tree

1 file changed

+13
-21
lines changed

1 file changed

+13
-21
lines changed

src/main/navigation/navigation_pos_estimator.c

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,6 @@ void updatePositionEstimator_BaroTopic(timeUs_t currentTimeUs)
327327
else {
328328
posEstimator.baro.alt = 0;
329329
posEstimator.baro.lastUpdateTime = 0;
330-
posEstimator.baro.epv = positionEstimationConfig()->max_eph_epv;
331330
}
332331
}
333332
#endif
@@ -555,8 +554,15 @@ static void estimationPredict(estimationContext_t * ctx)
555554
}
556555

557556
static bool estimationCalculateCorrection_Z(estimationContext_t * ctx)
558-
{
559-
bool correctionCalculated = false;
557+
{
558+
DEBUG_SET(DEBUG_ALTITUDE, 0, posEstimator.est.pos.z); // Position estimate
559+
DEBUG_SET(DEBUG_ALTITUDE, 2, posEstimator.baro.alt); // Baro altitude
560+
DEBUG_SET(DEBUG_ALTITUDE, 4, posEstimator.gps.pos.z); // GPS altitude
561+
DEBUG_SET(DEBUG_ALTITUDE, 6, accGetVibrationLevel()); // Vibration level
562+
DEBUG_SET(DEBUG_ALTITUDE, 1, posEstimator.est.vel.z); // Vertical speed estimate
563+
DEBUG_SET(DEBUG_ALTITUDE, 3, posEstimator.imu.accelNEU.z); // Vertical acceleration on earth frame
564+
DEBUG_SET(DEBUG_ALTITUDE, 5, posEstimator.gps.vel.z); // GPS vertical speed
565+
DEBUG_SET(DEBUG_ALTITUDE, 7, accGetClipCount()); // Clip count
560566

561567
if (ctx->newFlags & EST_BARO_VALID) {
562568
timeUs_t currentTimeUs = micros();
@@ -602,12 +608,9 @@ static bool estimationCalculateCorrection_Z(estimationContext_t * ctx)
602608
ctx->accBiasCorr.z -= baroAltResidual * sq(positionEstimationConfig()->w_z_baro_p);
603609
}
604610

605-
correctionCalculated = true;
606-
} else {
607-
pt1FilterInit(&posEstimator.baro.avgFilter, INAV_BARO_AVERAGE_HZ, 0.0f);
611+
return true;
608612
}
609-
610-
if ((STATE(FIXED_WING_LEGACY) || positionEstimationConfig()->use_gps_no_baro) && (ctx->newFlags & EST_GPS_Z_VALID)) {
613+
else if ((STATE(FIXED_WING_LEGACY) || positionEstimationConfig()->use_gps_no_baro) && (ctx->newFlags & EST_GPS_Z_VALID)) {
611614
// If baro is not available - use GPS Z for correction on a plane
612615
// Reset current estimate to GPS altitude if estimate not valid
613616
if (!(ctx->newFlags & EST_Z_VALID)) {
@@ -628,20 +631,10 @@ static bool estimationCalculateCorrection_Z(estimationContext_t * ctx)
628631
ctx->accBiasCorr.z -= gpsAltResudual * sq(positionEstimationConfig()->w_z_gps_p);
629632
}
630633

631-
correctionCalculated = true;
634+
return true;
632635
}
633636

634-
// DEBUG_ALTITUDE will be always available
635-
DEBUG_SET(DEBUG_ALTITUDE, 0, posEstimator.est.pos.z); // Position estimate
636-
DEBUG_SET(DEBUG_ALTITUDE, 2, posEstimator.baro.alt); // Baro altitude
637-
DEBUG_SET(DEBUG_ALTITUDE, 4, posEstimator.gps.pos.z); // GPS altitude
638-
DEBUG_SET(DEBUG_ALTITUDE, 6, accGetVibrationLevel()); // Vibration level
639-
DEBUG_SET(DEBUG_ALTITUDE, 1, posEstimator.est.vel.z); // Vertical speed estimate
640-
DEBUG_SET(DEBUG_ALTITUDE, 3, posEstimator.imu.accelNEU.z); // Vertical acceleration on earth frame
641-
DEBUG_SET(DEBUG_ALTITUDE, 5, posEstimator.gps.vel.z); // GPS vertical speed
642-
DEBUG_SET(DEBUG_ALTITUDE, 7, accGetClipCount()); // Clip count
643-
644-
return correctionCalculated;
637+
return false;
645638
}
646639

647640
static bool estimationCalculateCorrection_XY_GPS(estimationContext_t * ctx)
@@ -828,7 +821,6 @@ static void publishEstimatedTopic(timeUs_t currentTimeUs)
828821
navEPH = posEstimator.est.eph;
829822
navEPV = posEstimator.est.epv;
830823

831-
832824
DEBUG_SET(DEBUG_POS_EST, 0, (int32_t) posEstimator.est.pos.x*1000.0F); // Position estimate X
833825
DEBUG_SET(DEBUG_POS_EST, 1, (int32_t) posEstimator.est.pos.y*1000.0F); // Position estimate Y
834826
if (IS_RC_MODE_ACTIVE(BOXSURFACE) && posEstimator.est.aglQual!=SURFACE_QUAL_LOW){

0 commit comments

Comments
 (0)