From 0f957bdc5af68c0c49272d2a95c20299ca28d6f7 Mon Sep 17 00:00:00 2001
From: Randy Mackay <rmackay9@yahoo.com>
Date: Fri, 17 Jan 2014 17:31:28 +0900
Subject: [PATCH] Copter: lean angle arming check

---
 ArduCopter/motors.pde | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/ArduCopter/motors.pde b/ArduCopter/motors.pde
index e55b16b1c..725c9e857 100644
--- a/ArduCopter/motors.pde
+++ b/ArduCopter/motors.pde
@@ -471,6 +471,16 @@ static bool arm_checks(bool display_failure)
         }
     }
 
+    // check lean angle
+    if ((g.arming_check == ARMING_CHECK_ALL) || (g.arming_check & ARMING_CHECK_INS)) {
+        if (labs(ahrs.roll_sensor) > g.angle_max || labs(ahrs.pitch_sensor) > g.angle_max) {
+            if (display_failure) {
+                gcs_send_text_P(SEVERITY_HIGH,PSTR("Arm: Leaning"));
+            }
+            return false;
+        }
+    }
+
     // check if safety switch has been pushed
     if (hal.util->safety_switch_state() == AP_HAL::Util::SAFETY_DISARMED) {
         if (display_failure) {
-- 
GitLab