From 1f7ba3870f92df00487dbcc83a9b599951574bff Mon Sep 17 00:00:00 2001 From: muramura Date: Thu, 9 May 2024 03:54:47 +0900 Subject: [PATCH] Rover: Perform an arm check first --- Rover/fence.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Rover/fence.cpp b/Rover/fence.cpp index 4c29b48d243dcd..8d53d73080878b 100644 --- a/Rover/fence.cpp +++ b/Rover/fence.cpp @@ -4,17 +4,16 @@ void Rover::fence_check() { #if AP_FENCE_ENABLED - uint8_t new_breaches; // the type of fence that has been breached - const uint8_t orig_breaches = fence.get_breaches(); - - // check for a breach - new_breaches = fence.check(); - // return immediately if motors are not armed if (!arming.is_armed()) { return; } + const uint8_t orig_breaches = fence.get_breaches(); + + // check for a breach + uint8_t new_breaches = fence.check(); + // if there is a new breach take action if (new_breaches) { // if the user wants some kind of response and motors are armed