Skip to content

Commit

Permalink
AC_Fence: A circular fence with a radius of 0 meters is ignored
Browse files Browse the repository at this point in the history
  • Loading branch information
muramura committed May 18, 2024
1 parent 5cf2c27 commit 33f5f41
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion libraries/AC_Fence/AC_PolyFence_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,7 @@ bool AC_PolyFence_loader::validate_fence(const AC_PolyFenceItem *new_items, uint
GCS_SEND_TEXT(MAV_SEVERITY_WARNING, "Received incorrect type (want=%u got=%u)", (unsigned)expecting_type, (unsigned)new_items[i].type);
return false;
}
if (!is_positive(new_items[i].radius)) {
if (is_negative(new_items[i].radius)) {
GCS_SEND_TEXT(MAV_SEVERITY_WARNING, "Non-positive circle radius");
return false;
}
Expand Down Expand Up @@ -1093,6 +1093,10 @@ bool AC_PolyFence_loader::write_fence(const AC_PolyFenceItem *new_items, uint16_
return false;
case AC_PolyFenceType::CIRCLE_INCLUSION:
case AC_PolyFenceType::CIRCLE_EXCLUSION: {
if (!is_positive(new_item.radius)) { // radius must be positive
break;
}

total_vertex_count++; // useful to make number of lines in QGC file match FENCE_TOTAL
const bool store_as_int = (new_item.radius - int(new_item.radius) < 0.001);
AC_PolyFenceType store_type = new_item.type;
Expand Down

0 comments on commit 33f5f41

Please sign in to comment.