From a012f01dbc38a899a48e1767399b5972c995f435 Mon Sep 17 00:00:00 2001 From: Silvan Fuhrer Date: Fri, 22 Oct 2021 16:35:32 +0200 Subject: [PATCH] Navigator: clean up get_rtl_type() Signed-off-by: Silvan Fuhrer --- src/modules/navigator/navigator.h | 3 +-- src/modules/navigator/navigator_main.cpp | 4 ++-- src/modules/navigator/rtl.cpp | 6 +++--- src/modules/navigator/rtl.h | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/modules/navigator/navigator.h b/src/modules/navigator/navigator.h index 9a800c5a05..f4683c7a46 100644 --- a/src/modules/navigator/navigator.h +++ b/src/modules/navigator/navigator.h @@ -286,8 +286,7 @@ public: float get_mission_landing_alt() { return _mission.get_landing_alt(); } // RTL - bool mission_landing_required() { return _rtl.rtl_type() == RTL::RTL_LAND; } - int rtl_type() { return _rtl.rtl_type(); } + bool mission_landing_required() { return _rtl.get_rtl_type() == RTL::RTL_LAND; } bool in_rtl_state() const { return _vstatus.nav_state == vehicle_status_s::NAVIGATION_STATE_AUTO_RTL; } bool abort_landing(); diff --git a/src/modules/navigator/navigator_main.cpp b/src/modules/navigator/navigator_main.cpp index 689682cc80..0cbc26deb6 100644 --- a/src/modules/navigator/navigator_main.cpp +++ b/src/modules/navigator/navigator_main.cpp @@ -573,11 +573,11 @@ Navigator::run() const bool rtl_activated = _previous_nav_state != vehicle_status_s::NAVIGATION_STATE_AUTO_RTL; - switch (rtl_type()) { + switch (_rtl.get_rtl_type()) { case RTL::RTL_LAND: // use mission landing case RTL::RTL_CLOSEST: if (rtl_activated) { - if (rtl_type() == RTL::RTL_LAND) { + if (_rtl.get_rtl_type() == RTL::RTL_LAND) { mavlink_log_info(get_mavlink_log_pub(), "RTL LAND activated\t"); events::send(events::ID("navigator_rtl_landing_activated"), events::Log::Info, "RTL activated"); diff --git a/src/modules/navigator/rtl.cpp b/src/modules/navigator/rtl.cpp index f7c6c5a372..21e9794ff1 100644 --- a/src/modules/navigator/rtl.cpp +++ b/src/modules/navigator/rtl.cpp @@ -116,7 +116,7 @@ void RTL::find_RTL_destination() // consider the mission landing if not RTL_HOME type set - if (rtl_type() != RTL_HOME && _navigator->get_mission_start_land_available()) { + if (_param_rtl_type.get() != RTL_HOME && _navigator->get_mission_start_land_available()) { double mission_landing_lat; double mission_landing_lon; float mission_landing_alt; @@ -138,7 +138,7 @@ void RTL::find_RTL_destination() double dist_squared = coord_dist_sq(dlat, dlon); // set destination to mission landing if closest or in RTL_LAND or RTL_MISSION (so not in RTL_CLOSEST) - if (dist_squared < min_dist_squared || rtl_type() != RTL_CLOSEST) { + if (dist_squared < min_dist_squared || _param_rtl_type.get() != RTL_CLOSEST) { min_dist_squared = dist_squared; _destination.lat = mission_landing_lat; _destination.lon = mission_landing_lon; @@ -148,7 +148,7 @@ void RTL::find_RTL_destination() } // do not consider rally point if RTL type is set to RTL_MISSION, so exit function and use either home or mission landing - if (rtl_type() == RTL_MISSION) { + if (_param_rtl_type.get() == RTL_MISSION) { return; } diff --git a/src/modules/navigator/rtl.h b/src/modules/navigator/rtl.h index b1306516a8..f31173fa70 100644 --- a/src/modules/navigator/rtl.h +++ b/src/modules/navigator/rtl.h @@ -91,7 +91,7 @@ public: void set_return_alt_min(bool min) { _rtl_alt_min = min; } - int rtl_type() const { return _param_rtl_type.get(); } + int get_rtl_type() const { return _param_rtl_type.get(); } int rtl_destination();