Low-altitude fence

Hi all,

I've been working on a low-altitude fence for ArduCopter, and wanted to get peoples' input on how they'd like for something like that to work if they were going to use it.

The idea is that if you're flying over water or weeds (or other conditions where a landing is undesirable), a low-altitude fence prevents the copter from descending beyond a certain altitude.

I added a new value to the FENCE_TYPE mask, so it can be used in conjunction with or in lieu of the other fence types, or excluded.

I added a FENCE_MIN_ALT parameter specifying the minimum altitude, in meters. With the fence set to REPORT_ONLY, it keeps the altitude at or above FENCE_MIN_ALT while the low-altitude fence is active.

I added a FENCE_LOW_RADIUS parameter specifying the number of meters from the launch point at which the low-altitude fence becomes active. Inside this radius, the copter flies normally, and it's possible to land, etc. Beyond this radius, the fence reports a breach if the altitude falls below the FENCE_MIN_ALT's specified value. 

In testing, it's getting the expected results. If I set a FENCE_LOW_RADIUS of 20 and a FENCE_MIN_ALT of 10, then launch and fly at 1-2 meters, the copter flies normally until it reaches 20 meters from launch, then rises to 10 meters. At that point, I can fly around at 0 throttle, and the copter stays at 10 meters until I get back inside the radius. At that point, the copter descends as if the fence were not active. 

I'd like to see what everyone thinks of the idea, and what they think of the way it's described here. 



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

Join diydrones

Email me when people reply –


  • Nice feature! It would be less stressful flying overhead water.

  • Thinking this through, the opposition would also be good. I also suffer from altitude drift to high. Would be cool to set an upper limit fence of say 150 feet so that I can just have fun turning and zipping around. I find the most stressful thing is bringing the unit back down from an undesired drift up too high
    • Hi Chris,

      This is already in place. The way I implemented the low-alt fence, it's just another fence type. Normally, if you turn on the fence and set a max altitude and a max distance, you effectively have an invisible "cylinder" around you, outside of which your copter cannot fly. The low-alt fence just adds a "floor" to the cylinder beyond the radius, below which it can't fly. 

      I actually forgot I had that on my Iris. I had the "fence" switch turned on on the TX and was flying low along my driveway blowing grass clippings off of it (yes, really. :-)) It got near the end and suddenly shot up to 10 meters and wouldn't come back down. I was puzzled for a second until I realized it was the low-alt fence doing its thing. :-)

  • Now this is exactly what I need. When flying fpv I often see some drift down to the point where I lose track and get too close to ground. I find myself constantly checking altitude on the osd. I just ordered a sonar module with the idea that I could somehow have channel 7 switch rigged to set a 20 foot floor where the copter would not go below that. Do you have this running yet?
    • Hi Chris, 

      Yes, I've had it running for a while now, probably 4 months. It's being run on some drones from someone I know in New Zealand. He runs his drones over the ocean, and uses this to ensure he (and his customers) don't fly them into the ocean. I submitted a PR for this, but I don't think it ever got merged. 


This reply was deleted.