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 // called at 1hz
void Copter::fence_check() void Copter::fence_check()
{ {
uint8_t new_breaches; // the type of fence that has been breached // ignore any fence activity when not armed
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
if(!motors->armed()) { if(!motors->armed()) {
return; 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 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 the user wants some kind of response and motors are armed
if(fence.get_action() != AC_FENCE_ACTION_REPORT_ONLY ) { if(fence.get_action() != AC_FENCE_ACTION_REPORT_ONLY ) {
@ -44,10 +43,9 @@ void Copter::fence_check()
// log an error in the dataflash // log an error in the dataflash
Log_Write_Error(ERROR_SUBSYSTEM_FAILSAFE_FENCE, new_breaches); Log_Write_Error(ERROR_SUBSYSTEM_FAILSAFE_FENCE, new_breaches);
}
// record clearing of breach } else if (orig_breaches) {
if(orig_breaches != AC_FENCE_TYPE_NONE && fence.get_breaches() == AC_FENCE_TYPE_NONE) { // record clearing of breach
Log_Write_Error(ERROR_SUBSYSTEM_FAILSAFE_FENCE, ERROR_CODE_ERROR_RESOLVED); Log_Write_Error(ERROR_SUBSYSTEM_FAILSAFE_FENCE, ERROR_CODE_ERROR_RESOLVED);
} }
} }