terrain_estimator: introduce quality metric in rng

This commit introduces a quality measure in the range data. It is
used to properly decide whether to initialize the HAGL estimate on
 sensor data or MIN_HGT parameter, as well as in the decision of
whether a 'fake' measurement should be published on the ground to
allow for optical flow take-offs.
This commit is contained in:
Nico van Duijn
2019-09-12 17:45:37 +10:00
committed by Paul Riseborough
parent 3e05fd552e
commit a12186c285
5 changed files with 10 additions and 7 deletions
+4 -3
View File
@@ -48,7 +48,7 @@ bool Ekf::initHagl()
// get most recent range measurement from buffer
const rangeSample &latest_measurement = _range_buffer.get_newest();
if ((_time_last_imu - latest_measurement.time_us) < (uint64_t)2e5 && _R_rng_to_earth_2_2 > _params.range_cos_max_tilt) {
if (!_rng_hgt_faulty && (_time_last_imu - latest_measurement.time_us) < (uint64_t)2e5 && _R_rng_to_earth_2_2 > _params.range_cos_max_tilt) {
// if we have a fresh measurement, use it to initialise the terrain estimator
_terrain_vpos = _state.pos(2) + latest_measurement.rng * _R_rng_to_earth_2_2;
// initialise state variance to variance of measurement
@@ -66,7 +66,7 @@ bool Ekf::initHagl()
// Use the ground clearance value as our uncertainty
_terrain_var = sq(_params.rng_gnd_clearance);
// this is a guess
return false;
return true;
} else {
// no information - cannot initialise
@@ -99,8 +99,9 @@ void Ekf::runTerrainEstimator()
// if stationary on the ground and no range data for over a second, fake a measurement
// to handle bad range finder data when on ground
if (!_range_data_ready && !_control_status.flags.in_air && _vehicle_at_rest && (_time_last_imu - _time_last_hagl_fuse) > (uint64_t)1E6) {
if (_rng_hgt_faulty && !_range_data_ready && !_control_status.flags.in_air && _vehicle_at_rest && (_time_last_imu - _time_last_hagl_fuse) > (uint64_t)1E6) {
_range_data_ready = true;
_rng_hgt_faulty = false;
_range_sample_delayed.rng = _params.rng_gnd_clearance;
}