ekf2: reinit baro height on sensor or calibration change

- handle reset on delayed time horizon
This commit is contained in:
Daniel Agar
2022-12-29 16:37:34 -05:00
parent 0e2df5a152
commit 20a1c73cf0
4 changed files with 9 additions and 11 deletions
+4 -3
View File
@@ -59,17 +59,18 @@ void Ekf::controlBaroHeightFusion()
const bool measurement_valid = PX4_ISFINITE(measurement) && PX4_ISFINITE(measurement_var);
if (measurement_valid) {
if (_baro_counter == 0) {
if ((_baro_counter == 0) || baro_sample.reset) {
_baro_lpf.reset(measurement);
_baro_counter = 1;
} else {
_baro_lpf.update(measurement);
_baro_counter++;
}
if (_baro_counter <= _obs_buffer_length) {
// Initialize the pressure offset (included in the baro bias)
bias_est.setBias(_state.pos(2) + _baro_lpf.getState());
_baro_counter++;
}
}
@@ -108,10 +109,10 @@ void Ekf::controlBaroHeightFusion()
// determine if we should use height aiding
const bool continuing_conditions_passing = (_params.baro_ctrl == 1)
&& measurement_valid
&& (_baro_counter > _obs_buffer_length)
&& !_baro_hgt_faulty;
const bool starting_conditions_passing = continuing_conditions_passing
&& (_baro_counter > _obs_buffer_length)
&& isNewestSampleRecent(_time_last_baro_buffer_push, 2 * BARO_MAX_INTERVAL);
if (_control_status.flags.baro_hgt) {
+1
View File
@@ -222,6 +222,7 @@ struct magSample {
struct baroSample {
uint64_t time_us{}; ///< timestamp of the measurement (uSec)
float hgt{}; ///< pressure altitude above sea level (m)
bool reset{false};
};
struct rangeSample {
+1 -2
View File
@@ -229,9 +229,8 @@ void EstimatorInterface::setBaroData(const baroSample &baro_sample)
// limit data rate to prevent data being lost
if (time_us >= static_cast<int64_t>(_baro_buffer->get_newest().time_us + _min_obs_interval_us)) {
baroSample baro_sample_new;
baroSample baro_sample_new{baro_sample};
baro_sample_new.time_us = time_us;
baro_sample_new.hgt = baro_sample.hgt;
_baro_buffer->push(baro_sample_new);
_time_last_baro_buffer_push = _newest_high_rate_imu_sample.time_us;