diff --git a/libraries/AP_Arming/AP_Arming.cpp b/libraries/AP_Arming/AP_Arming.cpp index 5eae0afc39..827092b301 100644 --- a/libraries/AP_Arming/AP_Arming.cpp +++ b/libraries/AP_Arming/AP_Arming.cpp @@ -188,11 +188,19 @@ uint16_t AP_Arming::compass_magfield_expected() const return AP_ARMING_COMPASS_MAGFIELD_EXPECTED; } -bool AP_Arming::is_armed() +bool AP_Arming::is_armed() const { return armed || arming_required() == Required::NO; } +/* + true if armed and safety is off + */ +bool AP_Arming::is_armed_and_safety_off() const +{ + return is_armed() && hal.util->safety_switch_state() != AP_HAL::Util::SAFETY_DISARMED; +} + uint32_t AP_Arming::get_enabled_checks() const { return checks_to_perform; @@ -1616,7 +1624,7 @@ bool AP_Arming::disarm(const AP_Arming::Method method, bool do_disarm_checks) return true; } -AP_Arming::Required AP_Arming::arming_required() +AP_Arming::Required AP_Arming::arming_required() const { #if AP_OPENDRONEID_ENABLED // cannot be disabled if OpenDroneID is present diff --git a/libraries/AP_Arming/AP_Arming.h b/libraries/AP_Arming/AP_Arming.h index 0acda955cb..70e0611ac9 100644 --- a/libraries/AP_Arming/AP_Arming.h +++ b/libraries/AP_Arming/AP_Arming.h @@ -85,10 +85,11 @@ public: void init(void); // these functions should not be used by Copter which holds the armed state in the motors library - Required arming_required(); + Required arming_required() const; virtual bool arm(AP_Arming::Method method, bool do_arming_checks=true); virtual bool disarm(AP_Arming::Method method, bool do_disarm_checks=true); - bool is_armed(); + bool is_armed() const; + bool is_armed_and_safety_off() const; // get bitmask of enabled checks uint32_t get_enabled_checks() const;