AP_Arming: fixed auto-enable of fence with forced arm

when a user forced armed and had FENCE_AUTOENABLE=3 for enable on
arming then the fence did not enable
This commit is contained in:
Andrew Tridgell 2023-08-08 07:09:24 +10:00 committed by Randy Mackay
parent e3a049ba40
commit 7da87a811f
1 changed files with 13 additions and 10 deletions

View File

@ -1516,16 +1516,6 @@ bool AP_Arming::arm_checks(AP_Arming::Method method)
}
}
#if AP_FENCE_ENABLED
AC_Fence *fence = AP::fence();
if (fence != nullptr) {
// If a fence is set to auto-enable, turn on the fence
if(fence->auto_enabled() == AC_Fence::AutoEnable::ONLY_WHEN_ARMED) {
fence->enable(true);
}
}
#endif
// note that this will prepare AP_Logger to start logging
// so should be the last check to be done before arming
@ -1603,6 +1593,19 @@ bool AP_Arming::arm(AP_Arming::Method method, const bool do_arming_checks)
}
#endif
#if AP_FENCE_ENABLED
if (armed) {
auto *fence = AP::fence();
if (fence != nullptr) {
// If a fence is set to auto-enable, turn on the fence
if (fence->auto_enabled() == AC_Fence::AutoEnable::ONLY_WHEN_ARMED) {
fence->enable(true);
gcs().send_text(MAV_SEVERITY_INFO, "Fence: auto-enabled");
}
}
}
#endif
return armed;
}