Understanding EKF Primary Change in ArduPilot: Causes and Solutions
EKFArduPilotdrone engineeringtroubleshooting

Understanding EKF Primary Change in ArduPilot: Causes and Solutions

LogHat Engineering TeamJune 21, 20265 min read

Key Takeaway

EKF primary change in ArduPilot can be caused by sensor issues or configuration errors.

TL;DR: If you encounter an ERR Subsys=18 indicating an EKF primary change, check your FS_EKF_ACTION parameter; it must be set to 3 (Land) for proper failsafe operation. Note that there is no RTL option for EKF failsafe scenarios, and setting FS_EKF_ACTION to 1 (Warning only) will not trigger RTL, even if MODE Rsn=5 indicates an EKF failsafe.

What Does EKF Primary Change Mean in the Log?

EKF primary change is indicated by ERR Subsys=18, signaling a transition in the primary EKF instance when valid estimates for position or attitude can't be maintained.

In ArduPilot logs, an EKF primary change is represented by the error subsystem code ERR Subsys=18. The relevant log fields include:

ERR Subsys  ECode  TimeUS  Mode   Reason
18           1      123456  2      5
  • ERR Subsys: The subsystem reporting the error; 18 signifies an EKF primary change.
  • ECode: The specific error code; 1 generally indicates that the EKF has entered a failsafe state.
  • TimeUS: The timestamp of the log event.
  • Mode: The flight mode at the time of the error.
  • Reason: Indicates the reason for the mode change; 5 means an EKF failsafe was triggered.

How to Confirm EKF Primary Change in Mission Planner

Follow these steps in Mission Planner to confirm EKF primary changes effectively.

To verify EKF primary changes using Mission Planner, navigate through the following steps:

  1. Open the Mission Planner application.
  2. Go to the Flight Data tab.
  3. Select DataFlash Logs from the menu.
  4. Click on Review a Log to load your flight data.

Once the log is loaded, you can plot the following fields to identify EKF primary changes:

  • ERR Subsys - to see the error subsystem.
  • MODE - to check the flight mode.
  • GPS.HDOP - to monitor GPS quality.

How to Confirm EKF Primary Change in MAVExplorer

Use MAVExplorer commands to visualize EKF changes and diagnose issues effectively.

To visualize EKF changes in MAVExplorer, use the following command:

MAV> graph ERR.Subsys MODE.Rsn GPS.HDOP

This command allows you to correlate error subsystems with the mode and GPS quality, helping you diagnose the causes of EKF primary changes effectively.

What Are Common Causes of EKF Primary Change?

Identifying the root causes of EKF primary change can help prevent future issues.
  1. GPS Glitches: When GPS.Status indicates a GPS_GLITCH, the EKF may lose confidence in position data, leading to a primary change.
  2. Compass Interference: High interference levels can result in erroneous heading data, prompting the EKF to switch to a secondary instance.
  3. Vibration Issues: Excessive vibrations (above 60 m/s²) can degrade IMU readings, causing the EKF to reset. Ensure VIBE.VibeX/Y/Z values are below 15 m/s² for optimal performance.
  4. Sensor Failures: If any of the critical sensors (like barometer or accelerometer) report errors, the EKF may not be able to maintain a valid state.

How to Fix EKF Primary Change Issues

Effective fixes for EKF primary change can restore stable flight and improve overall performance.
  1. Set FS_EKF_ACTION = 3 to ensure an appropriate recovery action during an EKF failsafe.
  2. Inspect and recalibrate your GPS and compass sensors diligently to ensure valid readings.
  3. Check vibration levels using VIBE.VibeX/Y/Z to ensure they are below 15 m/s² for steady flight.
  4. Review the EK3_POS_I_GATE and other EKF parameters to ensure they are set to values that suit your specific drone configuration.
  5. Monitor GPS.HDOP values; ensure they stay below 1.4 for optimal performance, as higher values may affect EKF stability.

When This Isn't Actually an EKF Primary Change

Understanding false indications of EKF primary changes can save troubleshooting time.
  • Logs showing ERR Subsys=18 indicate a barometer issue, not an EKF primary change.
  • EKF primary changes may be misdiagnosed if GPS.Status is temporarily degraded without further issues.
  • Changes in flight mode due to pilot command will not trigger an EKF primary change.

When LogHat Helps — and When It Doesn't

LogHat provides analysis for EKF performance but cannot adjust hardware settings.

LogHat excels at analyzing flight logs for patterns and anomalies related to EKF performance. It provides insights into sensor behavior and the corresponding EKF instances. However, LogHat cannot directly adjust parameters or calibrate hardware; these tasks remain within the engineer's purview.

What is EKF in ArduPilot?

EKF stands for Extended Kalman Filter, a mathematical algorithm used in ArduPilot for estimating the position and attitude of the drone based on sensor data.

How can I troubleshoot EKF primary change errors?

To troubleshoot EKF primary change errors, check sensor configurations, perform calibrations, and assess the physical setup of your drone. Make sure that the FS_EKF_ACTION parameter is configured correctly to 3 (Land).

What are common causes of EKF errors?

Common causes of EKF errors include GPS glitches, compass interference, excessive vibrations, and sensor failures. Each of these can lead to a loss of confidence in the EKF's estimations.

How do I check vibration levels in ArduPilot?

Vibration levels can be checked by analyzing the VIBE log messages. Look for VIBE.VibeX/Y/Z values, targeting levels below 15 m/s² for optimal performance.

What should I do if my drone enters an EKF failsafe?

If your drone enters an EKF failsafe, first check the FS_EKF_ACTION parameter. Ensure it is set to 3 (Land), then inspect sensor data and recalibrate as necessary to regain stable flight.

For more detailed analysis and troubleshooting assistance, consider utilizing LogHat's capabilities to gain deeper insights into your flight logs. Our platform can help identify patterns that lead to EKF issues, ensuring smoother flights in the future.

About the author

LE

LogHat Engineering Team

The LogHat engineering team — drone-systems engineers who build and operate the LogHat flight analytics platform. Posts in this byline are written and reviewed by team members working on the parsers, analysis engine, and Vector AI that the post describes.

Tagged

EKFArduPilotdrone engineeringtroubleshooting

Try LogHat

Analyze your flight logs in seconds

Upload a .bin, .tlog, .log, or .ulg file. Get AI crash analysis, 3D replay, and forensic PDF reports instantly.

Try LogHat Free