From 6327f4adf187b89d8fd2324e5fe15b8302261249 Mon Sep 17 00:00:00 2001 From: Randy Mackay <rmackay9@yahoo.com> Date: Sat, 11 Oct 2014 16:05:32 +0900 Subject: [PATCH] Copter: allow arming in GUIDED only from GCS Also changed mode_allows_arming function to accept arming_from_gcs param Also remove AUTOTUNE from arming list --- ArduCopter/flight_mode.pde | 6 ++++-- ArduCopter/motors.pde | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ArduCopter/flight_mode.pde b/ArduCopter/flight_mode.pde index e12b4c9f0..a87d1b714 100644 --- a/ArduCopter/flight_mode.pde +++ b/ArduCopter/flight_mode.pde @@ -267,8 +267,10 @@ static bool manual_flight_mode(uint8_t mode) { return false; } -static bool mode_allows_arming(uint8_t mode) { - if (manual_flight_mode(mode) || mode == LOITER || mode == ALT_HOLD || mode == POSHOLD || mode == AUTOTUNE || mode == GUIDED) { +// mode_allows_arming - returns true if vehicle can be armed in the specified mode +// arming_from_gcs should be set to true if the arming request comes from the ground station +static bool mode_allows_arming(uint8_t mode, bool arming_from_gcs) { + if (manual_flight_mode(mode) || mode == LOITER || mode == ALT_HOLD || mode == POSHOLD || (arming_from_gcs && mode == GUIDED)) { return true; } return false; diff --git a/ArduCopter/motors.pde b/ArduCopter/motors.pde index c1f893a9f..227158972 100644 --- a/ArduCopter/motors.pde +++ b/ArduCopter/motors.pde @@ -528,10 +528,10 @@ static bool pre_arm_gps_checks(bool display_failure) // arm_checks - perform final checks before arming // always called just before arming. Return true if ok to arm -static bool arm_checks(bool display_failure, bool request_from_gcs) +static bool arm_checks(bool display_failure, bool arming_from_gcs) { // always check if the current mode allows arming - if (!mode_allows_arming(control_mode) || (!request_from_gcs && control_mode == GUIDED)) { + if (!mode_allows_arming(control_mode, arming_from_gcs)) { if (display_failure) { gcs_send_text_P(SEVERITY_HIGH,PSTR("Arm: Mode not armable")); } -- GitLab