AP_Arming: added is_armed_and_safety_off()

This commit is contained in:
Andrew Tridgell 2023-02-11 13:35:16 +11:00
parent 49fb4f37c5
commit bddd716cf9
2 changed files with 13 additions and 4 deletions

View File

@ -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

View File

@ -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;