From 03733e284c866f9283ca80b6a691f3e510c47982 Mon Sep 17 00:00:00 2001
From: Randy Mackay <rmackay9@yahoo.com>
Date: Tue, 15 Jan 2013 01:19:23 +0900
Subject: [PATCH] Copter: bug fix to altitude check of verify takeoff

set_next_WP function was not setting the alt_change_flag properly
---
 ArduCopter/commands.pde | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/ArduCopter/commands.pde b/ArduCopter/commands.pde
index 41d7f5c3a..185e52fff 100644
--- a/ArduCopter/commands.pde
+++ b/ArduCopter/commands.pde
@@ -129,9 +129,6 @@ static int32_t get_RTL_alt()
 
 static void set_next_WP(struct Location *wp)
 {
-    //SendDebug("MSG <set_next_wp> wp_index: ");
-    //SendDebugln(g.command_index, DEC);
-
     // copy the current WP into the OldWP slot
     // ---------------------------------------
     if (next_WP.lat == 0 || command_nav_index <= 1) {
@@ -143,20 +140,15 @@ static void set_next_WP(struct Location *wp)
             prev_WP = current_loc;
     }
 
-    //cliSerial->printf("set_next_WP #%d, ", command_nav_index);
-    //print_wp(&prev_WP, command_nav_index -1);
-
     // Load the next_WP slot
     // ---------------------
-    next_WP = *wp;
-
-    // used to control and limit the rate of climb
-    // -------------------------------------------
-    // We don't set next WP below 1m
-    next_WP.alt = max(next_WP.alt, 100);
+    next_WP.options = wp->options;
+    next_WP.lat = wp->lat;
+    next_WP.lng = wp->lng;
 
-    // Save new altitude so we can track it for climb_rate
-    set_new_altitude(next_WP.alt);
+    // Set new target altitude so we can track it for climb_rate
+    // To-Do: remove the restriction on negative altitude targets (after testing)
+    set_new_altitude(max(wp->alt,100));
 
     // this is handy for the groundstation
     // -----------------------------------
-- 
GitLab