A drone in Position mode (PX4) or Loiter (ArduPilot) should stay put. When it wanders off, circles or rocks around the point, teams usually reach for the controller gains. The cause more often sits in the estimator's input data or in the mechanics, and the flight log shows it if you know which fields to open.
Before you change any parameter, separate two cases:
- The estimator is wrong. The EKF thinks the drone is stationary while it moves: the EKF position matches the setpoint, but not reality (video, raw GNSS).
- The controller can't keep up. The EKF sees the drone has left the point, but the position loop can't hold it.
Compare the setpoint with the estimate to tell them apart: in PX4 the vehicle_local_position_setpoint and vehicle_local_position topics, in ArduPilot the PSCN and PSCE messages (fields TPN and PN). Causes 6 and 7 are about control, the rest mostly about estimation.
Names below are for PX4 v1.16 and ArduPilot Copter 4.6. On the PX4 development branch some GNSS parameters are renamed (e.g. GNSS_REQ_EPH instead of EKF2_REQ_EPH), and ArduPilot 4.6 renamed GPS_POS1_X to GPS1_POS_X.
1. GNSS quality and multipath
Symptom: a slow, irregular wander, clearly worse near buildings, trees and steel structures; jumps when the set of tracked satellites changes.
In the logs:
- PX4:
vehicle_gps_position:satellites_used,eph,s_variance_m_s,jamming_indicator, plusestimator_status.gps_check_fail_flags. The Flight Review guide gives as a reference around 12 satellites or more, horizontal accuracy below 1 m and a jamming indicator around or below 40. - ArduPilot:
GPS.NSats,GPS.HDop,GPA.HAcc,GPA.SAccand the innovationsXKF3.IPN/IPE. The Copter documentation calls HDop below 1.5 very good and above 2.0 a warning sign.
Fix: an antenna with a clear view of the sky, separated from onboard interference sources. Treat the EKF2_REQ_* and EK3_GPS_CHECK thresholds as a pre-flight quality gate, not an obstacle to work around.
2. Wrong GNSS antenna offset or delay
Symptom: yawing in place, the drone traces a small circle; starting and stopping, it overshoots. An antenna away from the IMU moves on a circle during yaw, and an EKF that doesn't know its position reads that as vehicle motion. A wrong delay compares GNSS with the state from another moment, so the error grows with every velocity change.
In the logs: GNSS innovations during yaw and acceleration: estimator_innovations.gps_hvel and gps_hpos (PX4), XKF3.IVN/IVE and IPN/IPE (ArduPilot). A pattern tied to rotation or acceleration, rather than to the place you fly, points to geometry or timing.
Fix: measure the offsets in metres in the body frame: EKF2_GPS_POS_X/Y/Z and EKF2_IMU_POS_X/Y/Z, or GPS1_POS_X/Y/Z and INS_POS1_X/Y/Z. Set the delay (EKF2_GPS_DELAY, GPS1_DELAY_MS) from the receiver documentation. ArduPilot notes that with all sensors within 15 cm of each other the offsets are unlikely to make a noticeable difference.
3. Compass interference and calibration
Symptom: circling in a spiral ("toilet bowling"); the drift direction changes after the drone yaws. A heading error rotates the velocity correction, so the controller pushes the wrong way.
In the logs:
- PX4: the norm of
vehicle_magnetometer.magnetometer_gaagainst thrust andbattery_status.current_a; Flight Review says it should be constant and uncorrelated with thrust. Addestimator_innovation_test_ratios.mag_field. - ArduPilot: the length of
MAG.MagX/MagY/MagZagainstCTUN.ThOorBAT.Curr,XKF3.IMX/IMY/IMZ,XKF4.SMand "ground mag anomaly, yaw re-aligned" messages. For compassmot the documentation gives: below 30% interference acceptable, 30-60% grey zone, above 60% unacceptable.
Fix: move the compass away from power wiring (an external module on a mast) and calibrate in the final configuration. Current compensation: CAL_MAG_COMP_TYP with CAL_MAGx_XCOMP/YCOMP/ZCOMP in PX4, compassmot (COMPASS_MOTCT) or MagFit in ArduPilot; it makes sense when the cables are fixed in place.
4. Vibration and aliasing
Symptom: altitude creeps up or down, the position "slides", and in severe cases the drone climbs suddenly. Vibration corrupts the accelerometer-based estimates, vertical and horizontal.
In the logs:
- PX4:
vehicle_imu_status.accel_vibration_metricandaccel_clipping, and the Vibration and Acceleration Power Spectral Density plots in Flight Review. The guide's rule of thumb: if the Z trace touches the X and Y traces in hover, vibration is too high. Height divergence shows ashgt_test_ratioabove 1. - ArduPilot:
VIBE.VibeX/VibeY/VibeZandVIBE.Clip. Per the documentation, below 30 m/s/s is normally acceptable and above 60 m/s/s nearly always causes position or altitude hold problems. Clipping should be 0; a count that keeps rising through the flight is a serious problem.
Fix: mechanics before filters: balanced propellers, a stiff frame, autopilot isolation, a secured GPS mast. A software filter can't remove aliasing, because the folded signal already sits in the useful band (see the article on IMU drift). PX4 allows raising EKF2_ACC_NOISE as a workaround, at the cost of more sensitivity to GNSS errors.
5. EKF tuning: noise, gates and sensor timing
Symptom: the position jitters with GNSS noise, or lags and then jumps. Noise set too low makes the filter trust GNSS too much; gates set too tight reject measurements until the position resets. Switching EKF instances that have drifted apart also causes a jump.
In the logs:
- PX4:
estimator_innovation_test_ratios,estimator_status.pos_test_ratioandvel_test_ratio: per the EKF2 documentation below 0.5 in normal flight with occasional spikes, and above 1 the measurement is rejected. Addreset_count_pos_ne,estimator_selector_status.instance_changed_countandtime_slip, which should stay at zero. - ArduPilot:
XKF4.SV/SP/SH/SM(below 1 accepted, above 1 rejected),XKF4.OFN/OFE(most recent position reset),XKF4.PI(primary core) and the "EKF3 lane switch" message.
Fix: change noise and gates (EKF2_GPS_P_NOISE, EKF2_GPS_P_GATE, EK3_POSNE_M_NSE, EK3_POS_I_GATE) after causes 1-4 are ruled out, one parameter at a time. Both stacks can replay the estimator from a log recorded with the "Estimator replay" bit in SDLOG_PROFILE or with LOG_REPLAY and LOG_DISARMED, so you can check a change without flying.
6. Wind and aerodynamic drag
Symptom: in gusts the drone drifts downwind and returns slowly, whatever its heading. EKF innovations are small: the estimator knows where the drone is, but the controller runs out of margin.
In the logs:
- PX4: tracking error of
vehicle_local_positionagainstvehicle_local_position_setpoint, commanded tilt againstMPC_TILTMAX_AIR, motor outputs (Flight Review: a signal held at maximum means saturation). A wind estimate (wind) on a multicopter needs drag fusion:EKF2_DRAG_CTRL,EKF2_BCOEF_X/Y,EKF2_MCOEF. - ArduPilot:
PSCN/PSCE:TVNagainstVN;ATT.DesRollagainstATT.Roll; saturation inRCOU; wind inXKF2.VWN/VWEonceEK3_DRAG_BCOEF_X/YandEK3_DRAG_MCOEFare set.
Fix: check the thrust margin and the tilt limit (MPC_TILTMAX_AIR, ANGLE_MAX), then the integral term of the velocity loop. A wind estimate helps with barometer compensation and with navigation without GNSS.
7. Position and velocity controller gains
Symptom: regular rocking around the point (gains too high) or a lazy return with overshoot (too low). The estimate is good, the tracking error is large.
In the logs: vehicle_local_position against vehicle_local_position_setpoint (Flight Review, PID Tracking Performance: the estimate should closely match the setpoint) and PSCN/PSCE: TPN/PN, TVN/VN, TAN/AN.
Fix: the position loop sits on the velocity loop, which sits on the attitude loop. Before you touch MPC_XY_P, MPC_XY_VEL_P_ACC, MPC_XY_VEL_I_ACC or PSC_POSXY_P, PSC_VELXY_P, PSC_VELXY_I, check that attitude tracks its setpoint (vehicle_attitude_setpoint, ATT.DesRoll). Change in small steps and fly the same pattern every time.
8. Barometer and prop wash
Symptom: altitude drifts when accelerating and braking and depends on flight direction; on landing the drone "bounces" up just above the ground. Static pressure at the airframe depends on airflow, and near the ground prop wash changes the reading (ground effect).
In the logs: vehicle_air_data.baro_alt_meter against GNSS altitude, estimator_innovations.baro_vpos and hgt_test_ratio (PX4); BARO.Alt against GPS.Alt, XKF3.IPD, XKF4.SH (ArduPilot).
Fix: shield the barometer from direct airflow, then derive compensation coefficients from a flight in several directions: EKF2_PCOEF_XP/XN/YP/YN/Z in PX4, BARO1_WCF_* in ArduPilot (needs the wind estimate). For ground effect: EKF2_GND_EFF_DZ (PX4 documentation: the dip read from the log plus a 10% margin) and GND_EFFECT_COMP in ArduPilot.
9. Sensor mounting and orientation
Symptom: with sticks centred the drone pulls one way and holds position with a constant tilt; entering position mode, it moves in a rotated direction; compasses disagree on heading.
In the logs: tilt in hover with a zero command (vehicle_attitude, ATT.Roll/Pitch), a comparison of sensor_mag instances, the "Compasses inconsistent" pre-arm message in ArduPilot. The EKF2 documentation says to check that the heading in QGroundControl is within 15° of the true heading.
Fix: check orientation physically (tilt and rotate the vehicle while watching the horizon in the GCS), run the level calibration on a levelled vehicle and set the orientation of every external compass: SENS_BOARD_ROT, CAL_MAG0_ROT in PX4; AHRS_ORIENTATION, COMPASS_ORIENT in ArduPilot.
10. Optical flow and rangefinder (if you use them)
Symptom: without GNSS, drift over a uniform, shiny or dark surface, rocking with a wrong flow scale, height jumps over obstacles and vegetation.
In the logs:
- PX4:
vehicle_optical_flow.quality,distance_sensor.current_distance,estimator_innovation_test_ratios.flowandhagl. Per the EKF2 documentation, flow needs valid rangefinder data and quality above a threshold, and the rangefinder can be rejected over obstacles and slopes. - ArduPilot:
OF.Qual,OF.flowXagainstOF.bodyX,RFND.Dist,XKF5.FIX/FIY,XKF5.HAGL.OF.bodyXuncorrelated withIMU.GyrXpoints to a wrongFLOW_ORIENT_YAW.
Fix: scale calibration (ArduPilot: rock the vehicle in both axes and adjust FLOW_FXSCALER/FYSCALER until flowX matches bodyX), mounting offsets (EKF2_OF_POS_X/Y/Z, FLOW_POS_X/Y/Z, RNGFND1_POS_X/Y/Z), orientation (SENS_FLOW_ROT), and the texture and lighting of the ground.
How I approach it: logs before parameters
In an audit I start with one planned flight and a fixed order for reading the log, not with parameters:
- A position-hold flight: a few minutes of hover, a 360° yaw in place, starts and stops on each axis; logging set up for replay.
- Vibration and clipping. If they are bad, the rest of the analysis can't be trusted.
- GNSS: satellites, accuracy, interference.
- EKF test ratios and resets: which sensor is rejected, and when.
- The magnetic field norm against thrust and current.
- Setpoint, estimated and raw GNSS position: estimation or control?
- One change at a time, the same flight pattern, logs compared before and after.
This review of logs, parameters and mounting is a typical Technical Audit scope (2-5 days): a platform assessment, a risk list and a remediation plan the team carries out itself or in a Rescue Sprint. If your drone drifts and it's unclear where to start, get in touch and attach a flight log.
Sources
- PX4: Using PX4's Navigation Filter (EKF2), Log Analysis using Flight Review, Compass Power Compensation, Vibration Isolation, System-wide Replay
- ArduPilot (EKF3): Extended Kalman Filter (EKF), EKF3 Affinity and Lane Switching, Onboard Message Log Messages, Testing with Replay
- ArduPilot (sensors): Diagnosing some common problems using Logs, Magnetic Interference, Measuring Vibration, Managing Gyro Noise with the Dynamic Harmonic Notch Filters, Advanced Compass Setup, Sensor Position Offset Compensation, Windspeed Estimation and Baro Compensation, Optical Flow Sensor Testing and Setup