Skip to content

Commit 07c80f1

Browse files
committed
AP_Scripting: plane_ship_landing.lua: add pos/vel sanity check
this method can return false if the target is outside the AP_Follow acceptance radius. So we can be receiving messages from the target, so have_target can be true, but false is returned from get_target_location_and_velocity_ofs, meaning we try to call methods on nil values
1 parent 2a26d62 commit 07c80f1

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

libraries/AP_Scripting/applets/plane_ship_landing.lua

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,13 +337,23 @@ function update_target()
337337
have_target = false
338338
return
339339
end
340+
341+
target_pos, target_velocity = follow:get_target_location_and_velocity_ofs()
342+
if target_pos == nil or target_velocity == nil then
343+
if have_target then
344+
gcs:send_text(MAV_SEVERITY.WARNING, "No target location/velocity")
345+
have_target = false
346+
end
347+
return
348+
end
349+
340350
if not have_target then
341351
gcs:send_text(MAV_SEVERITY.INFO, "Have beacon")
342352
arming:set_aux_auth_passed(auth_id)
343353
end
354+
344355
have_target = true
345356

346-
target_pos, target_velocity = follow:get_target_location_and_velocity_ofs()
347357
target_pos:change_alt_frame(ALT_FRAME_ABSOLUTE)
348358
target_heading = follow:get_target_heading_deg()
349359
-- zero vertical velocity to reduce impact of ship movement

0 commit comments

Comments
 (0)