AP_Scripting: fixed radius selection for ship landing

This commit is contained in:
Andrew Tridgell 2022-03-09 16:57:15 +11:00 committed by Randy Mackay
parent fbe1672d22
commit a15c80fcca
1 changed files with 11 additions and 2 deletions

View File

@ -46,6 +46,7 @@ TRIM_ARSPD_CM = bind_param("TRIM_ARSPD_CM")
TECS_LAND_ARSPD = bind_param("TECS_LAND_ARSPD")
Q_TRANS_DECEL = bind_param("Q_TRANS_DECEL")
WP_LOITER_RAD = bind_param("WP_LOITER_RAD")
RTL_RADIUS = bind_param("RTL_RADIUS")
FOLL_OFS_X = bind_param("FOLL_OFS_X")
FOLL_OFS_Y = bind_param("FOLL_OFS_Y")
FOLL_OFS_Z = bind_param("FOLL_OFS_Z")
@ -180,9 +181,17 @@ function stopping_distance()
return sq(closing_speed) / (2.0 * Q_TRANS_DECEL:get())
end
-- get holdoff distance
function get_holdoff_radius()
if RTL_RADIUS:get() ~= 0 then
return RTL_RADIUS:get()
end
return WP_LOITER_RAD:get()
end
-- get holdoff distance
function get_holdoff_distance()
local radius = WP_LOITER_RAD:get()
local radius = get_holdoff_radius()
local holdoff_dist = math.abs(radius*1.5)
local stop_distance = stopping_distance()
@ -193,7 +202,7 @@ end
-- get the holdoff position
function get_holdoff_position()
local radius = WP_LOITER_RAD:get()
local radius = get_holdoff_radius()
local heading_deg = target_heading + SHIP_LAND_ANGLE:get()
local holdoff_dist = get_holdoff_distance()