53
53
54
54
navigationPosEstimator_t posEstimator ;
55
55
56
- PG_REGISTER_WITH_RESET_TEMPLATE (positionEstimationConfig_t , positionEstimationConfig , PG_POSITION_ESTIMATION_CONFIG , 3 );
56
+ PG_REGISTER_WITH_RESET_TEMPLATE (positionEstimationConfig_t , positionEstimationConfig , PG_POSITION_ESTIMATION_CONFIG , 4 );
57
57
58
58
PG_RESET_TEMPLATE (positionEstimationConfig_t , positionEstimationConfig ,
59
59
// Inertial position estimator parameters
@@ -66,6 +66,8 @@ PG_RESET_TEMPLATE(positionEstimationConfig_t, positionEstimationConfig,
66
66
67
67
.max_surface_altitude = 200 ,
68
68
69
+ .w_xyz_acc_p = 1.0f ,
70
+
69
71
.w_z_baro_p = 0.35f ,
70
72
71
73
.w_z_surface_p = 3.500f ,
@@ -433,6 +435,12 @@ static bool navIsHeadingUsable(void)
433
435
}
434
436
}
435
437
438
+ float navGetAccelerometerWeight (void )
439
+ {
440
+ // TODO(digitalentity): consider accelerometer health in weight calculation
441
+ return positionEstimationConfig ()-> w_xyz_acc_p ;
442
+ }
443
+
436
444
static uint32_t calculateCurrentValidityFlags (timeUs_t currentTimeUs )
437
445
{
438
446
/* Figure out if we have valid position data from our data sources */
@@ -474,11 +482,13 @@ static uint32_t calculateCurrentValidityFlags(timeUs_t currentTimeUs)
474
482
475
483
static void estimationPredict (estimationContext_t * ctx )
476
484
{
485
+ const float accWeight = navGetAccelerometerWeight ();
486
+
477
487
/* Prediction step: Z-axis */
478
488
if ((ctx -> newFlags & EST_Z_VALID )) {
479
489
posEstimator .est .pos .z += posEstimator .est .vel .z * ctx -> dt ;
480
- posEstimator .est .pos .z += posEstimator .imu .accelNEU .z * sq (ctx -> dt ) / 2.0f ;
481
- posEstimator .est .vel .z += posEstimator .imu .accelNEU .z * ctx -> dt ;
490
+ posEstimator .est .pos .z += posEstimator .imu .accelNEU .z * sq (ctx -> dt ) / 2.0f * accWeight ;
491
+ posEstimator .est .vel .z += posEstimator .imu .accelNEU .z * ctx -> dt * sq ( accWeight ) ;
482
492
}
483
493
484
494
/* Prediction step: XY-axis */
@@ -489,10 +499,10 @@ static void estimationPredict(estimationContext_t * ctx)
489
499
490
500
// If heading is valid, accelNEU is valid as well. Account for acceleration
491
501
if (navIsHeadingUsable () && navIsAccelerationUsable ()) {
492
- posEstimator .est .pos .x += posEstimator .imu .accelNEU .x * sq (ctx -> dt ) / 2.0f ;
493
- posEstimator .est .pos .y += posEstimator .imu .accelNEU .y * sq (ctx -> dt ) / 2.0f ;
494
- posEstimator .est .vel .x += posEstimator .imu .accelNEU .x * ctx -> dt ;
495
- posEstimator .est .vel .y += posEstimator .imu .accelNEU .y * ctx -> dt ;
502
+ posEstimator .est .pos .x += posEstimator .imu .accelNEU .x * sq (ctx -> dt ) / 2.0f * accWeight ;
503
+ posEstimator .est .pos .y += posEstimator .imu .accelNEU .y * sq (ctx -> dt ) / 2.0f * accWeight ;
504
+ posEstimator .est .vel .x += posEstimator .imu .accelNEU .x * ctx -> dt * sq ( accWeight ) ;
505
+ posEstimator .est .vel .y += posEstimator .imu .accelNEU .y * ctx -> dt * sq ( accWeight ) ;
496
506
}
497
507
}
498
508
}
0 commit comments