Height source vision: Fallback to rangefinder if available (#994)

This commit is contained in:
Eike
2021-03-31 14:24:38 +02:00
committed by GitHub
parent da06f25216
commit 5d34d7a24e
3 changed files with 31 additions and 5 deletions
+14
View File
@@ -262,6 +262,20 @@ void Ekf::resetHeight()
// reset the vertical position
if (_control_status.flags.rng_hgt) {
// a fallback from any other height source to rangefinder happened
if(!_control_status_prev.flags.rng_hgt) {
if (_control_status.flags.in_air && isTerrainEstimateValid()) {
_hgt_sensor_offset = _terrain_vpos;
} else if (_control_status.flags.in_air) {
_hgt_sensor_offset = _range_sensor.getDistBottom() + _state.pos(2);
} else {
_hgt_sensor_offset = _params.rng_gnd_clearance;
}
}
// update the state and associated variance
resetVerticalPositionTo(_hgt_sensor_offset - _range_sensor.getDistBottom());