MAVLINKHUD

Overview

The INJECT parameter group (specifically INJECT_TO or GPS_INJECT_TO) configures the routing of RTK Correction data.

Key Concepts

1. RTK Routing

In a dual-GPS system, the RTK correction data (RTCM) arrives from the Ground Station over the telemetry link. The autopilot must decide which physical GPS receiver to send this data to.

  • INJECT_TO:
    • 0: Send to GPS 1.
    • 1: Send to GPS 2.
    • 127: Send to all connected GPS units.

Developer Notes

  • Library: libraries/AP_GPS.
  • Context: Critical for centimeter-level positioning accuracy.

INJECT_TO

Index
Default 127
Range 0 127

GPS Data Injection Target (INJECT_TO)

Description

This parameter controls the routing of "GPS_INJECT_DATA" MAVLink packets. These packets are typically used to send RTK (Real-Time Kinematic) corrections from a Ground Control Station (GCS) to the autopilot, enabling centimeter-level positioning accuracy.

If your vehicle has multiple GPS sensors, you can use this parameter to decide if the corrections should go to a specific GPS instance (e.g., just the primary one) or be "broadcast" to all connected GPS modules simultaneously.

The Mathematics

The value maps to the internal GPS instance index ($i$):

  • 0: GPS 1 (First instance).
  • 1: GPS 2 (Second instance).
  • 127: All GPS instances (Broadcast mode).

The Engineer's View

In AP_GPS::handle_msg() (libraries/AP_GPS/AP_GPS.cpp):

  1. The system receives raw serial data from the MAVLink GPS_INJECT_DATA or GPS2_RTK packets.
  2. It checks the _inject_to parameter.
  3. If set to 127 (GPS_RTK_INJECT_TO_ALL), it iterates through every detected GPS backend and calls inject_data().
  4. If set to a specific index ($0$ or $1$), it sends the data only to that specific backend.
  5. This ensures that if you have two different GPS models (e.g., a u-blox and a Septentrio) that require different correction formats, you can target the corrections appropriately (though most users simply broadcast to all).

Tuning & Behavior

  • Default Value: 127 (All).
  • Recommended: Leave at 127 unless you have a specific dual-GPS setup where the sensors are of different types and sharing corrections causes errors.
  • RTK Fix: If your GCS shows "RTK Fixed" or "RTK Float" but only on one GPS, check this parameter to ensure it is set to include the second GPS instance if needed.