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)
As 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.