mirror of https://github.com/ArduPilot/ardupilot
Copter: avoid terrain failsafe from a single out-of-range rangefinder reading
This commit is contained in:
parent
67ff96d8de
commit
8e095d4a81
|
@ -40,8 +40,10 @@ void Copter::read_rangefinder(void)
|
|||
// filter rangefinder for use by AC_WPNav
|
||||
uint32_t now = AP_HAL::millis();
|
||||
|
||||
const bool timed_out = now - rangefinder_state.last_healthy_ms > RANGEFINDER_TIMEOUT_MS;
|
||||
|
||||
if (rangefinder_state.alt_healthy) {
|
||||
if (now - rangefinder_state.last_healthy_ms > RANGEFINDER_TIMEOUT_MS) {
|
||||
if (timed_out) {
|
||||
// reset filter if we haven't used it within the last second
|
||||
rangefinder_state.alt_cm_filt.reset(rangefinder_state.alt_cm);
|
||||
} else {
|
||||
|
@ -51,7 +53,9 @@ void Copter::read_rangefinder(void)
|
|||
}
|
||||
|
||||
// send rangefinder altitude and health to waypoint navigation library
|
||||
wp_nav->set_rangefinder_alt(rangefinder_state.enabled, rangefinder_state.alt_healthy, rangefinder_state.alt_cm_filt.get());
|
||||
if (rangefinder_state.alt_healthy || timed_out) {
|
||||
wp_nav->set_rangefinder_alt(rangefinder_state.enabled, rangefinder_state.alt_healthy, rangefinder_state.alt_cm_filt.get());
|
||||
}
|
||||
|
||||
#else
|
||||
rangefinder_state.enabled = false;
|
||||
|
|
Loading…
Reference in New Issue