Skip to content

Commit

Permalink
AC_Fence: fixed pre-arm check for polygon fences
Browse files Browse the repository at this point in the history
for polygon fences we need to check if the vehicle has a position and
is inside the polygon
  • Loading branch information
tridge committed Nov 25, 2024
1 parent 0a32cca commit bc06501
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions libraries/AC_Fence/AC_Fence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,17 @@ bool AC_Fence::pre_arm_check_polygon(char *failure_msg, const uint8_t failure_ms
return false;
}

Location loc;
if (!AP::ahrs().get_location(loc)) {
hal.util->snprintf(failure_msg, failure_msg_len, "Fence requires position");
return false;
}

if (_poly_loader.breached(loc)) {
hal.util->snprintf(failure_msg, failure_msg_len, "Vehicle outside fence");
return false;
}

return true;
}

Expand Down

0 comments on commit bc06501

Please sign in to comment.