Setting GPS_TYPE = 14
Configuring ArduPilot for MAVLink Injection
To tell ArduPilot to "listen" for GPS data coming from a MAVLink message rather than a physical UART wire, you must configure the GPS driver backend.
1. The Primary Parameter
- Parameter: GPS_TYPE (or GPS1_TYPE on newer firmware).
- Value: 14 (MAVLink).
- Effect: This loads the
AP_GPS_MAVbackend driver. This driver subscribes to the internal message bus, waiting specifically forMAVLINK_MSG_ID_GPS_INPUT(#232).
2. The Transport Layer
Unlike a U-Blox module where you set SERIAL1_PROTOCOL = 5 (GPS), for Virtual GPS you set the port to MAVLink.
- Parameter: SERIAL0_PROTOCOL (USB) or SERIAL1_PROTOCOL (Telem 1).
- Value: 2 (MAVLink 2).
- Why: The
GPS_INPUTmessage is just a standard MAVLink packet. It travels over the same link as your telemetry, heartbeat, and RC overrides.
3. EKF Configuration
Ensure the Extended Kalman Filter is active and ready to fuse GPS data.
EKF3_ENABLE= 1- AHRS_EKF_TYPE = 3
EKF3 Source Selection (Copter 4.1+)
To specifically prioritize the Phone's GPS data for horizontal position but use LiDAR for altitude (highly recommended):
- EK3_SRC1_POSXY = 3 (GPS)
- EK3_SRC1_VELXY = 3 (GPS)
- EK3_SRC1_POSZ = 2 (RangeFinder) -- CRITICAL: Do not use GPS for indoor altitude.
- EK3_SRC1_VELZ = 0 (None) -- Let EKF derive vertical velocity from IMU/LiDAR.
Verification
Once connected:
- Open Mission Planner > Flight Data.
- Look at the GPS Status label.
- No Fix: The driver is loaded (
GPS_TYPE=14), but no data is arriving from the phone. - 3D Fix: The driver is receiving valid
GPS_INPUTpackets from the phone.
Multiple GPS Setup
You can use the phone as a secondary GPS.
- GPS1_TYPE = 1 (Auto) -> Physical U-Blox on the roof.
- GPS2_TYPE = 14 (MAVLink) -> Virtual GPS via USB.
- Result: ArduPilot will blend or switch between them based on GPS_AUTO_SWITCH logic.