In the previous article, we explained the structure and operating principles of ArduPilot's EKF3. In this article, which is FC14, we will cover the practice of EKF tuning. After understanding the theory, we will explain the specific procedures for diagnosing problems from actual logs and adjusting parameters.
Prerequisites for tuning—What is the goal?
The goal of EKF tuning is to ensure that the EKF's estimated values are close to the true values and that the assessment of uncertainty is accurate. It is important not only to have accurate estimates but also to ensure that the EKF accurately understands its own uncertainty.
An overconfident EKF has a smaller P than reality, making it slower to react to new observations. It is prone to overlooking sensor anomalies and cannot correct erroneous state estimates.
An underconfident EKF has a larger P than reality, making it over-reactive to observations and susceptible to noise.
The indicator for appropriate tuning is innovation statistics. The innovation y=z-Hx̂ should follow a normal distribution N(0,S), where S=HPHᵀ+R is the covariance. Ideally, the mean of the Normalized Innovation Squared (NIS) should match the number of observation dimensions.
Log messages used for tuning
We will organize the key messages to refer to in ArduPilot logs.
NKF1 is the main state log for EKF3, recording position (PN, PE, PD), velocity (VN, VE, VD), and attitude (Roll, Pitch, Yaw).
NKF2 is the sensor bias log for EKF3, recording gyro bias (GX, GY, GZ), accelerometer bias (AX, AY, AZ), and magnetic field (MX, MY, MZ). Check if the bias changes significantly during flight.
NKF4 is the innovation statistics for EKF3 and is the most important debugging information. It records SV (velocity innovation), SP (position innovation), SH (altitude innovation), and SM (magnetic innovation).
NKF5 is the innovation statistics for optical flow and terrain altitude.
XKF1 to XKF5 contain similar data for multiple EKF instances and are used to diagnose instance switching.
VIBE (vibration) records statistics of IMU vibration (VibeX, VibeY, VibeZ). This is an essential pre-processing step to confirm that vibration is within the acceptable range before EKF tuning.
Step 1—Checking vibration
Before EKF tuning, always check if the IMU vibration is within the acceptable range. Adjusting EKF parameters while vibration is high will have no effect.
Confirm that the RMS values of VIBE.VibeXYZ are 30m/s² or less (15m/s² or less is recommended). If they exceed this, perform the mechanical vibration isolation and notch filter settings explained in FC7 first.
To check VIBE, use 'Review a log' in Mission Planner to graph VIBE.VibeX, VIBE.VibeY, and VIBE.VibeZ. If they spike during high throttle, it is a problem with propeller balance or motor mounts.
Step 2—Evaluating innovation
We will explain how to interpret the innovation values in NKF4.
The velocity innovation NKF4.SV is the difference between the GPS velocity predicted by the EKF and the actual GPS velocity. The unit is m/s, and the normal value during flight is typically 0.2 m/s or less. If it consistently exceeds 0.5 m/s, there is a GPS quality issue or a need to adjust EK3_VEL_I_GATE.
The position innovation NKF4.SP is the difference between the GPS position predicted by the EKF and the actual GPS position. The unit is meters, and the normal value is typically 1 m or less. Sudden jumps indicate GPS glitches, while consistently large values indicate GPS quality issues or INS drift.
The altitude innovation NKF4.SH is the difference between the barometer's predicted altitude and the measured altitude. It is normal for this to increase during takeoff and landing (due to pressure changes from ground effect), but if it remains consistently large during cruise, there is a foam shielding issue or a need to adjust EK3_BARO_I_GATE.
The magnetic innovation NKF4.SM is the compass innovation, with a normal value of 0.05 Gauss or less. If it fluctuates significantly when the motors start, the CompassMot compensation is insufficient; if it is large at specific headings, the hard-iron calibration needs to be reviewed.
Innovation spikes are typical signatures of GPS glitches, radio interference, or electromagnetic noise. Single spikes are automatically rejected by the innovation gate and are not a problem, but continuous spikes indicate a design issue.
Step 3—Checking Bias Drift
Check the changes in the bias estimates of NKF2.
Gyro bias (NKF2.GX, GY, GZ) normally converges gradually from the initial calibration after power-on and stabilizes 5 to 10 minutes after flight begins. The unit is rad/s, and if the value after stabilization exceeds 0.01 rad/s (approx. 0.57 deg/s), there is an IMU temperature management issue.
Sudden changes in bias during flight indicate shocks to the IMU, rapid temperature changes, or power noise. Compare the attitude logs of NKF1 to see if the EKF attitude estimation is disturbed after a sudden bias change.
The normal value for accelerometer bias (NKF2.AX, AY, AZ) is 0.1 m/s² or less. A large bias indicates that the 6-point accelerometer calibration is incomplete.
Step 4—Adjusting Key Parameters
This section explains the core EKF3 parameters and adjustment strategies for tuning.
EK3_GYRO_P_NSE is the process noise for gyro bias. The default value is 1.5e-2 rad/s. Increasing this value allows for faster tracking of gyro bias changes but increases sensitivity to noise. If NKF2.GXYZ fluctuates significantly during flight, increase the value; if it is noisy, decrease it.
EK3_ACC_P_NSE is the process noise for accelerometer bias. The default value is 6.0e-3 m/s². Increase this in environments with large IMU temperature fluctuations.
EK3_POSNE_P_NSE is the process noise for horizontal position. The default value is 0.1 m. Increase this in environments where the aircraft is susceptible to wind disturbances to improve GPS tracking.
EK3_ALT_M_NSE is the process noise for vertical position. The default value is 0.5 m. Increase this in environments with large barometer disturbances (building wind, indoor airflow).
EK3_MAG_P_NSE is the process noise for geomagnetism. The default value is 2.5e-2 Gauss. Increase this in environments where the compass fluctuates due to ESC or battery influence.
GPS observation noise does not usually require manual adjustment because ArduPilot automatically sets R based on u-blox's hAcc and sAcc. However, EK3_GLCH_RAD (GPS glitch detection radius) should be set small (1–2 m) in urban environments with high multipath, and large (0.1 m) when using RTK.
Step 5—Tuning in GPS-Denied Environments
EKF tuning in GPS-denied environments (indoors, using VIO) requires additional caution.
When inputting VIO horizontal position into the EKF with EK3_SRC1_POSXY=6 (ExternalNav), adjust EK3_POSNE_P_NSE to match the drift characteristics of the VIO. Increase it if the VIO position noise is greater than that of the GPS, and decrease it if the VIO is of RTK quality.
VIO innovation monitoring can be checked using NKF4.SP, the same as for GPS. If VIO innovation is consistently high, suspect issues with the VIO coordinate frame transformation (ENU to NED) or timestamp correction.
To verify EKF operation during GPS denial, check NKF4 in the logs and evaluate whether the EKF diverges without GPS updates. If the EKF position estimation does not change abruptly in NKF1.PN or PE, the IMU bias is being estimated accurately and drift is being suppressed.
Step 6—Coordination between Notch Filters and EKF
IMU vibration filters (INS_HNTCH) and EKF parameters must be adjusted in conjunction with each other.
Notch filters increase phase delay in the control loop. Since this delay affects EKF prediction accuracy, re-check EKF logs after changing filter settings.
The cutoff frequencies for INS_GYRO_FILTER and INS_ACCEL_FILTER affect the quality of IMU data for the EKF. Lowering the cutoff too much increases signal delay and reduces EKF tracking performance. If changing significantly from the default (20Hz), verify the impact using NKF4 innovations.
EK3_DELVEL_NOISE is the noise setting for the accelerometer's delta velocity (integrated acceleration). It may need to be adjusted in conjunction with changes to INS_ACCEL_FILTER settings.
Practical Tuning Workflow
The actual workflow for EKF tuning is organized as follows.
For the first flight, fly with basic settings to obtain a baseline for VIBE and NKF4. Collect data in three stages: hovering, slow forward/backward movement, and high-speed movement.
If vibration exceeds acceptable levels, adjust mechanical vibration isolation and notch filters according to the procedures in FC7, then return to the first flight.
For sensors where NKF4 innovation consistently exceeds the threshold, increase the process noise by a factor of 10 and fly again. If there is no improvement, suspect a hardware issue.
If bias drift (NKF2) is significant, improve IMU temperature management. Enable ArduPilot's temperature calibration function (INS_TCAL_ENABLE) to estimate temperature correction coefficients.
Final verification is a statistical evaluation of NKF4 over multiple flights. Tuning is complete if the standard deviation of the innovation is within about 1x the innovation covariance √S (NIS ≈ number of observation dimensions).
EKF Tuning Automation Tools
Auxiliary tools for manual tuning are introduced below.
ArduPilot Methodic is a web-based tool that guides you through parameter tuning procedures, including EKF parameter tuning steps.It can be accessed at https://ardupilot.github.io/MethodicConfigurator.
MAVExplorer is ArduPilot's official log analysis tool, capable of statistical analysis and visualization of EKF innovations. pyFlightAnalysis is a Python-based analysis tool that allows for FFT analysis and overlaying EKF logs.
EKF tuning in SITL (Software In The Loop) will be covered in detail in FC20, but you can check the impact of EKF parameters in a simulation environment before flying the actual aircraft. Inject GPS noise, compass interference, and IMU noise into the simulation environment to evaluate EKF behavior.
Common Problems and Solutions
We will organize the problems frequently encountered during EKF tuning.
PreArm: EKF not started indicates that EKF initialization is incomplete. Causes include failure to obtain a GPS fix, incomplete compass calibration, or EKF3 being disabled. Wait for at least one minute outdoors with a clear view of GNSS satellites before rechecking.
Frequent EKF Lane changes indicate sensor quality issues. Check the innovations for each parameter in NKF4; if the innovation for a specific sensor is large, review the installation and calibration of that sensor.
Yaw estimation degradation is often caused by compass interference. If CompassMot compensation exceeds 50%, physical relocation of the compass is necessary. Switching to GPS Yaw (using two GNSS antennas) is a fundamental solution.
Rapid increase in position error after GPS denial indicates incomplete estimation of IMU bias. Extend the GPS usage time to wait for bias convergence, or consider switching to a higher-precision IMU (tactical grade).
Summary
EKF tuning is performed systematically through the steps of VIBE verification, NKF4 innovation evaluation, NKF2 bias confirmation, and process noise adjustment. Innovation statistics (NKF4) are the primary indicators for tuning; consistently large innovations indicate a need for process noise adjustment or hardware issues. Vibration filters and EKF parameters should be adjusted in tandem, and completion should be confirmed through statistical evaluation, ultimately aiming for NIS ≈ number of observation dimensions. In the next session, FC15, we will explain GPS and INS integration—optimizing u-blox settings and the practice of GPS-INS integration in ArduPilot.
