diff --git a/src/modules/land_detector/LandDetector.h b/src/modules/land_detector/LandDetector.h index 01ba9a5a58..db2abfa8f9 100644 --- a/src/modules/land_detector/LandDetector.h +++ b/src/modules/land_detector/LandDetector.h @@ -61,10 +61,6 @@ public: GROUND_CONTACT = 3 }; - enum class BatteryLevel { - - }; - LandDetector(); virtual ~LandDetector(); @@ -128,7 +124,7 @@ protected: virtual bool _get_freefall_state() = 0; /** - * @return + * @return maximum altitude that can be reached */ virtual float _get_max_altitude() = 0; @@ -164,8 +160,6 @@ protected: float _altitude_max; - - private: static void _cycle_trampoline(void *arg); diff --git a/src/modules/navigator/rtl.cpp b/src/modules/navigator/rtl.cpp index d85a81bdbc..97151d9ca3 100644 --- a/src/modules/navigator/rtl.cpp +++ b/src/modules/navigator/rtl.cpp @@ -84,6 +84,13 @@ RTL::on_inactive() _rtl_state = RTL_STATE_NONE; } +float +RTL::get_rtl_altitude() +{ + return (_param_return_alt.get() < _navigator->get_land_detected()->alt_max) ? _param_return_alt.get() : + _navigator->get_land_detected()->alt_max; +} + void RTL::on_activation() { @@ -101,7 +108,7 @@ RTL::on_activation() /* if lower than return altitude, climb up first */ } else if (_navigator->get_global_position()->alt < (_navigator->get_home_position()->alt - + _param_return_alt.get())) { + + get_rtl_altitude())) { _rtl_state = RTL_STATE_CLIMB; /* otherwise go straight to return */ @@ -145,7 +152,7 @@ RTL::set_rtl_item() _navigator->get_global_position()->lat, _navigator->get_global_position()->lon); // if we are close to home we do not climb as high, otherwise we climb to return alt - float climb_alt = _navigator->get_home_position()->alt + _param_return_alt.get(); + float climb_alt = _navigator->get_home_position()->alt + get_rtl_altitude(); // we are close to home, limit climb to min if (home_dist < _param_rtl_min_dist.get()) { diff --git a/src/modules/navigator/rtl.h b/src/modules/navigator/rtl.h index 0633cf91c1..a11101732f 100644 --- a/src/modules/navigator/rtl.h +++ b/src/modules/navigator/rtl.h @@ -77,6 +77,12 @@ private: */ void advance_rtl(); + /** + * Get rtl altitude + */ + float get_rtl_altitude(); + + enum RTLState { RTL_STATE_NONE = 0, RTL_STATE_CLIMB,