@@ -787,7 +787,9 @@ void Ekf::controlHeightSensorTimeouts()
787787 const bool continuous_bad_accel_hgt = isTimedOut (_time_good_vert_accel, (uint64_t )_params.bad_acc_reset_delay_us );
788788
789789 // check if height has been inertial deadreckoning for too long
790- const bool hgt_fusion_timeout = isTimedOut (_time_last_hgt_fuse, (uint64_t )5e6 );
790+ // in vision hgt mode check for vision data
791+ const bool hgt_fusion_timeout = isTimedOut (_time_last_hgt_fuse, (uint64_t )5e6 ) ||
792+ (_control_status.flags .ev_hgt && !isRecent (_time_last_ext_vision, 5 * EV_MAX_INTERVAL));
791793
792794 if (hgt_fusion_timeout || continuous_bad_accel_hgt) {
793795
@@ -876,6 +878,13 @@ void Ekf::controlHeightSensorTimeouts()
876878 failing_height_source = " ev" ;
877879 new_height_source = " ev" ;
878880
881+ // Fallback to rangefinder data if available
882+ } else if (_range_sensor.isHealthy ()) {
883+ setControlRangeHeight ();
884+ request_height_reset = true ;
885+ failing_height_source = " ev" ;
886+ new_height_source = " rng" ;
887+
879888 } else if (!_baro_hgt_faulty) {
880889 startBaroHgtFusion ();
881890
@@ -1061,11 +1070,13 @@ void Ekf::controlHeightFusion()
10611070
10621071 case VDIST_SENSOR_EV:
10631072
1064- // don't start using EV data unless data is arriving frequently
1073+ // don't start using EV data unless data is arriving frequently, do not reset if pref mode was height
10651074 if (!_control_status.flags .ev_hgt && isRecent (_time_last_ext_vision, 2 * EV_MAX_INTERVAL)) {
10661075 fuse_height = true ;
10671076 setControlEVHeight ();
1068- resetHeight ();
1077+ if (!_control_status_prev.flags .rng_hgt ) {
1078+ resetHeight ();
1079+ }
10691080 }
10701081
10711082 if (_control_status.flags .baro_hgt && _baro_data_ready && !_baro_hgt_faulty) {
0 commit comments