Copter-3.4's polygon fence

One of the more important features that will arrive with Copter-3.4 (still in beta testing) is the Polygon Fence (the full list of features can be seen in the ReleaseNotes.txt).

Plane has had the polygon fence for years but when we added it to Copter, we also added the ability to stop at the fence in Loiter mode and when using Guided mode's velocity controller.  This stop-at-the-fence feature is quite exciting, not only because it's a feature people have been asking for for a long time but because it's also a solid step towards reliable object avoidance.

If you want to give it a try now and are happy to accept the risks of beta testing, there's a quick how-to video below showing how to define and upload the fence using the Mission Planner (MAVProxy can also be used but other GCSs don't yet support this feature).  Over the coming weeks we will update the wiki to include this info.  For those not looking to become beta testers you can look forward to it once Copter-3.4 is official released.

You can also find the code showing how we implemented stop-at-the-fence here.

Some extra info and a couple of warnings:

  • The fence can theoretically have up to 84 points but I have not tested with more than about 10 so far.  As the number of points grows, it does require a small amount of additional CPU so we will keep an eye on the "PM" (performance management) dataflash log message to see if the real limit is less than 84.
  • There is also a slight issue with very acute angles meaning the vehicle might be able to breach the fence if you create a fence that looks like Bart Simpson's hair.  Nothing horrible will happen except that the vehicle will RTL as it normally does when it breaches the fence.

By the way, the stop-at-the-fence feature works with the circular fence as well. If you define both a circular and a polygon fence, the vehicle will stop at whichever barrier it hits first (i.e. the green lines shown below)

3689697879?profile=originalAs I mentioned above, if you do give it a try, remember that Copter-3.4-rc2 is still beta so although it seems quite solid it's best to keep your eyes our for troubles, don't test on a vehicle that you could not stand to be involved in a crash and report any issues on our discourse server.

Thanks in particular to Leonard Hall and Daniel Ricketts for the code to stop the vehicle at the fence.

E-mail me when people leave their comments –

You need to be a member of diydrones to add comments!

Join diydrones


  • Randy,  Any chance you could ask Michael to include a "clear polygon fence" feature?  Still a bit unclear on how to remove mine now that it's in place.

  • Developer
    The discourse server is the new forums if it was unclear. Discourse is modern discussion forum software that works,
    ArduPilot Open Source Autopilot
    The most advanced open source autopilot for use by both professionals and hobbyist. Supports multi-copters, planes, rovers, boats, helicopters, ante…
  • T3


    this is a great feature! Any additional security is important.

    What would be perfect would be if the polygon fence is automatically set around a survey mission area (for sure with some small buffer). This could be a simple convex hull. But I guess this is a job for the ground control stations and mission planning.


This reply was deleted.