diff --git a/src/modules/navigator/rtl.cpp b/src/modules/navigator/rtl.cpp index 286f12ca7b..1c558dfa27 100644 --- a/src/modules/navigator/rtl.cpp +++ b/src/modules/navigator/rtl.cpp @@ -257,6 +257,7 @@ void RTL::on_activation() const vehicle_global_position_s &global_position = *_navigator->get_global_position(); + _rtl_loiter_rad = _param_rtl_loiter_rad.get(); if (_navigator->get_vstatus()->vehicle_type == vehicle_status_s::VEHICLE_TYPE_ROTARY_WING) { _rtl_alt = calculate_return_alt_from_cone_half_angle((float)_param_rtl_cone_half_angle_deg.get()); @@ -410,6 +411,10 @@ void RTL::set_rtl_item() _mission_item.yaw = _destination.yaw; } + if (_navigator->get_vstatus()->is_vtol) { + _mission_item.loiter_radius = _rtl_loiter_rad; + } + _mission_item.acceptance_radius = _navigator->get_acceptance_radius(); _mission_item.time_inside = 0.0f; _mission_item.autocontinue = true; diff --git a/src/modules/navigator/rtl.h b/src/modules/navigator/rtl.h index 3718ac724d..fcdc970ab8 100644 --- a/src/modules/navigator/rtl.h +++ b/src/modules/navigator/rtl.h @@ -148,6 +148,7 @@ private: float _rtl_alt{0.0f}; // AMSL altitude at which the vehicle should return to the home position bool _rtl_alt_min{false}; + float _rtl_loiter_rad{50.0f}; // radius at which a fixed wing would loiter while descending bool _climb_and_return_done{false}; // this flag is set to true if RTL is active and we are past the climb state and return state bool _deny_mission_landing{false}; @@ -159,7 +160,8 @@ private: (ParamInt) _param_rtl_type, (ParamInt) _param_rtl_cone_half_angle_deg, (ParamFloat) _param_rtl_flt_time, - (ParamInt) _param_rtl_pld_md + (ParamInt) _param_rtl_pld_md, + (ParamFloat) _param_rtl_loiter_rad ) // These need to point at different parameters depending on vehicle type. diff --git a/src/modules/navigator/rtl_params.c b/src/modules/navigator/rtl_params.c index 769d56fa5f..463ee1a435 100644 --- a/src/modules/navigator/rtl_params.c +++ b/src/modules/navigator/rtl_params.c @@ -159,3 +159,17 @@ PARAM_DEFINE_FLOAT(RTL_FLT_TIME, 15); * @group Return To Land */ PARAM_DEFINE_INT32(RTL_PLD_MD, 0); + +/** + * Loiter radius for rtl descend + * + * Set the radius for loitering to a safe altitude for VTOL transition. + * + * @unit m + * @min 25 + * @max 1000 + * @decimal 1 + * @increment 0.5 + * @group Return Mode + */ +PARAM_DEFINE_FLOAT(RTL_LOITER_RAD, 50.0f);