New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AC_Fence.cpp "get_breach_distance" function does not account for polygon fence breach #13152
base: master
Are you sure you want to change the base?
Conversation
libraries/AC_Fence/AC_Fence.cpp
Outdated
// ignore exclusion polygons with less than 3 points | ||
continue; | ||
} | ||
float distance_to_poly_new = Polygon_closest_distance_point(boundary, num_points,pos_vector)*0.01f; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs a check first if we are breached
libraries/AC_Fence/AC_Fence.cpp
Outdated
if (_poly_loader.get_exclusion_circle(i, center_pos_cm, radius)) { | ||
const float dist_circle_sq = (pos_vector - center_pos_cm).length(); | ||
const float dist_circle_new = (dist_circle_sq*0.01f) - radius; | ||
if(!distance_to_poly_updated || (dist_circle_new < _poly_breach_distance)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs a check if we are breached
libraries/AC_Fence/AC_Fence.cpp
Outdated
for (uint8_t i = 0; i < num_exclusion_polygons; i++){ | ||
uint16_t num_points; | ||
const Vector2f* boundary = _poly_loader.get_exclusion_polygon(i, num_points); | ||
if (num_points < 3) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this sanity check required?
Separate functions in the polyfence file. |
Breach is checked for each of the fence types and the breach distance is calculated. Minimum of those breach distance from each fence is returned.
Minimum distance from inclusion/exclusion of polygon fence is taken and back up fence 20 meters ahead of a fresh breach is created
7032ed5
to
63d475c
Compare
I have made the changes that were discussed in the last Dev Call.
I attached Mission Planner with SITL and printed out breach distance from each fence type (inclusion/exclusion polygon/circle) just to check if the added functionality is working. I believe it is working just like the other two fence types now. |
This PR fixes the bug stated in #13125
There are a couple of problems that are addressed in this PR.
This makes the polygon fence behave exactly like the other two fence types which was not the case until now.
Testing:
@peterbarker I have attached a before/after patch video as you asked.
Before the fix: https://youtu.be/Ucp3cFpP4Eg
After the fix: https://youtu.be/MloaZ69uOco