From 6eae9fb37107ba55d52ab7e3189b1c403cea45a6 Mon Sep 17 00:00:00 2001 From: Daniel Agar Date: Tue, 17 Oct 2023 13:33:06 -0400 Subject: [PATCH] ekf2: fix barometer kconfig --- src/modules/ekf2/EKF/covariance.cpp | 5 +++++ src/modules/ekf2/EKF/estimator_interface.cpp | 2 ++ src/modules/ekf2/EKF2.cpp | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/src/modules/ekf2/EKF/covariance.cpp b/src/modules/ekf2/EKF/covariance.cpp index 0692c9d4695f..28c5815f1819 100644 --- a/src/modules/ekf2/EKF/covariance.cpp +++ b/src/modules/ekf2/EKF/covariance.cpp @@ -65,7 +65,12 @@ void Ekf::initialiseCovariance() P.uncorrelateCovarianceSetVariance(State::vel.idx, Vector3f(vel_var, vel_var, sq(1.5f) * vel_var)); // position +#if defined(CONFIG_EKF2_BAROMETER) float z_pos_var = sq(fmaxf(_params.baro_noise, 0.01f)); +#else + float z_pos_var = sq(1.f); +#endif // CONFIG_EKF2_BAROMETER + #if defined(CONFIG_EKF2_GNSS) const float xy_pos_var = sq(fmaxf(_params.gps_pos_noise, 0.01f)); diff --git a/src/modules/ekf2/EKF/estimator_interface.cpp b/src/modules/ekf2/EKF/estimator_interface.cpp index bf97dc2a75b3..850e409bdb18 100644 --- a/src/modules/ekf2/EKF/estimator_interface.cpp +++ b/src/modules/ekf2/EKF/estimator_interface.cpp @@ -563,10 +563,12 @@ bool EstimatorInterface::initialise_interface(uint64_t timestamp) max_time_delay_ms = math::max(_params.auxvel_delay_ms, max_time_delay_ms); #endif // CONFIG_EKF2_AUXVEL +#if defined(CONFIG_EKF2_BAROMETER) // using baro if (_params.baro_ctrl > 0) { max_time_delay_ms = math::max(_params.baro_delay_ms, max_time_delay_ms); } +#endif // CONFIG_EKF2_BAROMETER #if defined(CONFIG_EKF2_AIRSPEED) // using airspeed diff --git a/src/modules/ekf2/EKF2.cpp b/src/modules/ekf2/EKF2.cpp index 291e9aa64d28..0b85928e0bee 100644 --- a/src/modules/ekf2/EKF2.cpp +++ b/src/modules/ekf2/EKF2.cpp @@ -229,7 +229,9 @@ EKF2::~EKF2() perf_free(_ecl_ekf_update_perf); perf_free(_ecl_ekf_update_full_perf); perf_free(_msg_missed_imu_perf); +#if defined(CONFIG_EKF2_BAROMETER) perf_free(_msg_missed_air_data_perf); +#endif // CONFIG_EKF2_BAROMETER #if defined(CONFIG_EKF2_AIRSPEED) perf_free(_msg_missed_airspeed_perf); #endif // CONFIG_EKF2_AIRSPEED @@ -398,7 +400,9 @@ int EKF2::print_status() perf_print_counter(_ecl_ekf_update_perf); perf_print_counter(_ecl_ekf_update_full_perf); perf_print_counter(_msg_missed_imu_perf); +#if defined(CONFIG_EKF2_BAROMETER) perf_print_counter(_msg_missed_air_data_perf); +#endif // CONFIG_EKF2_BAROMETER #if defined(CONFIG_EKF2_AIRSPEED) perf_print_counter(_msg_missed_airspeed_perf); #endif // CONFIG_EKF2_AIRSPEED