Skip to content

Geofence ​

TIP

A geofence keeps the aircraft inside a defined area. When it crosses the boundary or the altitude limit, the configured action fires (RTL, hold, and so on). It is one of the main safety measures you have.

Concepts ​

  • Circle fence: a circular boundary defined by a centre point and a radius.
  • Polygon fence: a boundary drawn as a polygon through a series of waypoints.
  • Altitude fence: caps the maximum flight height.
  • Fence action: what the aircraft does when the fence triggers (RTL, Land, AltHold and so on).

ArduPilot parameters ​

  • FENCE_ENABLE: turns the geofence on (1) or off (0).
  • FENCE_TYPE: fence type, as a bitmask (1 = circle, 2 + 3 = polygon plus max altitude, 4 = max altitude, and so on).
  • FENCE_RADIUS: circle fence radius, in metres.
  • FENCE_ALT_MAX: maximum flight height, in metres.
  • FENCE_ACTION: what happens when the fence triggers (1 = RTL, 2 = Land, 3 = AltHold).
  • FENCE_MARGIN: buffer distance at the fence edge, in metres.

NOTE

The fence boundary moves with the aircraft's latitude and longitude, so check before takeoff that the area you are in matches the fence configuration — otherwise it may trigger by mistake.

Setup steps ​

  1. Connect the controller to the ground station.
  2. In the parameter list, set the fence type, the radius or boundary, and the maximum altitude.
  3. Set FENCE_ACTION to the response you want.
  4. Write the parameters and restart the controller.
  5. Fly a test to confirm the fence really triggers at the boundary.

More tutorials ​