Skip to content

Commit

Permalink
AP_Arming: fixed auto-enable of fence with forced arm
Browse files Browse the repository at this point in the history
when a user forced armed and had FENCE_AUTOENABLE=3 for enable on
arming then the fence did not enable
  • Loading branch information
tridge committed Aug 7, 2023
1 parent 843a14e commit 7ffc8b0
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions libraries/AP_Arming/AP_Arming.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1551,16 +1551,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

Expand Down Expand Up @@ -1638,6 +1628,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;
}

Expand Down

0 comments on commit 7ffc8b0

Please sign in to comment.