From e8237c8930c59f83ed7b379e023c713b53015938 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 15 Oct 2024 19:24:26 +1100 Subject: [PATCH] Plane: more places checking for terrain alt --- ArduPlane/ArduPlane.cpp | 2 +- ArduPlane/GCS_Mavlink.cpp | 2 +- ArduPlane/mode_guided.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ArduPlane/ArduPlane.cpp b/ArduPlane/ArduPlane.cpp index 0181f392d804b9..5f1a6e5717b840 100644 --- a/ArduPlane/ArduPlane.cpp +++ b/ArduPlane/ArduPlane.cpp @@ -859,7 +859,7 @@ bool Plane::set_target_location(const Location &target_loc) return false; } // add home alt if needed - if (loc.relative_alt) { + if (loc.relative_alt && !loc.terrain_alt) { loc.alt += plane.home.alt; loc.relative_alt = 0; } diff --git a/ArduPlane/GCS_Mavlink.cpp b/ArduPlane/GCS_Mavlink.cpp index 45f8c3338eedfc..591f40d68b8100 100644 --- a/ArduPlane/GCS_Mavlink.cpp +++ b/ArduPlane/GCS_Mavlink.cpp @@ -749,7 +749,7 @@ bool GCS_MAVLINK_Plane::handle_guided_request(AP_Mission::Mission_Command &cmd) void GCS_MAVLINK_Plane::handle_change_alt_request(AP_Mission::Mission_Command &cmd) { plane.next_WP_loc.alt = cmd.content.location.alt; - if (cmd.content.location.relative_alt) { + if (cmd.content.location.relative_alt && !cmd.content.location.terrain_alt) { plane.next_WP_loc.alt += plane.home.alt; } plane.next_WP_loc.relative_alt = false; diff --git a/ArduPlane/mode_guided.cpp b/ArduPlane/mode_guided.cpp index a97bedcd7dffbb..cb4a1ccd4baa46 100644 --- a/ArduPlane/mode_guided.cpp +++ b/ArduPlane/mode_guided.cpp @@ -109,7 +109,7 @@ void ModeGuided::navigate() bool ModeGuided::handle_guided_request(Location target_loc) { // add home alt if needed - if (target_loc.relative_alt) { + if (target_loc.relative_alt && !target_loc.terrain_alt) { target_loc.alt += plane.home.alt; target_loc.relative_alt = 0; }