Copter: check for fence breaches when disarmed

This commit is contained in:
chobits 2018-05-08 10:04:55 +08:00 committed by Randy Mackay
parent 4d5e258b19
commit 75c2a2b02a
1 changed files with 7 additions and 5 deletions

View File

@ -8,16 +8,18 @@
// called at 1hz
void Copter::fence_check()
{
// ignore any fence activity when not armed
if(!motors->armed()) {
return;
}
const uint8_t orig_breaches = fence.get_breaches();
// check for new breaches; new_breaches is bitmask of fence types breached
const uint8_t new_breaches = fence.check();
// we still don't do anything when disarmed, but we do check for fence breaches.
// fence pre-arm check actually checks if any fence has been breached
// that's not ever going to be true if we don't call check on AP_Fence while disarmed.
if (!motors->armed()) {
return;
}
// if there is a new breach take action
if (new_breaches) {