From aba476355ef6ecc66159879d791741873df10284 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Fri, 11 Oct 2024 15:13:10 +1100 Subject: [PATCH] AP_SurfaceDistance: allow for more than 327m range rangefinders --- libraries/AP_SurfaceDistance/AP_SurfaceDistance.cpp | 2 +- libraries/AP_SurfaceDistance/AP_SurfaceDistance.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/AP_SurfaceDistance/AP_SurfaceDistance.cpp b/libraries/AP_SurfaceDistance/AP_SurfaceDistance.cpp index af8ec0b42f0912..9dfdb232d55d7e 100644 --- a/libraries/AP_SurfaceDistance/AP_SurfaceDistance.cpp +++ b/libraries/AP_SurfaceDistance/AP_SurfaceDistance.cpp @@ -69,7 +69,7 @@ void AP_SurfaceDistance::update() } // tilt corrected but unfiltered, not glitch protected alt - alt_cm = tilt_correction * rangefinder->distance_cm_orient(rotation); + alt_cm = tilt_correction * rangefinder->distance_orient(rotation)*100; // remember inertial alt to allow us to interpolate rangefinder inertial_alt_cm = inertial_nav.get_position_z_up_cm(); diff --git a/libraries/AP_SurfaceDistance/AP_SurfaceDistance.h b/libraries/AP_SurfaceDistance/AP_SurfaceDistance.h index 1b331a30810c10..c8aefad62e0cd9 100644 --- a/libraries/AP_SurfaceDistance/AP_SurfaceDistance.h +++ b/libraries/AP_SurfaceDistance/AP_SurfaceDistance.h @@ -26,10 +26,10 @@ class AP_SurfaceDistance { bool enabled; // not to be confused with rangefinder enabled, this state is to be set by the vehicle. bool alt_healthy; // true if we can trust the altitude from the rangefinder - int16_t alt_cm; // tilt compensated altitude (in cm) from rangefinder + int32_t alt_cm; // tilt compensated altitude (in cm) from rangefinder float inertial_alt_cm; // inertial alt at time of last rangefinder sample LowPassFilterFloat alt_cm_filt {0.5}; // altitude filter - int16_t alt_cm_glitch_protected; // last glitch protected altitude + int32_t alt_cm_glitch_protected; // last glitch protected altitude int8_t glitch_count; // non-zero number indicates rangefinder is glitching uint32_t glitch_cleared_ms; // system time glitch cleared float terrain_offset_cm; // filtered terrain offset (e.g. terrain's height above EKF origin)