Copter: remove argument to check()

Also, check() was check_fence()
This commit is contained in:
Peter Barker 2017-12-15 20:36:25 +11:00 committed by Francisco Ferreira
parent aa482bae40
commit cb129fbdaf
1 changed files with 9 additions and 11 deletions

View File

@ -8,19 +8,18 @@
// called at 1hz
void Copter::fence_check()
{
uint8_t new_breaches; // the type of fence that has been breached
uint8_t orig_breaches = fence.get_breaches();
// check for a breach
new_breaches = fence.check_fence(current_loc.alt/100.0f);
// return immediately if motors are not armed
// 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();
// if there is a new breach take action
if( new_breaches != AC_FENCE_TYPE_NONE ) {
if (new_breaches) {
// if the user wants some kind of response and motors are armed
if(fence.get_action() != AC_FENCE_ACTION_REPORT_ONLY ) {
@ -44,10 +43,9 @@ void Copter::fence_check()
// log an error in the dataflash
Log_Write_Error(ERROR_SUBSYSTEM_FAILSAFE_FENCE, new_breaches);
}
} else if (orig_breaches) {
// record clearing of breach
if(orig_breaches != AC_FENCE_TYPE_NONE && fence.get_breaches() == AC_FENCE_TYPE_NONE) {
Log_Write_Error(ERROR_SUBSYSTEM_FAILSAFE_FENCE, ERROR_CODE_ERROR_RESOLVED);
}
}