# Geofencing

{% hint style="info" %}
This feature is only applicable for PRS-M3DTEX users who are running firmware version 3.6.4 or later.
{% endhint %}

DJI has not yet released the functionality in the FlightHub 2 platform to export Custom Task Areas (i.e., geofences). This document will be updated when this feature is released. Meanwhile, AVSS PRS-M3DTEX users can use the QGroundControl platform to design their desired geofence and import it to the AVSS PRS-M3DTEX.

{% hint style="info" %}
This instruction set assumes that the user has already designed a geofence in FlightHub 2. For instructions on how to design a geofence in FlightHub 2, refer to the DJI FlightHub 2 user manual at the following link: <https://fh.dji.com/user-manual/en/overview.html>
{% endhint %}

## Download and Installation

Follow the instructions at the link below to install the *QGroundControl* platform onto a local computer: <https://docs.qgroundcontrol.com/master/en/qgc-user-guide/getting_started/download_and_install.html>

If prompted to select a firmware and vehicle type during the process, ensure that "PX4 Pro" and "Multi-Rotor" are both selected.

<figure><img src="/files/rw1vpxdda87P55LWP6Ep" alt="" width="563"><figcaption><p>Firmware Designation</p></figcaption></figure>

## Designing Geofence

Open QGroundControl and then click the “Fly Plan” icon to create the Geofence.

<figure><img src="/files/gsh9KpaecSMrqZExybND" alt=""><figcaption><p>QGroundControl Main Planning Screen</p></figcaption></figure>

Refer to the instructions at the link below to design the desired geofence:&#x20;

<https://docs.qgroundcontrol.com/master/en/qgc-user-guide/plan_view/plan_geofence.html>

Ensure that "inclusion" is selected as the Fence type, as this will match the green “Custom Task Area” in DJI Flight Hub 2. Ensure that your fence matches the fence created in DJI Flight Hub 2 as closely as possible.

<figure><img src="/files/yHm9civRFTOSXEM8MlsR" alt="" width="296"><figcaption><p>GeoFence Parameters</p></figcaption></figure>

## Exporting Geofence File

The following link shows how to export the designed geofence. Please save the geofence file as “*PX4\_mission.plan*” as this is the name that the AVSS PRS recognizes as its current geofence mission.

<https://docs.qgroundcontrol.com/master/en/qgc-user-guide/plan_view/plan_view.html>

## Importing Geofence File to AVSS PRS Using AVSS Assistant

As outlined previously in the "[Firmware Updates](/prs-m3dtex-for-dji-dock2/prs-m3dtex-for-dji-m3d-and-m3td/firmware-updates.md)" section of this manual, firmware updates are conducted by connecting the PRS to a local computer, accessing AVSS Assistant and placing the PRS into "SD mode". These steps are repeated here.

Similar to a firmware update, the user will then copy-pase the geofence file exported in the previous step (labeled as "*PX4\_mission.plan*") into the main directory of the PRS's SD card.

<figure><img src="/files/IGfZQNbqnWBEU46qpeH7" alt=""><figcaption><p>Geofence File Importation Onto SD Card</p></figcaption></figure>

## Checking Geofence Data

After successfully transferring the geofence file to the PRS SD Card storage, cycle the power of the PRS by unplugging the PRS fron the computer and then re-plugging it in.

{% hint style="danger" %}
ENSURE THAT THE PRS'S SD CARD DIRECTORY WINDOW IS CLOSED PRIOR TO DISCONNECTING THE PRS FROM THE COMPUTER TO AVOID CORRUPTING THE PRS SD CARD.
{% endhint %}

Upon re-connecting the PRS to the computer, follow the process detailed in the "[Firmware Updates](/prs-m3dtex-for-dji-dock2/prs-m3dtex-for-dji-m3d-and-m3td/firmware-updates.md)" section of this manual to put the PRS into "SD mode".

Once in "SD mode", navigate to the latest event log"

{% hint style="info" %}
When checking the event log, use the actual log number (e.g. 000008) as a guide to the most recent event log instead of the calendar date on the log file. A higher number indicates a more recent log.
{% endhint %}

Ensure that the geofence information in the event log (i.e. shape, coordinates) is consistent with the key information in the "*PX4\_mission.plan*" file. Note that the first two images shown below correspond to a circular geofence and the next two images correspond to a polygon geofence.

<div><figure><img src="/files/kc8Fmlx3zBqRTDcXxUbq" alt=""><figcaption><p>Geofence File (Px4_mission.plan) (circular)</p></figcaption></figure> <figure><img src="/files/wRhDIvkO1ockLtUNwWg3" alt=""><figcaption><p>Geofence Information in PRS-M3DTEX Event Log (circular)</p></figcaption></figure></div>

<div><figure><img src="/files/XWgBR1SFtJFNrXQPoxde" alt=""><figcaption><p>Geofence File (PX4_mission.plan) (polygon)</p></figcaption></figure> <figure><img src="/files/jm6JyBERr9CMb4YZsOYa" alt=""><figcaption><p>Geofence Information in PRS-M3DTEX Event Log (polygon)</p></figcaption></figure></div>

## Geofence Status in Flight

Once the geofence information on the PRS is confirmed, the user can install the PRS-M3DTEX on the DJI drone and check the status of the Geofence triggering function on the remote using the DJI Pilot float window. The following status indications will be shown in the window.

<table data-header-hidden><thead><tr><th valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top"><strong>Status</strong></td><td valign="top"><strong>Possible Values</strong></td></tr><tr><td valign="top">geofence_mission_status</td><td valign="top"><p><em>GEOFENCE_IDLE:</em> When no geofence mission is set</p><p><em>GEOFENCE_SYNCING:</em> When PRS synchronizes the geofence information with the drone</p><p><em>GEOFENCE_RUNNING:</em> When the geofence triggering function is active and running</p><p><em>GEOFENCE_ERROR:</em> When geofence information has an error</p></td></tr><tr><td valign="top">geofence_breach_status</td><td valign="top"><p>BREACH_NONE: When no geofence breach has happened</p><p>BREACH_MINALT: When a geofence breach happened due to violating minimum altitude</p><p>BREACH_MAXALT: When a geofence breach happened due to violating maximum altitude</p><p>BREACH_BOUNDARY: When a geofence breach happened due to crossing a boundary</p></td></tr><tr><td valign="top">geofence_id</td><td valign="top"><p><em>mission_opaque_id</em>,</p><p><em>geofence_circle_count</em>,</p><p><em>geofence_polygon_count</em></p><p>in the following format: “%04d-%04d-%04d” </p></td></tr></tbody></table>

## Geofence Design and Operational Considerations

#### Geofence Data Size Limit

Polygon geofences must have fewer than 50 vertices in total. Circle geofences must have fewer than 15. If these limits are exceeded, the PRS-M3DTEX will fail to fully import the geofence information and record one of the following messages in the event log: "*The geofence file is too large to import*", or "*Out of memory. DISARMED*".

<figure><img src="/files/LsubzaCPr2qwO4LyKWE9" alt=""><figcaption><p>Memory Full Status Message</p></figcaption></figure>

#### Operational Considerations

**Arming and Disarming**: The auto arming/disarming conditions of the Geofence triggering function are the same as the ATS’s. Please also note that when the geofence triggering function is armed, the drone must have already been in an inclusive geofence and outside of exclusive geofences.  Therefore, make sure the whole flight from takeoff to landing stays in an inclusive geofence zone and outside of any exclusive geofence zones.

### Geofence Buffer

The PRS geofence trigger method considers a distance buffer from the geofence that is uploaded to the PRS by the end user. The distance buffer is added to the uploaded geofence such that the Geofence Trigger Method does not trigger until the geofence + buffer distance is breached.&#x20;

**VERTICAL\_BUFFER\_BASELINE and HORIZONTAL\_BUFFER\_BASELINE**: The geofence triggering function in the PRS considers a vertical and horizontal buffer at the boundaries of the geofences where the parachute deployment command is masked. The baseline values for vertical and horizontal buffers are 30m and 20m, respectively. However, note that if the onboard GNSS module of the PRS estimates that vertical or horizontal accuracies are better, those values DO NOT overwrite the baseline values. For instance, if the GNSS module estimates that the vertical positioning accuracy is 25m, the vertical buffer is still the baseline value of 30m; however, if the GNSS module estimates that the horizontal positioning accuracy is 25m, the horizontal buffer will be set to 25m instead of the baseline value of 20m.

**GEOFENCE\_TRIGER\_DELAY**: If the drone crosses the geofence boundary and also passes the buffer distance discussed before, the pilot has 1 second to react and bring the drone back to a safe zone before the parachute is deployed.

**VERTICAL\_BUFFER\_MAXIMUM and HORIZONTAL\_BUFFER\_MAXIMUM**: If the onboard GNSS positioning error grows above a certain threshold, the PRS will disable the Geofence trigger function. The vertical and horizontal thresholds are 50m and 30m, respectively.

#### Ceiling - Maximum Altitude

The maximum altitude is based off of the Barometric Altitude Above Takeoff provided by the onboard barometer. To set the ceiling of the PRS open the AVSS Assistant software and connect the PRS to the computer via the provided USB-C cable.

After connecting to the PRS, click “Device Parameters”

<figure><img src="/files/4CHwKPKwItxHVLybZaL6" alt=""><figcaption><p>Device Parameters Window (AVSS Assistant)</p></figcaption></figure>

Then set the ceiling by adding a value in meters Above Takeoff Level in the “Set Maximum Safety Height” text box, then click “SET”. You should see the “Maximum Safety Height” change in the list of parameters above.

When planning a mission, provide a sufficient buffer in the altitude so that you clear any elevations in the terrain in your flight area.

{% hint style="warning" %}
When setting the Maximum Safety Height, consider the highest building/elevation point within the flight plan so that the Altitude Above Takeoff is never greater than the Maximum Safety Height.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://avss.gitbook.io/prs-m3dtex-for-dji-dock2/prs-m3dtex-for-dji-m3d-and-m3td/geofencing.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
