Skip to content

Commit 806b47a

Browse files
authored
Merge pull request #10243 from breadoven/abo_nav_vel_z_improvements
Nav velocity Z estimation improvements
2 parents 678434f + 1ed4875 commit 806b47a

File tree

5 files changed

+122
-56
lines changed

5 files changed

+122
-56
lines changed

docs/Settings.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2002,6 +2002,16 @@ Uncertainty value for barometric sensor [cm]
20022002

20032003
---
20042004

2005+
### inav_default_alt_sensor
2006+
2007+
Sets the default altitude sensor to use. Settings GPS and BARO always use both sensors unless there is an altitude error between the sensors that exceeds a set limit. In this case only the selected sensor will be used while the altitude error limit is exceeded. GPS error limit = 2 * inav_max_eph_epv. BARO error limit = 4 * inav_baro_epv. Settings GPS_ONLY and BARO_ONLY will use only the selected sensor even if the other sensor is working. The other sensor will only be used as a backup if the selected sensor is no longer available to use.
2008+
2009+
| Default | Min | Max |
2010+
| --- | --- | --- |
2011+
| GPS | | |
2012+
2013+
---
2014+
20052015
### inav_gravity_cal_tolerance
20062016

20072017
Unarmed gravity calibration tolerance level. Won't finish the calibration until estimated gravity error falls below this value.
@@ -2122,6 +2132,16 @@ Weight of barometer measurements in estimated altitude and climb rate. Setting i
21222132

21232133
---
21242134

2135+
### inav_w_z_baro_v
2136+
2137+
Weight of barometer climb rate measurements in estimated climb rate. Setting is used on both airplanes and multirotors.
2138+
2139+
| Default | Min | Max |
2140+
| --- | --- | --- |
2141+
| 0.1 | 0 | 10 |
2142+
2143+
---
2144+
21252145
### inav_w_z_gps_p
21262146

21272147
Weight of GPS altitude measurements in estimated altitude. Setting is used on both airplanes and multirotors.

src/main/fc/settings.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,9 @@ tables:
201201
- name: mavlink_radio_type
202202
values: ["GENERIC", "ELRS", "SIK"]
203203
enum: mavlinkRadio_e
204+
- name: default_altitude_source
205+
values: ["GPS", "BARO", "GPS ONLY", "BARO ONLY"]
206+
enum: navDefaultAltitudeSensor_e
204207

205208
constants:
206209
RPYL_PID_MIN: 0
@@ -2410,6 +2413,12 @@ groups:
24102413
min: 0
24112414
max: 10
24122415
default_value: 0.35
2416+
- name: inav_w_z_baro_v
2417+
description: "Weight of barometer climb rate measurements in estimated climb rate. Setting is used on both airplanes and multirotors."
2418+
field: w_z_baro_v
2419+
min: 0
2420+
max: 10
2421+
default_value: 0.1
24132422
- name: inav_w_z_gps_p
24142423
description: "Weight of GPS altitude measurements in estimated altitude. Setting is used on both airplanes and multirotors."
24152424
field: w_z_gps_p
@@ -2464,6 +2473,11 @@ groups:
24642473
field: baro_epv
24652474
min: 0
24662475
max: 9999
2476+
- name: inav_default_alt_sensor
2477+
description: "Sets the default altitude sensor to use. Settings GPS and BARO always use both sensors unless there is an altitude error between the sensors that exceeds a set limit. In this case only the selected sensor will be used while the altitude error limit is exceeded. GPS error limit = 2 * inav_max_eph_epv. BARO error limit = 4 * inav_baro_epv. Settings GPS_ONLY and BARO_ONLY will use only the selected sensor even if the other sensor is working. The other sensor will only be used as a backup if the selected sensor is no longer available to use."
2478+
default_value: "GPS"
2479+
field: default_alt_sensor
2480+
table: default_altitude_source
24672481

24682482
- name: PG_NAV_CONFIG
24692483
type: navConfig_t

src/main/navigation/navigation.h

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -231,35 +231,37 @@ typedef enum {
231231

232232
typedef struct positionEstimationConfig_s {
233233
uint8_t automatic_mag_declination;
234-
uint8_t reset_altitude_type; // from nav_reset_type_e
235-
uint8_t reset_home_type; // nav_reset_type_e
236-
uint8_t gravity_calibration_tolerance; // Tolerance of gravity calibration (cm/s/s)
234+
uint8_t reset_altitude_type; // from nav_reset_type_e
235+
uint8_t reset_home_type; // nav_reset_type_e
236+
uint8_t gravity_calibration_tolerance; // Tolerance of gravity calibration (cm/s/s)
237237
uint8_t allow_dead_reckoning;
238238

239239
uint16_t max_surface_altitude;
240240

241-
float w_z_baro_p; // Weight (cutoff frequency) for barometer altitude measurements
241+
float w_z_baro_p; // Weight (cutoff frequency) for barometer altitude measurements
242+
float w_z_baro_v; // Weight (cutoff frequency) for barometer climb rate measurements
242243

243-
float w_z_surface_p; // Weight (cutoff frequency) for surface altitude measurements
244-
float w_z_surface_v; // Weight (cutoff frequency) for surface velocity measurements
244+
float w_z_surface_p; // Weight (cutoff frequency) for surface altitude measurements
245+
float w_z_surface_v; // Weight (cutoff frequency) for surface velocity measurements
245246

246-
float w_z_gps_p; // GPS altitude data is very noisy and should be used only on airplanes
247-
float w_z_gps_v; // Weight (cutoff frequency) for GPS climb rate measurements
247+
float w_z_gps_p; // GPS altitude data is very noisy and should be used only on airplanes
248+
float w_z_gps_v; // Weight (cutoff frequency) for GPS climb rate measurements
248249

249-
float w_xy_gps_p; // Weight (cutoff frequency) for GPS position measurements
250-
float w_xy_gps_v; // Weight (cutoff frequency) for GPS velocity measurements
250+
float w_xy_gps_p; // Weight (cutoff frequency) for GPS position measurements
251+
float w_xy_gps_v; // Weight (cutoff frequency) for GPS velocity measurements
251252

252253
float w_xy_flow_p;
253254
float w_xy_flow_v;
254255

255-
float w_z_res_v; // When velocity sources lost slowly decrease estimated velocity with this weight
256+
float w_z_res_v; // When velocity sources lost slowly decrease estimated velocity with this weight
256257
float w_xy_res_v;
257258

258-
float w_acc_bias; // Weight (cutoff frequency) for accelerometer bias estimation. 0 to disable.
259+
float w_acc_bias; // Weight (cutoff frequency) for accelerometer bias estimation. 0 to disable.
259260

260-
float max_eph_epv; // Max estimated position error acceptable for estimation (cm)
261-
float baro_epv; // Baro position error
261+
float max_eph_epv; // Max estimated position error acceptable for estimation (cm)
262+
float baro_epv; // Baro position error
262263

264+
uint8_t default_alt_sensor; // default altitude sensor source
263265
#ifdef USE_GPS_FIX_ESTIMATION
264266
uint8_t allow_gps_fix_estimation;
265267
#endif

src/main/navigation/navigation_pos_estimator.c

Lines changed: 65 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
navigationPosEstimator_t posEstimator;
5757
static float initialBaroAltitudeOffset = 0.0f;
5858

59-
PG_REGISTER_WITH_RESET_TEMPLATE(positionEstimationConfig_t, positionEstimationConfig, PG_POSITION_ESTIMATION_CONFIG, 7);
59+
PG_REGISTER_WITH_RESET_TEMPLATE(positionEstimationConfig_t, positionEstimationConfig, PG_POSITION_ESTIMATION_CONFIG, 8);
6060

6161
PG_RESET_TEMPLATE(positionEstimationConfig_t, positionEstimationConfig,
6262
// Inertial position estimator parameters
@@ -69,6 +69,7 @@ PG_RESET_TEMPLATE(positionEstimationConfig_t, positionEstimationConfig,
6969
.max_surface_altitude = SETTING_INAV_MAX_SURFACE_ALTITUDE_DEFAULT,
7070

7171
.w_z_baro_p = SETTING_INAV_W_Z_BARO_P_DEFAULT,
72+
.w_z_baro_v = SETTING_INAV_W_Z_BARO_V_DEFAULT,
7273

7374
.w_z_surface_p = SETTING_INAV_W_Z_SURFACE_P_DEFAULT,
7475
.w_z_surface_v = SETTING_INAV_W_Z_SURFACE_V_DEFAULT,
@@ -89,6 +90,8 @@ PG_RESET_TEMPLATE(positionEstimationConfig_t, positionEstimationConfig,
8990

9091
.max_eph_epv = SETTING_INAV_MAX_EPH_EPV_DEFAULT,
9192
.baro_epv = SETTING_INAV_BARO_EPV_DEFAULT,
93+
94+
.default_alt_sensor = SETTING_INAV_DEFAULT_ALT_SENSOR_DEFAULT,
9295
#ifdef USE_GPS_FIX_ESTIMATION
9396
.allow_gps_fix_estimation = SETTING_INAV_ALLOW_GPS_FIX_ESTIMATION_DEFAULT
9497
#endif
@@ -342,6 +345,7 @@ static bool gravityCalibrationComplete(void)
342345

343346
return zeroCalibrationIsCompleteS(&posEstimator.imu.gravityCalibration);
344347
}
348+
345349
#define ACC_VIB_FACTOR_S 1.0f
346350
#define ACC_VIB_FACTOR_E 3.0f
347351
static void updateIMUEstimationWeight(const float dt)
@@ -423,7 +427,6 @@ static void updateIMUTopic(timeUs_t currentTimeUs)
423427
posEstimator.imu.calibratedGravityCMSS = gyroConfig()->gravity_cmss_cal;
424428
}
425429

426-
/* If calibration is incomplete - report zero acceleration */
427430
if (gravityCalibrationComplete()) {
428431
#ifdef USE_SIMULATOR
429432
if (ARMING_FLAG(SIMULATOR_MODE_HITL) || ARMING_FLAG(SIMULATOR_MODE_SITL)) {
@@ -432,7 +435,7 @@ static void updateIMUTopic(timeUs_t currentTimeUs)
432435
#endif
433436
posEstimator.imu.accelNEU.z -= posEstimator.imu.calibratedGravityCMSS;
434437
}
435-
else {
438+
else { // If calibration is incomplete - report zero acceleration
436439
posEstimator.imu.accelNEU.x = 0.0f;
437440
posEstimator.imu.accelNEU.y = 0.0f;
438441
posEstimator.imu.accelNEU.z = 0.0f;
@@ -476,14 +479,16 @@ static uint32_t calculateCurrentValidityFlags(timeUs_t currentTimeUs)
476479
/* Figure out if we have valid position data from our data sources */
477480
uint32_t newFlags = 0;
478481

482+
const float max_eph_epv = positionEstimationConfig()->max_eph_epv;
483+
479484
if ((sensors(SENSOR_GPS)
480485
#ifdef USE_GPS_FIX_ESTIMATION
481486
|| STATE(GPS_ESTIMATED_FIX)
482487
#endif
483488
) && posControl.gpsOrigin.valid &&
484489
((currentTimeUs - posEstimator.gps.lastUpdateTime) <= MS2US(INAV_GPS_TIMEOUT_MS)) &&
485-
(posEstimator.gps.eph < positionEstimationConfig()->max_eph_epv)) {
486-
if (posEstimator.gps.epv < positionEstimationConfig()->max_eph_epv) {
490+
(posEstimator.gps.eph < max_eph_epv)) {
491+
if (posEstimator.gps.epv < max_eph_epv) {
487492
newFlags |= EST_GPS_XY_VALID | EST_GPS_Z_VALID;
488493
}
489494
else {
@@ -503,11 +508,11 @@ static uint32_t calculateCurrentValidityFlags(timeUs_t currentTimeUs)
503508
newFlags |= EST_FLOW_VALID;
504509
}
505510

506-
if (posEstimator.est.eph < positionEstimationConfig()->max_eph_epv) {
511+
if (posEstimator.est.eph < max_eph_epv) {
507512
newFlags |= EST_XY_VALID;
508513
}
509514

510-
if (posEstimator.est.epv < positionEstimationConfig()->max_eph_epv) {
515+
if (posEstimator.est.epv < max_eph_epv) {
511516
newFlags |= EST_Z_VALID;
512517
}
513518

@@ -521,7 +526,9 @@ static void estimationPredict(estimationContext_t * ctx)
521526
if ((ctx->newFlags & EST_Z_VALID)) {
522527
posEstimator.est.pos.z += posEstimator.est.vel.z * ctx->dt;
523528
posEstimator.est.pos.z += posEstimator.imu.accelNEU.z * sq(ctx->dt) / 2.0f;
524-
posEstimator.est.vel.z += posEstimator.imu.accelNEU.z * ctx->dt;
529+
if (ARMING_FLAG(WAS_EVER_ARMED)) { // Hold at zero until first armed
530+
posEstimator.est.vel.z += posEstimator.imu.accelNEU.z * ctx->dt;
531+
}
525532
}
526533

527534
/* Prediction step: XY-axis */
@@ -552,20 +559,28 @@ static bool estimationCalculateCorrection_Z(estimationContext_t * ctx)
552559
DEBUG_SET(DEBUG_ALTITUDE, 7, accGetClipCount()); // Clip count
553560

554561
bool correctOK = false;
562+
const uint8_t defaultAltitudeSource = positionEstimationConfig()->default_alt_sensor;
563+
float wGps = defaultAltitudeSource == ALTITUDE_SOURCE_BARO_ONLY && ctx->newFlags & EST_BARO_VALID ? 0.0f : 1.0f;
564+
float wBaro = defaultAltitudeSource == ALTITUDE_SOURCE_GPS_ONLY && ctx->newFlags & EST_GPS_Z_VALID ? 0.0f : 1.0f;
555565

556-
float wBaro = 0.0f;
557-
if (ctx->newFlags & EST_BARO_VALID) {
558-
// Ignore baro if difference is too big, baro is probably wrong
559-
const float gpsBaroResidual = ctx->newFlags & EST_GPS_Z_VALID ? fabsf(posEstimator.gps.pos.z - posEstimator.baro.alt) : 0.0f;
566+
if (wBaro && ctx->newFlags & EST_BARO_VALID && wGps && ctx->newFlags & EST_GPS_Z_VALID) {
567+
const float gpsBaroResidual = fabsf(posEstimator.gps.pos.z - posEstimator.baro.alt);
560568

561-
// Fade out the baro to prevent sudden jump
562-
const float start_epv = positionEstimationConfig()->max_eph_epv;
563-
const float end_epv = positionEstimationConfig()->max_eph_epv * 2.0f;
569+
// Fade out the non default sensor to prevent sudden jump
570+
uint16_t residualErrorEpvLimit = defaultAltitudeSource == ALTITUDE_SOURCE_BARO ? 2 * positionEstimationConfig()->baro_epv : positionEstimationConfig()->max_eph_epv;
571+
const float start_epv = residualErrorEpvLimit;
572+
const float end_epv = residualErrorEpvLimit * 2.0f;
573+
574+
// Calculate residual gps/baro sensor weighting based on assumed default altitude source = GPS
564575
wBaro = scaleRangef(constrainf(gpsBaroResidual, start_epv, end_epv), start_epv, end_epv, 1.0f, 0.0f);
576+
577+
if (defaultAltitudeSource == ALTITUDE_SOURCE_BARO) { // flip residual sensor weighting if default = BARO
578+
wGps = wBaro;
579+
wBaro = 1.0f;
580+
}
565581
}
566582

567-
// Always use Baro if no GPS otherwise only use if accuracy OK compared to GPS
568-
if (wBaro > 0.01f) {
583+
if (ctx->newFlags & EST_BARO_VALID && wBaro) {
569584
timeUs_t currentTimeUs = micros();
570585

571586
if (!ARMING_FLAG(ARMED)) {
@@ -588,21 +603,25 @@ static bool estimationCalculateCorrection_Z(estimationContext_t * ctx)
588603
((ctx->newFlags & EST_BARO_VALID) && posEstimator.state.isBaroGroundValid && posEstimator.baro.alt < posEstimator.state.baroGroundAlt));
589604

590605
// Altitude
591-
const float baroAltResidual = (isAirCushionEffectDetected ? posEstimator.state.baroGroundAlt : posEstimator.baro.alt) - posEstimator.est.pos.z;
592-
ctx->estPosCorr.z += wBaro * baroAltResidual * positionEstimationConfig()->w_z_baro_p * ctx->dt;
593-
ctx->estVelCorr.z += wBaro * baroAltResidual * sq(positionEstimationConfig()->w_z_baro_p) * ctx->dt;
606+
const float baroAltResidual = wBaro * ((isAirCushionEffectDetected ? posEstimator.state.baroGroundAlt : posEstimator.baro.alt) - posEstimator.est.pos.z);
607+
const float baroVelZResidual = isAirCushionEffectDetected ? 0.0f : wBaro * (posEstimator.baro.baroAltRate - posEstimator.est.vel.z);
608+
const float w_z_baro_p = positionEstimationConfig()->w_z_baro_p;
594609

595-
ctx->newEPV = updateEPE(posEstimator.est.epv, ctx->dt, posEstimator.baro.epv, positionEstimationConfig()->w_z_baro_p);
610+
ctx->estPosCorr.z += baroAltResidual * w_z_baro_p * ctx->dt;
611+
ctx->estVelCorr.z += baroAltResidual * sq(w_z_baro_p) * ctx->dt;
612+
ctx->estVelCorr.z += baroVelZResidual * positionEstimationConfig()->w_z_baro_v * ctx->dt;
613+
614+
ctx->newEPV = updateEPE(posEstimator.est.epv, ctx->dt, posEstimator.baro.epv, w_z_baro_p);
596615

597616
// Accelerometer bias
598617
if (!isAirCushionEffectDetected) {
599-
ctx->accBiasCorr.z -= wBaro * baroAltResidual * sq(positionEstimationConfig()->w_z_baro_p);
618+
ctx->accBiasCorr.z -= baroAltResidual * sq(w_z_baro_p);
600619
}
601620

602-
correctOK = true;
621+
correctOK = ARMING_FLAG(WAS_EVER_ARMED); // No correction until first armed
603622
}
604623

605-
if (ctx->newFlags & EST_GPS_Z_VALID) {
624+
if (ctx->newFlags & EST_GPS_Z_VALID && wGps) {
606625
// Reset current estimate to GPS altitude if estimate not valid
607626
if (!(ctx->newFlags & EST_Z_VALID)) {
608627
ctx->estPosCorr.z += posEstimator.gps.pos.z - posEstimator.est.pos.z;
@@ -611,19 +630,20 @@ static bool estimationCalculateCorrection_Z(estimationContext_t * ctx)
611630
}
612631
else {
613632
// Altitude
614-
const float gpsAltResudual = posEstimator.gps.pos.z - posEstimator.est.pos.z;
615-
const float gpsVelZResudual = posEstimator.gps.vel.z - posEstimator.est.vel.z;
633+
const float gpsAltResidual = wGps * (posEstimator.gps.pos.z - posEstimator.est.pos.z);
634+
const float gpsVelZResidual = wGps * (posEstimator.gps.vel.z - posEstimator.est.vel.z);
635+
const float w_z_gps_p = positionEstimationConfig()->w_z_gps_p;
616636

617-
ctx->estPosCorr.z += gpsAltResudual * positionEstimationConfig()->w_z_gps_p * ctx->dt;
618-
ctx->estVelCorr.z += gpsAltResudual * sq(positionEstimationConfig()->w_z_gps_p) * ctx->dt;
619-
ctx->estVelCorr.z += gpsVelZResudual * positionEstimationConfig()->w_z_gps_v * ctx->dt;
620-
ctx->newEPV = updateEPE(posEstimator.est.epv, ctx->dt, MAX(posEstimator.gps.epv, fabsf(gpsAltResudual)), positionEstimationConfig()->w_z_gps_p);
637+
ctx->estPosCorr.z += gpsAltResidual * w_z_gps_p * ctx->dt;
638+
ctx->estVelCorr.z += gpsAltResidual * sq(w_z_gps_p) * ctx->dt;
639+
ctx->estVelCorr.z += gpsVelZResidual * positionEstimationConfig()->w_z_gps_v * ctx->dt;
640+
ctx->newEPV = updateEPE(posEstimator.est.epv, ctx->dt, MAX(posEstimator.gps.epv, fabsf(gpsAltResidual)), w_z_gps_p);
621641

622642
// Accelerometer bias
623-
ctx->accBiasCorr.z -= gpsAltResudual * sq(positionEstimationConfig()->w_z_gps_p);
643+
ctx->accBiasCorr.z -= gpsAltResidual * sq(w_z_gps_p);
624644
}
625645

626-
correctOK = true;
646+
correctOK = ARMING_FLAG(WAS_EVER_ARMED); // No correction until first armed
627647
}
628648

629649
return correctOK;
@@ -700,21 +720,23 @@ static void updateEstimatedTopic(timeUs_t currentTimeUs)
700720
{
701721
estimationContext_t ctx;
702722

723+
const float max_eph_epv = positionEstimationConfig()->max_eph_epv;
724+
703725
/* Calculate dT */
704726
ctx.dt = US2S(currentTimeUs - posEstimator.est.lastUpdateTime);
705727
posEstimator.est.lastUpdateTime = currentTimeUs;
706728

707729
/* If IMU is not ready we can't estimate anything */
708730
if (!isImuReady()) {
709-
posEstimator.est.eph = positionEstimationConfig()->max_eph_epv + 0.001f;
710-
posEstimator.est.epv = positionEstimationConfig()->max_eph_epv + 0.001f;
731+
posEstimator.est.eph = max_eph_epv + 0.001f;
732+
posEstimator.est.epv = max_eph_epv + 0.001f;
711733
posEstimator.flags = 0;
712734
return;
713735
}
714736

715737
/* Calculate new EPH and EPV for the case we didn't update postion */
716-
ctx.newEPH = posEstimator.est.eph * ((posEstimator.est.eph <= positionEstimationConfig()->max_eph_epv) ? 1.0f + ctx.dt : 1.0f);
717-
ctx.newEPV = posEstimator.est.epv * ((posEstimator.est.epv <= positionEstimationConfig()->max_eph_epv) ? 1.0f + ctx.dt : 1.0f);
738+
ctx.newEPH = posEstimator.est.eph * ((posEstimator.est.eph <= max_eph_epv) ? 1.0f + ctx.dt : 1.0f);
739+
ctx.newEPV = posEstimator.est.epv * ((posEstimator.est.epv <= max_eph_epv) ? 1.0f + ctx.dt : 1.0f);
718740
ctx.newFlags = calculateCurrentValidityFlags(currentTimeUs);
719741
vectorZero(&ctx.estPosCorr);
720742
vectorZero(&ctx.estVelCorr);
@@ -737,12 +759,12 @@ static void updateEstimatedTopic(timeUs_t currentTimeUs)
737759
estimationCalculateCorrection_XY_FLOW(&ctx);
738760

739761
// If we can't apply correction or accuracy is off the charts - decay velocity to zero
740-
if (!estXYCorrectOk || ctx.newEPH > positionEstimationConfig()->max_eph_epv) {
762+
if (!estXYCorrectOk || ctx.newEPH > max_eph_epv) {
741763
ctx.estVelCorr.x = (0.0f - posEstimator.est.vel.x) * positionEstimationConfig()->w_xy_res_v * ctx.dt;
742764
ctx.estVelCorr.y = (0.0f - posEstimator.est.vel.y) * positionEstimationConfig()->w_xy_res_v * ctx.dt;
743765
}
744766

745-
if (!estZCorrectOk || ctx.newEPV > positionEstimationConfig()->max_eph_epv) {
767+
if (!estZCorrectOk || ctx.newEPV > max_eph_epv) {
746768
ctx.estVelCorr.z = (0.0f - posEstimator.est.vel.z) * positionEstimationConfig()->w_z_res_v * ctx.dt;
747769
}
748770
// Boost the corrections based on accWeight
@@ -754,16 +776,17 @@ static void updateEstimatedTopic(timeUs_t currentTimeUs)
754776
vectorAdd(&posEstimator.est.vel, &posEstimator.est.vel, &ctx.estVelCorr);
755777

756778
/* Correct accelerometer bias */
757-
if (positionEstimationConfig()->w_acc_bias > 0.0f) {
779+
const float w_acc_bias = positionEstimationConfig()->w_acc_bias;
780+
if (w_acc_bias > 0.0f) {
758781
const float accelBiasCorrMagnitudeSq = sq(ctx.accBiasCorr.x) + sq(ctx.accBiasCorr.y) + sq(ctx.accBiasCorr.z);
759782
if (accelBiasCorrMagnitudeSq < sq(INAV_ACC_BIAS_ACCEPTANCE_VALUE)) {
760783
/* transform error vector from NEU frame to body frame */
761784
imuTransformVectorEarthToBody(&ctx.accBiasCorr);
762785

763786
/* Correct accel bias */
764-
posEstimator.imu.accelBias.x += ctx.accBiasCorr.x * positionEstimationConfig()->w_acc_bias * ctx.dt;
765-
posEstimator.imu.accelBias.y += ctx.accBiasCorr.y * positionEstimationConfig()->w_acc_bias * ctx.dt;
766-
posEstimator.imu.accelBias.z += ctx.accBiasCorr.z * positionEstimationConfig()->w_acc_bias * ctx.dt;
787+
posEstimator.imu.accelBias.x += ctx.accBiasCorr.x * w_acc_bias * ctx.dt;
788+
posEstimator.imu.accelBias.y += ctx.accBiasCorr.y * w_acc_bias * ctx.dt;
789+
posEstimator.imu.accelBias.z += ctx.accBiasCorr.z * w_acc_bias * ctx.dt;
767790
}
768791
}
769792

0 commit comments

Comments
 (0)