Safeguard
Developer Tools•

Geofence and return mode: choosing safe actions for your drone

In PX4 a geofence breach can trigger Warning, Hold, Return, Land or Terminate. How to choose an action, and why Terminate is off by default.

Safeguard Security Team
3 min read

In PX4, a geofence breach can trigger None, Warning, Hold, Return, Terminate or Land, set by the GF_ACTION parameter. Terminate is disabled unless the CBRK_FLIGHTTERM circuit breaker is reset. For strict no fly zones the documentation suggests Hold with a safety margin. Return needs a clear path back.

What the geofence checks

The PX4 documentation describes the geofence failsafe as triggering when the vehicle leaves the horizontal or vertical limit. You choose the action with GF_ACTION. The options are None, Warning, Hold, Return, Terminate and Land.

That is a lot of choices for a single event. The right one depends on what is outside the fence and what is on the way back.

Choosing an action

SituationA reasonable starting choice
Strict no fly zone, such as an airport edgeHold, with a safety margin inside the line
Open site, clear route homeReturn
Obstacles on the return pathLand, or Hold and let the pilot decide
Test flights over waterThink hard about Land and Terminate

The table reflects general practice and the PX4 note about strict zones. It is not a recommendation for your site, so test it.

Why Hold is the documented choice for strict zones

Return flies the vehicle to its home position. If home lies on the far side of the fence, a return can carry the aircraft further through the very zone you wanted to avoid. Hold stops the aircraft where it is, which keeps the breach small. The documentation also says to use a safety margin, so the fence trips before the boundary.

Return mode details

The Return behavior, including return altitude and loiter time, is set in the ground station's return settings. The documentation says defaults usually suffice, but fixed wing vehicles generally need a defined mission landing, and the Return mode page should be read for your vehicle type before you change settings.

Terminate is a last resort

Terminate stops the motors in flight. It is disabled unless a circuit breaker is reset, which tells you how seriously the project treats it. Think of it as a tool for a flyaway near people when no other action is acceptable, and then only after testing and with a clear policy.

Testing

  • Simulate a breach before flying the real aircraft.
  • Fly a low risk test near the fence, with a pilot ready to take over.
  • Verify the return altitude clears obstacles near the fence.
  • Check the combination of a geofence breach and a link loss.
  • Keep the parameter file, and diff it after updates.

Why this is a security topic

A geofence is a control that software enforces. Changes to the parameters or to the fence file change the behavior of the aircraft, so treat them like any security relevant configuration. Limit who can edit them, keep approved versions in version control and review changes.

Quick check

Is Terminate available by default as a geofence action?

No. The PX4 documentation says Terminate is disabled unless CBRK_FLIGHTTERM is reset.

What does the documentation suggest for strict no fly zones?

Use Hold and a safety margin, according to the PX4 safety configuration page.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.