This is a heads up to the community about ongoing development that is aimed at improving navigation accuracy and robustness
Development of the estimation software has been a long and difficult process due to the wide range of use cases and sensor quality/user setups. What has been developed, starting with AP_NavEKF and then moving on to AP_NavEKF2 is a general purpose estimator. This inevitably means compromises have had to be made, which means that performance for some applications will be inferior to special purpose algorithms. The use cases that have driven development have been full inertial navigation with Barometer, GPS, and magnetometer with the ability to incorporate additional sensors such as range finders, optical flow and airspeed. Operation without GPS or optical flow to provide only an attitude and height estimate has never been a priority for development, and has only been developed to the extent required to provide a reversion mode.
When we moved from the AP_NavEKF to the AP_NavEKF2 library, a number of changes to the underlying algorithms were made in an effort to improve robustness to bas sensor data, particularly the IMU which is much harder to recover from compared to other errors. An effort was also made to enable alignment when the vehicle was on a moving platform or being carried as a slung load which can generate large amplitude angular and translational movement.
- Dual EKF instances with each instance using a different IMU.
- Use of data buffers and delayed EKF time horizon to compensate for different sensor delays. The EKF runs 250 msec behind current time. This means that when measurements are fused, the measurements, EKF states and covariances all have consistent time stamps. The old EKF used the states from the measurement time (delayed) and the covariance matrix from the current time which made the calculation less accurate and stable for some measurements.
- Use of an output predictor to predict the EKF states forward from the fusion time horizon to the current time. This also filters out the small steps in position, velocity and attitude that occur when measurements, eg GPS, are fused.
- Attitude (angular orientation) in the filter states was represented as a 3D vector representing the growth in error since the last update, instead of using the quaternion states form the INS directly. This had the benefit that the EKF could self align from any orientation regardless of motion. This was also great for recovering from very bad in-flight data. Unfortunately it came at a cost in that if the yaw rate is high enough, the roll and pitch estimate suffers from temporary loss of accuracy.
- Estimation of gyro scale factors was added to try and improve accuracy during high angular rate manoeuvres. In practice this was of limited benefit, the problem being that the scale factor is slow to learn and appeared to vary with temperature.
After some early problems with tuning AP_NavEKF2 is now providing a robust solution for a wide range of platforms, but for enterprise use with good quality setups, and with the increased availability of higher precision position solutions, eg RTK GPS, I started investigating an alternative mathematical formulation which provided increased accuracy, but at the expense of being able to bootstrap with arbitrary movement. However the revised formulation is still capable of aligning from boats, so boat mode has not been affected. The effect on some of the more extreme slung load startup scenarios has not been assessed.
This formulation, which is also implemented in the PX4/ecl library, has a number of key differences to the Ardupilot EKF2:
- Direct estimation of quaternions states instead of the attitude error to avoid the roll/pitch errors produced by yaw transients.
- Removal of the gyro scale factor state estimation.
- Addition of 3-axis accelerometer bias state estimation.
This has now been implemented in Ardupilot in a AP_NavEKF3 library and pushed to a branch that enables the three EKF estimators EKF (AP_NavEKF), EKF2 (AP_NavEKF2) and the new formulation EKF3 (AP_NavEKF3) to be compared by changing parameters and rebooting between tests. Here is the branch:
A downside is that adding the additional estimator option has pushed the code over the 1MB flash limit due to a hardware bug in the STM32 that affects the older pixhawks. That required modifying the PX4Firmware build configuration to bypass the 1MB limit applied during the build process. Note that if this is loaded onto a pixhawk with the older STM32 processor affected by the hardware bug, then the USB interface will not work for telemetry comms or log download, however the boot-loader will still work, so the usb can still be used to change the firmware.
I have tested the ekf3-wip branch in GPS and optical flow aiding using an IRIS+ quadcopter so it is now at a point where getting some feedback from other testers would be useful. If you want to try EKF3 for yourself, the following parameter changes are required.
1) Set AHRS_EKF_TYPE to the number corresponding to the estimator you wish to test, eg set AHRS_EKF_TYPE = 3
2) Disable the other estimators, eg set EKF_ENABLE = 0 and EK2_ENABLE = 0
3) Enable the estimator you wish to use, eg set EK3_ENABLE = 1
4) Reboot
The log data is in XKF1, ... , XKF9