-
Notifications
You must be signed in to change notification settings - Fork 18.2k
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
Fence warn at the margins #28840
base: master
Are you sure you want to change the base?
Fence warn at the margins #28840
Conversation
ce3674f
to
9fbfa49
Compare
9fbfa49
to
336ea4e
Compare
336ea4e
to
9fbfa49
Compare
Do you have any references to the specific regulatory requirements for fences? |
Let's be careful about spamming the user when in Loiter mode and the user pushes the vehicle against the fence |
9fbfa49
to
4f9ad37
Compare
3248d57
to
5f08d05
Compare
Getting the maths right on this was actually quite hard. Think I might have it now. |
Thoughts on unit tests to prove they are right? |
I added a unit test, did you not see it? |
So @rmackay9 what would you suggest here? If they have the option on and avoidance on and are in loiter mode, don't send the message? |
Totally missed it. Those look great. I'm guessing the choice of sphere approximation over something like ellipsoid with Vincenty's distance is because fences are usually small enough and with not enough accuracy that we can just neglect the difference? |
Yeah, I was relying on the reference @tpwrules sent me which shows that for small angles the haversine approximation is totally fine (the unit test demonstrates meter resolution). What wasn't fine was the original implementation which did not work at all for lat/lng 😛 |
345f1f2
to
91d63c3
Compare
Yep, we just might want a wiki note to not try to use fences to define boundaries the size of a country because you can be far enough off that you'll make the wrong people mad. |
I think you would have to have a margin the size of a country to run into this - which would be an odd thing to do
|
2854ea4
to
a0b9e86
Compare
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.
see if you can use the exiting function
It's probably worth putting this new information in the |
add margin checks to polyfence loader using Polygon_closest_distance_point()
calculate fence distance for polyfences and use it for margin breaches
…g at small distances add polygon proximity tests
a0b9e86
to
8011415
Compare
Using the Cartesian version of Polygon_closest_distance_point() saves about 1k, the overall cost is still 1k since this was not used before. |
I added some tests for the existing Polygon_closest_distance_point(), it gives accuracy down to about 30cm - which doesn't seem great, but its <1m so probably acceptable. |
libraries/AP_Math/polygon.cpp
Outdated
} | ||
|
||
// Haversine distance between two points given in 1e7 degrees | ||
static ftype haversine(long lat1_1e7, long lon1_1e7, long lat2_1e7, long lon2_1e7) |
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.
unused code?
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.
Need to remove the new unused code
Need performance numbers
Move the in-margin stuff to a thread?
libraries/AC_Fence/AC_Fence.cpp
Outdated
if (_poly_loader.breached()) { | ||
|
||
Location loc; | ||
bool have_location = AP::ahrs().get_location(loc); |
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.
bool have_location = AP::ahrs().get_location(loc); | |
const bool have_location = AP::ahrs().get_location(loc); |
we need the worst case CPU cost, and quite possibly move to a IO callback, maybe at 20Hz or so |
This PR allows you to get a repeated warning when flying outside FENCE_MARGIN but inside the fence itself. Can be enabled by setting FENCE_OPTIONS=4. Multiple people have requested this because they are required to have a hard fence with failsafe action for regulatory reasons but want to know when they are close so they can avoid the action (typically when flying manually)