Developer

new ArduPlane feature - geo-fencing

geofence-CMAC.jpgThe dev team is delighted to give a Christmas present to ArduPlane users in the form of a new geo-fencing feature!

Geo-fencing allows you to define a GPS fence around your flying area, plus a minimum and maximum altitude. Within the fence you can fly ArduPlane normally in any mode you like. If you go outside the fenced area then the APM will automatically take over and bring the plane back to a pre-defined return point, ready for you to have another go.

We're hoping that this feature will both help beginners learn to fly, and also allow experts to perfect complex aerobatic stunts while minimising the risk of a crash. It is also ideal for ensuring that local club rules on flight boundaries and maximum altitude are followed.

You can read all about how to setup and use the new feature in the ArduPlane wiki, but I thought it might be fun to tell you about a test I did of geo-fencing yesterday at my local flying field.

It was Christmas eve, and I was at CMAC testing the geo-fencing code. A family had turned up to watch the planes flying, including Wilson, a 5 year old who loves aeroplanes

IMG_20111224_114020.jpgI thought this would be the perfect opportunity to test geo-fencing as a training tool, so I asked Wilson if he'd like to try flying a plane by himself. As you might imagine, he enthusiastically agreed!

I took up my SkyWalker with the APM2 fitted, and then enabled the geo-fence. At first I put it in a loiter at about 70 meters, and showed Wilson how he could control the loiter using the transmitter sticks. After mastering that we put the plane in FBWA mode, and Wilson flew it himself. He was delighted!

The fencing really made a difference, as he made some mistakes and flew outside the defined area or too low a few times, but each time the APM took over and brought the plane back to the return point, where it loitered ready for him to have another go. We then flicked the trainer switch to give him control again, and he took the plane around more than a dozen circuits. Not bad for the first time flying a plane at that age!

IMG_20111224_113929.jpg

I also did some test flights with my SkyFun yesterday, and I was delighted to find it worked very well with geo-fencing. One of the reasons I added the geo-fencing feature was to help me improve my manual flying skills. I've found that flying with the APM stabiliser enabled means that my flying skills don't improve as much as I'd like, so I really wanted to practice flying more in manual mode, but I also found that in manual I tend to crash far too often. With the geo-fence enabled I can fly in manual with a safety net. That allows me to really improve my flying skills without crashing. It means I don't need to remember to change modes when I get in trouble - the APM is constantly monitoring my position and altitude, and if I am about to crash it takes over and brings the plane back ready for another try. Great fun!

Many thanks to Wilson for test flying the new ArduPlane code and happy Christmas to ArduPlane users everywhere!

E-mail me when people leave their comments –

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

Join diydrones

Comments

  • Developer

    Hi Omar,

    You're right, the 100* is causing the int16 to overflow for values larger than 327 meters. I've just pushed a fix to the git master branch for the next release. Just change the 100 to 100.0 in 3 places in geofence.pde to fix the problem.

    Thanks for reporting this!

    Cheers, Tridge

  • Hi Tridge, I was having some troubles with the geofence max altitude value. My values set are:

    FENCE_ACTION,0
    FENCE_CHANNEL,5
    FENCE_MAXALT,1000
    FENCE_MINALT,0
    FENCE_TOTAL,6

    The breach_type triggering is FENCE_BREACH_MAXALT. I take a look in the code and see that the line:

    return (current_loc.alt > (g.fence_maxalt*100) + home.alt); 

    Is always returning true. My home location is about 850 meter (Curitiba/Brazil). I was testing in home after GPS fix in the ground. So the expression above is supposed to be:

    return 850 > 1000*100 + 850. But these values will lead to a False result.

    After some changes in the FENCE_MAXALT, I found that FENCE_MAXALT=327 meters doesn't trigger the guided mode and that 328 meter trigger it.

    Did someone have troubles like that?

    Cold be an intrinsic type conversion in the coded statement?

    regards,

    Omar

  • There was mention of this being added to the Arducopter Code.  However, today the roadmap came out indicating that new features would not be added to 2.X.  Does this mean Fencing for Arducopter will be waiting for 3.X?

     

    Thank you.

     

  • Moderator

    Could this be implemented in Arducopter Code? It would make for a great addition for insurers of your commercial AP rig :)

  • Well done that man !

  • Great work! That has so many applications for new and experienced pilots. Thank you for your work!

  • @Tridge, see my post on dev group, please.

  • Developer

    @Yure, sorry you didn't get a chance to code it! There is more to do in this area if you are still interested. For example, we need a way to enable the fence over mavlink (apart from RC override), and I also think it would be good to have a detection mechanism for when we haven't taken off yet, so you can enable the fence on the ground and not have to worry about it declaring a fence breach until you have taken off. Needs thinking about a bit though, as we do want it to enable if in the air but outside the fence.

    @evilmacaw, it works fine on an APM1, you just need to trim the code by disabling logging if you have one of the older 1280 based boards.

  • I love it  now all i have to do is afford an APM2 and i still have not gotten the hang of the Legacy  sigh ! 

  • Thanx for that code! This makes me happy and sad at the same time =) I was coding the same thing - but you did it faster =))))

This reply was deleted.