Skip to content
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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

rishabsingh3003
Copy link
Contributor

This PR fixes the bug stated in #13125
There are a couple of problems that are addressed in this PR.

  1. Minimum distance from inclusion/exclusion of polygon/circular polygon fence is calculated after a breach.
  2. A backup fence is created 20 meters ahead of a fresh breach to force a vehicle to follow fence breach action.
    This makes the polygon fence behave exactly like the other two fence types which was not the case until now.

Testing:

  1. Tools/scripts/build_all.sh ran successfully
  2. I tested all fence types in SITL, and they work as they should.

@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

// 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;
Copy link
Contributor

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

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)) {
Copy link
Contributor

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

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) {
Copy link
Contributor

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?

@peterbarker
Copy link
Contributor

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
@rishabsingh3003
Copy link
Contributor Author

I have made the changes that were discussed in the last Dev Call.

  • @peterbarker the function has been moved to AC_PolyFence_loader.cpp
  • There was no need for the sanity check as it is automatically done beforehand, hence I have removed it.
    -@tridge in the updated PR I have checked for breach first and then calculated distance from the fence.

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.
Here is the new video - https://youtu.be/yn_AyOjseoE

@khancyr khancyr self-assigned this Jul 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants