terrain estimator: fixed computation of filtered time since last range update

- do not use hrt to compute delta time
- limit filter state
- do not use static variables

Signed-off-by: Roman <bapstroman@gmail.com>
This commit is contained in:
Roman
2017-02-22 14:12:05 +01:00
parent 6561edb9a5
commit 6480fcc3d5
3 changed files with 13 additions and 11 deletions
+6 -10
View File
@@ -175,20 +175,16 @@ void Ekf::checkRangeDataContinuity()
{
// update range data continuous flag (2Hz ie 500 ms)
/* Timing in micro seconds */
static hrt_abstime t = 0;
static hrt_abstime t_prev = 0;
static float dt = 0.0f;
t = hrt_absolute_time();
dt = t_prev != 0 ? (t - t_prev) * 1.0f : 0.0f;
t_prev = t;
dt = math::min(dt, 1.0f);
static float range_update_interval = 0.0f;
/* Apply a 1.0 sec low pass filter to the time delta from the last range finder updates */
range_update_interval = range_update_interval * (1.0f - dt) + dt * (_time_last_imu - _time_last_range);
_dt_last_range_update_filt_us = _dt_last_range_update_filt_us * (1.0f - _dt_update) + _dt_update *
(_time_last_imu - _time_last_range);
if (range_update_interval < 5e5f) {
_dt_last_range_update_filt_us = fminf(_dt_last_range_update_filt_us, 1e6f);
if (_dt_last_range_update_filt_us < 5e5f) {
_range_data_continuous = true;
} else {
_range_data_continuous = false;
}