During flight, when switching from GPS to Beacon (SRC1 ↔ SRC2), a position jump issue occurs on the drone.

Dear All,

In ArduPilot, I am switching the EKF source mode (SRC) while the drone is in motion. Initially, I arm and take off in Guided mode using GPS. When I later switch to Beacon-based positioning (tested with both Beacon SITL and Pozyx), sudden jumps occur in the drone’s actual position.

Solutions I’ve tried

  1. I tried to perfectly match the beacon origin parameters (BCN_LATITUDE, BCN_LONGITUDE, BCN_ALT) with the ArduPilot home/origin (SIM_OPOS_*) values, but I’m still experiencing discrepancies.
  2. I was switching from GPS to Pozyx (BCN_TYPE = 1). Thinking Pozyx might be faulty, I tried Beacon SITL (BCN_TYPE = 10). However, the jump is still happening.
  3. When I try to set the first SRC (SRC1) source as Beacon and the second SRC (SRC2) source as GPS, I get the error “AP Arm: GPS and AHRS differ by 12.3m” without the drone even being able to lift off.

I am performing the SRC source change with the following simple code.

from pymavlink import mavutil

# Connect (typical address for SITL)
master = mavutil.mavlink_connection("udp:127.0.0.1:14550")
master.wait_heartbeat()

print("Connected:", master.target_system, master.target_component)

def set_src(src):
    print(f"Switching to SRC {src}...")

    master.mav.command_long_send(
        master.target_system,
        master.target_component,
        42007,   # MAV_CMD_SET_EKF_SOURCE_SET
        0,
        src,     # param1 = source set (1,2,3)
        0, 0, 0, 0, 0, 0
    )

    ack = master.recv_match(type="COMMAND_ACK", blocking=True, timeout=3)

    if ack and ack.result == 0:
        print("OK")
    else:
        print("FAIL", ack.result if ack else "No ACK")

while True:
    s = input("Select SRC (1/2/3, q to quit): ").strip()
    if s == "q":
        break
    if s in ["1", "2", "3"]:
        set_src(int(s))

EKF Source Configuration

Parameter Value Description
EK3_SRC1_POSXY 3 GPS
EK3_SRC1_POSZ 1 Barometer
EK3_SRC1_VELXY 3 GPS
EK3_SRC1_VELZ 3 GPS
EK3_SRC1_YAW 1 Compass
EK3_SRC2_POSXY 4 Beacon
EK3_SRC2_POSZ 1 Barometer
EK3_SRC2_VELXY 0 None
EK3_SRC2_VELZ 0 None
EK3_SRC2_YAW 1 Compass
EK3_SRC3_POSXY 0 None
EK3_SRC3_POSZ 1 Barometer
EK3_SRC3_VELXY 0 None
EK3_SRC3_VELZ 0 None
EK3_SRC3_YAW 0 None
EK3_SRC_OPTIONS 8 UsePerCoreEKFSources

Beacon & Simulation Origin Parameters

Parameter Value
BCN_ALT 584.0
BCN_LATITUDE -35.36326217651367
BCN_LONGITUDE 149.1652374267578
BCN_ORIENT_YAW 0
BCN_TYPE 10
SIM_OPOS_ALT 584.0
SIM_OPOS_HDG 353.0
SIM_OPOS_LAT -35.36326217651367
SIM_OPOS_LNG 149.1652374267578

ArduPilot Version

Vehicle: Copter
Release: Copter-4.5.7
Commit: 2a3dc4b7bf2507120f7378a7b2fde73185e0c325