A geofence check is done:
- whenever a new mission is sent to the autopilot
- the current position of the system is updated
On a violation of the geofence a warning is printed in qGroundControl.
Geofencing is enabled if the file
fs/microsd/etc/geofence.txt exists and the parameter
GF_ACTION is set to 0 = none, 1 = warning (default), 2 = loiter, 3 = return to launch, 4 = fight termination.
GF_COUNT sets the number of subsequent 'outside of geofence' detections (= positions measurements) which are needed before the geofence violation is triggered. This parameter can be used to make the fence more robust against gps/estimator glitches.
Source and altitude mode
- The param GF_SOURCE defines which position source is used: 0 for global position (position estimator), 1 for raw gps
- The param GF_ALTMODE defines which altitude reference is used for the vertical geofence limit. O: wgs84 (AMSL from GPS), 1: QNH (altitude calcualted from barometer + local ground offset (QNH))
fs/microsd/etc/geofence.txt holds the points for the geofence polygon. There are two options for the coordinate format: Decimal degrees and the Degree-Minute-Second Format. The first line always holds the vertical limits in meters AMSL (
altitude_min altitude_max). For a minimal altitude which corresponds to the ground set the lower vertical limit to a value « 0.
Example: Decimal Degrees
0 900 47.475273548913222 8.52672100067138672 47.4608261578541359 8.53414535522460938 47.4613484218861217 8.56444358825683594 47.4830758091035534 8.53470325469970703
0 900 DMS -26 -34 -10.4304 151 50 14.5428 DMS -26 -34 -11.8416 151 50 21.8580 DMS -26 -34 -36.5628 151 50 28.1112 DMS -26 -34 -37.1640 151 50 24.1620