From ea27d1604a2107db4877d9bddb05221498f010f1 Mon Sep 17 00:00:00 2001 From: Amilcar Lucas Date: Sun, 9 Oct 2011 15:33:10 +0200 Subject: [PATCH 1/3] More optimizations I forgot these ones. --- ArduPlane/Attitude.pde | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/ArduPlane/Attitude.pde b/ArduPlane/Attitude.pde index e6f8a1bfaa..8564690453 100644 --- a/ArduPlane/Attitude.pde +++ b/ArduPlane/Attitude.pde @@ -287,15 +287,19 @@ static void set_servos(void) g.channel_rudder.radio_out = g.channel_rudder.radio_in; // FIXME To me it does not make sense to control the aileron using radio_in in manual mode // Doug could you please take a look at this ? - if (g_rc_function[RC_Channel_aux::k_aileron] != rc_array[g.flight_mode_channel-1]) { - G_RC_AUX(k_aileron)->radio_out = g_rc_function[RC_Channel_aux::k_aileron]->radio_in; - } + if (g_rc_function[RC_Channel_aux::k_aileron]) { + if (g_rc_function[RC_Channel_aux::k_aileron] != rc_array[g.flight_mode_channel-1]) { + g_rc_function[RC_Channel_aux::k_aileron]->radio_out = g_rc_function[RC_Channel_aux::k_aileron]->radio_in; + } + } // only use radio_in if the channel is not used as flight_mode_channel - if (g_rc_function[RC_Channel_aux::k_flap_auto] != rc_array[g.flight_mode_channel-1]) { - G_RC_AUX(k_flap_auto)->radio_out = g_rc_function[RC_Channel_aux::k_flap_auto]->radio_in; - } else { - G_RC_AUX(k_flap_auto)->radio_out = g_rc_function[RC_Channel_aux::k_flap_auto]->radio_trim; - } + if (g_rc_function[RC_Channel_aux::k_flap_auto]) { + if (g_rc_function[RC_Channel_aux::k_flap_auto] != rc_array[g.flight_mode_channel-1]) { + g_rc_function[RC_Channel_aux::k_flap_auto]->radio_out = g_rc_function[RC_Channel_aux::k_flap_auto]->radio_in; + } else { + g_rc_function[RC_Channel_aux::k_flap_auto]->radio_out = g_rc_function[RC_Channel_aux::k_flap_auto]->radio_trim; + } + } } else { if (g.mix_mode == 0) { g.channel_roll.calc_pwm(); From 5c16a380c0dbbe38d3d53ca2c9379d5936ceeaa1 Mon Sep 17 00:00:00 2001 From: James Goppert Date: Sun, 9 Oct 2011 11:46:56 -0400 Subject: [PATCH 2/3] Fixed APO bug. --- libraries/APO/APO_DefaultSetup.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/APO/APO_DefaultSetup.h b/libraries/APO/APO_DefaultSetup.h index a74b58535e..94424e0253 100644 --- a/libraries/APO/APO_DefaultSetup.h +++ b/libraries/APO/APO_DefaultSetup.h @@ -123,7 +123,7 @@ void setup() { hal->rangeFinders.push_back(rangeFinder); } - } else + } /* * Select guidance, navigation, control algorithms From d47e43e0c429bc468f43f596bc6c6149348c1532 Mon Sep 17 00:00:00 2001 From: James Goppert Date: Sun, 9 Oct 2011 15:57:29 -0400 Subject: [PATCH 3/3] APO GPS bug fix. --- libraries/APO/APO_DefaultSetup.h | 3 ++- libraries/APO/AP_Autopilot.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/libraries/APO/APO_DefaultSetup.h b/libraries/APO/APO_DefaultSetup.h index 94424e0253..b378d5ded2 100644 --- a/libraries/APO/APO_DefaultSetup.h +++ b/libraries/APO/APO_DefaultSetup.h @@ -23,6 +23,7 @@ void setup() { AP_Guide * guide = NULL; AP_Controller * controller = NULL; AP_HardwareAbstractionLayer * hal = NULL; + /* * Communications */ @@ -50,6 +51,7 @@ void setup() { hal->debug->println_P(PSTR("initializing gps")); AP_GPS_Auto gpsDriver(&Serial1, &(hal->gps)); hal->gps = &gpsDriver; + hal->gps->callback = delay; hal->gps->init(); } @@ -155,7 +157,6 @@ void setup() { hal->hil = new COMMLINK_CLASS(&Serial1, navigator, guide, controller, hal); } - /* * Start the autopilot */ diff --git a/libraries/APO/AP_Autopilot.cpp b/libraries/APO/AP_Autopilot.cpp index 55251c720d..fa796d0626 100644 --- a/libraries/APO/AP_Autopilot.cpp +++ b/libraries/APO/AP_Autopilot.cpp @@ -45,6 +45,7 @@ AP_Autopilot::AP_Autopilot(AP_Navigator * navigator, AP_Guide * guide, if (hal->gps->fix) { break; } else { + hal->gps->update(); hal->gcs->sendText(SEVERITY_LOW, PSTR("waiting for gps lock\n")); hal->debug->printf_P(PSTR("waiting for gps lock\n")); @@ -67,8 +68,8 @@ AP_Autopilot::AP_Autopilot(AP_Navigator * navigator, AP_Guide * guide, break; } hal->debug->println_P(PSTR("waiting for hil packet")); - delay(1000); } + delay(1000); } AP_MavlinkCommand::home.setAlt(_navigator->getAlt());