From d00a28b9b09ae46b65971c9f9d4f149b4b09f987 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Dec 2024 07:58:25 +1100 Subject: [PATCH] AC_Fence: removed _curr_alt from class this is only ever set/checked within a function --- libraries/AC_Fence/AC_Fence.cpp | 6 +++--- libraries/AC_Fence/AC_Fence.h | 2 -- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/libraries/AC_Fence/AC_Fence.cpp b/libraries/AC_Fence/AC_Fence.cpp index cdbf55e51f..f078bd5eb0 100644 --- a/libraries/AC_Fence/AC_Fence.cpp +++ b/libraries/AC_Fence/AC_Fence.cpp @@ -524,7 +524,7 @@ bool AC_Fence::check_fence_alt_max() float alt; AP::ahrs().get_relative_position_D_home(alt); - _curr_alt = -alt; // translate Down to Up + const float _curr_alt = -alt; // translate Down to Up // check if we are over the altitude fence if (_curr_alt >= _alt_max) { @@ -573,7 +573,7 @@ bool AC_Fence::check_fence_alt_min() float alt; AP::ahrs().get_relative_position_D_home(alt); - _curr_alt = -alt; // translate Down to Up + const float _curr_alt = -alt; // translate Down to Up // check if we are under the altitude fence if (_curr_alt <= _alt_min) { @@ -625,7 +625,7 @@ bool AC_Fence::auto_enable_fence_floor() float alt; AP::ahrs().get_relative_position_D_home(alt); - _curr_alt = -alt; // translate Down to Up + const float _curr_alt = -alt; // translate Down to Up // check if we are over the altitude fence if (!floor_enabled() && _curr_alt >= _alt_min + _margin) { diff --git a/libraries/AC_Fence/AC_Fence.h b/libraries/AC_Fence/AC_Fence.h index 3165d7b73d..8ed6817d69 100644 --- a/libraries/AC_Fence/AC_Fence.h +++ b/libraries/AC_Fence/AC_Fence.h @@ -251,8 +251,6 @@ private: // other internal variables uint8_t _auto_enable_mask = AC_FENCE_ALL_FENCES; // fences that can be auto-enabled or auto-disabled float _home_distance; // distance from home in meters (provided by main code) - float _curr_alt; - // breach information uint8_t _breached_fences; // bitmask holding the fence type that was breached (i.e. AC_FENCE_TYPE_ALT_MIN, AC_FENCE_TYPE_CIRCLE)