MAVLINKHUD

Overview

The AFS parameter group configures the Advanced Failsafe library. This subsystem is distinct from the standard FS_ (Failsafe) parameters found in Plane/Copter. It is designed to meet strict Flight Termination System (FTS) requirements for regulatory compliance or competitions (e.g., UAV Challenge Outback Rescue).

Unlike standard failsafes which try to save the vehicle (RTL, Land), AFS is often designed to "Terminate" the flight to ensure safety of people on the ground if the vehicle goes rogue.

Key Concepts

1. Flight Termination (AFS_TERMINATE)

The core function of AFS. If a critical failure condition is met (RC Loss, GCS Loss, Geofence Breach), the system can be configured to:

  • Kill Motors: Immediately stop propulsion.
  • Move Servos: Force control surfaces to a "Crash" or "Spin" position (e.g., full rudder, full up elevator) to limit the impact area.
  • Hardware Pin: Drive a GPIO pin (AFS_TERM_PIN) high/low to trigger an external parachute deployment module or airbag.

AFS can monitor both the RC link and the GCS (MAVLink) link independently (AFS_DUAL_LOSS). It ensures that you always have at least one valid command link.

3. Heartbeat Hardware (AFS_HB_PIN)

Can output a "heartbeat" signal to an external watchdog timer. If the autopilot freezes, the heartbeat stops, and the external hardware terminates the flight.

Parameter Breakdown

  • AFS_ENABLE: Master switch.
  • AFS_TERM_ACTION: 0=Disable, 1=Terminate immediately on failure.
  • AFS_MAN_PIN: Input pin for a manual "Kill Switch" from an external receiver.
  • AFS_TERM_PIN: Output pin to trigger external termination hardware.
  • AFS_RC_FAIL_TIME: Timeout (seconds) for RC loss before termination.
  • AFS_AMSL_LIMIT: Hard altitude ceiling (AMSL) for termination.

Integration Guide

Typical Setup for FTS

  1. Enable: Set AFS_ENABLE = 1.
  2. Define Output: Set AFS_TERM_PIN to the Servo/GPIO connected to your parachute release or ignition kill.
  3. Define Logic: Configure AFS_RC_FAIL_TIME and AFS_GCS_TIMEOUT appropriately.
  4. Testing: REMOVE PROPELLERS. Use the AFS.TERMINATE MAVLink command or simulate a link loss to verify the pin switches state.

Developer Notes

  • Library: libraries/AP_AdvancedFailsafe
  • Vehicle: Primarily used in ArduPlane.
  • Warning: Misconfiguring this WILL crash your plane. This is a "destruct" system, not a "save me" system.

AFS_AMSL_ERR_GPS

m
Default -1

Error margin for GPS based AMSL limit (AFS_AMSL_ERR_GPS)

Description

Safety margin for GPS-based altitude limiting when the barometer fails.

Tuning & Behavior

  • Default Value: -1 m
  • -1 means barometer failure leads to immediate termination.

AFS_AMSL_LIMIT

m
Default 0

AMSL limit (AFS_AMSL_LIMIT)

Description

Maximum altitude (Above Mean Sea Level) allowed before forced termination.

Tuning & Behavior

  • Default Value: 0 m (Disabled)
  • Units are in meters.

AFS_DUAL_LOSS

Default 1

Enable dual loss terminate (AFS_DUAL_LOSS)

Description

Triggers termination if both GPS and GCS link are lost simultaneously.

Tuning & Behavior

  • Default Value: 1 (Enabled)
  • Values: 0:Disabled, 1:Enabled

AFS_ENABLE

Default 0

Enable Advanced Failsafe (AFS_ENABLE)

Description

Enables the advanced failsafe system.

Tuning & Behavior

  • Default Value: 0 (Disabled)
  • Values: 0:Disabled, 1:Enabled

AFS_GCS_TIMEOUT

s
Default 10

GCS timeout (AFS_GCS_TIMEOUT)

Description

Duration of GCS link loss before triggering failsafe.

Tuning & Behavior

  • Default Value: 10 s

AFS_GEOFENCE

Default 1

Enable geofence Advanced Failsafe (AFS_GEOFENCE)

Description

Enables geofence-triggered failsafes within the AFS system.

Tuning & Behavior

  • Default Value: 1 (Enabled)
  • Requires AFS_ENABLE = 1 to function.

AFS_HB_PIN

Default -1

Heartbeat Pin (AFS_HB_PIN)

Description

Digital output pin used for monitoring autopilot health via a 10Hz heartbeat.

Tuning & Behavior

  • Default Value: -1 (Disabled)
  • Values: -1:Disabled, 49:BB Blue GP0 pin 4, 50:AUXOUT1, 51:AUXOUT2, 52:AUXOUT3, 53:AUXOUT4, 54:AUXOUT5, 55:AUXOUT6, 57:BB Blue GP0 pin 3, 113:BB Blue GP0 pin 6, 116:BB Blue GP0 pin 5

AFS_MAN_PIN

Default -1

Manual Pin (AFS_MAN_PIN)

Description

Digital output pin indicating Manual mode.

Tuning & Behavior

  • Default Value: -1 (Disabled)

AFS_MAX_COM_LOSS

Default 0

Maximum number of comms loss events (AFS_MAX_COM_LOSS)

Description

Limit on how many times communication can be lost before the aircraft refuses to resume its mission.

Tuning & Behavior

  • Default Value: 0 (Unlimited)

AFS_MAX_GPS_LOSS

Default 0

Maximum number of GPS loss events (AFS_MAX_GPS_LOSS)

Description

Limit on how many times GPS signal can be lost before the aircraft refuses to resume its mission.

Tuning & Behavior

  • Default Value: 0 (Unlimited)

AFS_MAX_RANGE

km
Default 0

Max allowed range (AFS_MAX_RANGE)

Description

Distance limit from the arming point, triggering termination if exceeded.

Tuning & Behavior

  • Default Value: 0 km (Disabled)
  • Units are in kilometers.

AFS_OPTIONS

Default 0

AFS options (AFS_OPTIONS)

Description

Bitmask for configuring specific Advanced Failsafe behaviors.

Tuning & Behavior

  • Default Value: 0
  • Bitmask:
    • 0: Continue the mission even after comms are recovered (does not go to the mission item at the time comms were lost)
    • 1: Enable AFS for all autonomous modes (not just AUTO)
      Internal logic check: bit 0 skips returning to the exact WP where comms were lost; bit 1 extends protection beyond just the AUTO mission mode.

AFS_QNH_PRESSURE

hPa
Default 0

QNH pressure (AFS_QNH_PRESSURE)

Description

Reference sea-level pressure for barometric altitude limit calculation.

Tuning & Behavior

  • Default Value: 0 hPa (Disabled)
  • Must be set correctly for AMSL limiting to be accurate.

AFS_RC

Default 1

Enable RC Advanced Failsafe (AFS_RC)

Description

Enables RC-link loss detection and associated actions within the AFS system.

Tuning & Behavior

  • Default Value: 1 (Enabled)
  • Requires AFS_ENABLE = 1 to function.

AFS_RC_FAIL_TIME

s
Default 0

RC failure time (AFS_RC_FAIL_TIME)

Description

Duration of RC link loss in manual mode before forced termination.

Tuning & Behavior

  • Default Value: 0 s (Disabled)
  • Recommended for OBC rules: 1.5 seconds.

AFS_RC_MAN_ONLY

Default 1

Enable RC Termination only in manual control modes (AFS_RC_MAN_ONLY)

Description

Restricts RC-loss termination to manual flight modes only.

Tuning & Behavior

  • Default Value: 1 (Manual Only)
  • Values: 0:All Modes, 1:Manual Modes Only

AFS_TERMINATE

Default 0

Force Terminate (AFS_TERMINATE)

Description

Software switch to immediately trigger vehicle termination.

Tuning & Behavior

  • Default Value: 0 (Normal)
  • Setting this to 1 in flight will terminate the vehicle.

AFS_TERM_ACTION

Default 0

Terminate action (AFS_TERM_ACTION)

Description

Specific vehicle behavior to execute when termination is triggered.

Tuning & Behavior

  • Default Value: 0
  • Common values include crashing or immediate landing.

AFS_TERM_PIN

Default -1

Terminate Pin (AFS_TERM_PIN)

Description

Digital output pin triggered high when the flight is terminated.

Tuning & Behavior

  • Default Value: -1 (Disabled)
  • Values: -1:Disabled, 49:BB Blue GP0 pin 4, 50:AUXOUT1, 51:AUXOUT2, 52:AUXOUT3, 53:AUXOUT4, 54:AUXOUT5, 55:AUXOUT6, 57:BB Blue GP0 pin 3, 113:BB Blue GP0 pin 6, 116:BB Blue GP0 pin 5

AFS_WP_COMMS

Default 0

Comms Waypoint (AFS_WP_COMMS)

Description

Waypoint designated for navigation when communication link is lost.

Tuning & Behavior

  • Default Value: 0 (None)

AFS_WP_GPS_LOSS

Default 0

GPS Loss Waypoint (AFS_WP_GPS_LOSS)

Description

Waypoint designated for navigation when GPS signal is lost.

Tuning & Behavior

  • Default Value: 0 (None)