Adapted from EKF2 implementation as of commits
3835d2613, e9ed3540f and df4fc0fff
this sets a limit on the difference between the earth field from the
WMM tables and the learned earth field inside the EKF. Setting it to
zero disables the feature. A positive value sets the limit in mGauss.
GPS modules tend to be rather optimistic about their yaw accuracy. By
setting a min or 5 degrees we prevent the user constantly getting
warnings about yaw innovations
this moves intermediate variables from being per-core to being common
between cores. This saves memory on systems with more than one core by
avoiding allocating this memory on every core.
This is an alternative to #11717 which moves memory onto the stack. It
doesn't save as much memory as #11717, but avoids creating large stack
frames
when on the ground without a position source we would disable the
innovation gate for the barometer. This meant that a single (or small
number of) really bad baro readings would be fused into the EKF,
causing it to destabilise
Fixes#11903
this prevents the EKF origin on different cores from being initialised
to different values. A common value is stored in the frontend and used
by a core if it doesn't have an origin
this forces the EKF origin to the GPS alt on a height datum reset if
we have GPS lock. If we don't do this then the reported AMSL alt will
drift over time away from the GPS alt when we reset while on the
ground
this ensures we consistently fly with EKF lane1 if it is healthy at
the point we arm. Otherwise the choice of lane will be a lottery.
This is important as many systems have quite different filtering and
vibration characteristics on their different IMUs. We by default
enable fast sampling only on the first IMU for example, which means
the 2nd and 3rd IMUs are more vulnerable to high freq causing
aliasing.
this fixes an issue in selecting the best lane to change to when we
have 3 or more EKF cores. The bug is that if the current lane is
unhealthy it would always choose the last healthy lane instead of
choosing the lane with the lowest score
when we had 3 compasses the lack of the 'break' meant when we switched
compass in flight we would always switch back instantly to the one
that we had just rejected.
This avoids creating two pointers of different types to the same memory.
Having two pointers to the same memory can lead to the compiler
optimising code such that a write to one pointer is rearranged to be
either before or after a read from the other pointer depending on
which is deemed faster - not a good outcome.
See discussion here:
https://github.com/ArduPilot/ardupilot/issues/7331
we were getting some uninitialised variables. While it only showed up in
AP_SbusOut, it means we can't be sure it won't happen on other objects,
so safest to remove the approach
Thanks to assistance from Lucas, Peter and Francisco
Previous default was to apply in-flight height origin changes to local position instead of to reported origin height. This caused problems with copters that took off before getting GPS lock.
This change means that provided the GPS_DELAY_MS parameters are set for each GPS receiver attached, the EKF will not have to wait for the configuration of each receiver to be determined before it can start.
This significantly reduces start-up times when the delay parameters are set.
If variance falls below desired minimum, set state noise to a larger value.
If variance drops below safe value, set to desired minimum and reset off-diagonals to zero.
To eliminate the possibility of editing errors, revert the covariance prediction auto-code to the original auto-code without the replacement fo the /2 and /4 operations. The compiler optimisations are able to correctly handle the /2 and /4 operations.
Also use local variables for intermediate covariance calculations. The use of class variables for these small arrays was unnecessary.
This patch ensures that covariance matrix entries for inactive states are always set to zero.
It also halves the number of copy operations from the updated to stored matrix.
All Kalman gain calculations now explicity set gains for deactivated states to zero.
Previous use of loops to set gains to zero have been replaced with more efficient memset operations.
Inhibiting gyro bias estimation during the initial tilt alignment speeds alignment.
The calculation of the maxmum state index required has been modified so that it can handle all combinations of inhibited states.
Limiting the maximum state index accessed by all EKF operations result in significant processing reductions when higher index states are not being used.
Fix rounding error bug preventing state from updating after initial convergence.
Decouple GPS reference height from published EKf origin height.
Add bitmask parameter to control update and publishing of GPS reference height.
this changes the stragegy for load levelling between EKF cores so it
works between EK2 and EK3, and with future estimators as well.
It allows us to run EK3 and EK2 at the same time with good scheduling
performance
If the GPS receiver selection changes and we are using GPS for height, the vertical position will be reset to the new GPS height measurement.
correct output observer history when doing a GPS height reset
Do not time out and provide an escalating series of messages. We may need to adjust the time thresholds used for escalation.
Do not wait if the EKF is not using the GPS.
Copter operation without a magnetometer is limited to constant position and relative position modes only (no GPS or range beacon fusion permitted)
Copter optical flow operation without a magnetometer is permitted.
The ability of planes to takeoff/launch without a magnetometer and align the yaw using the GPS velocity is retained.
Prevent bad values for GPS time delay pushing the GPS time stamp outside the range of IMU data contained in the buffer. If this occurs it can prevent the GPS measurements from being fused and cause loss of navigation.
Use the time delay returned by the GPS driver.
Wait long enough for the GPS configuration to be determined, but time out after 30 seconds and warn the user that a default value for time delay will be used.
Switch to use of an airspeed reading averaged across the raw sensor readings. since the last update.
This avoids use of the IIR which requires a larger time delay compensation and violates the assumption of uncorrelated noise.
The time delay parameter has been reduced to compensate for the removal of the airspeed IIR filtering.
This value is a compromise between what works best for a Ublox 6 which is around 200msec delay and the more recent 7 and 8 series receivers that are around 120msec delay.
Adapt the lengths of the IMU and observations buffers on startup to the specified time delays and update rates.
This does require the EKF to be re-started if time delays are changed.
Enables the horizontal speed at which we switch from range finder to alternate to be adjusted.
Does not switch from range finder to alternate based on speed when speed estimate is invalid.
AP_NavEKF3: Implement same maths as PX4/ecl EKF
Replace attitude vector states with quaternions
Remove gyro scale factor states
Add XY accel delta velocity bias estimation
Initial tuning
Add GPS body frame offset compensation
AP_NavEKF3: Fix bugs and consolidate aiding switch logic
Switching in and out of aiding modes was being performed in more than one place and was using two variables.
The reversion out of GPS mode due to prolonged loss of GPS was not working.
This consolidates the logic and ensures that PV_AidingMode is only changed by the setAidingMode function.
AP_NavEKF3: prevent multiple fusion mode changes per filter update
AP_NavEKF3: Update tuning defaults
AP_NavEKF3: Fix bug causing switching in and out of aiding
If the GPS receiver was disconnected and no data received, then then the gpsGoodToAlign check did not get a chance to run and becasue it was previously true the EKF would switch back into aiding.
This prevents this by ensuring that gpsGoodToAlign defaults to false when the check is not being performed.
An additional check has also been dded to ensure that there is GPS data to fuse before we declare ready to use GPS.
AP_NavEKF3: Fix bug preventing planes recovering from bad magnetometers
This bug created a race condition whereby if the EKF had to reset the yaw to the GPS ground course to recover from a bad magnetometer, the new heading could be over-written by the bad magnetic heading when the plane reached the height for the scheduled reset.
AP_NavEKF3: Improve switch-over to backup magnetometer
When switching over to a back up magnetometer, ensure that the earth field estimate are reset. Otherwise mag earth field estimates due to the previous failed mag could cause data from the new mag to be rejected.
AP_NavEKF3: enable automatic use of range finder height
AP_NavEKF3: Fix bug in handling of invalid range data
AP_NavEKF3: Fix height drift on ground using range finder without GPSAP_NavEKF3:
AP_NavEKF3: Handle yaw jumps due to core switches
AP_NavEKF3: Enable simultaneous GPS and optical flow use
AP_NavEKF3: fix console status reporting
AP_NavEKF3: send messages to mavlink instead of console
This allows the GCS to better handle the display of messages to the user.
AP_NavEKF3: replace deprecated function call
AP_NavEKF3: Compensate for sensor body frame offsets
AP_NavEKF3: Fix bug in median filter code
AP_NavEKF3: save some memory in the position offsets in EKF3
We don't need to copy that vector3f for every sample. A uint8_t does the job
AP_NavEKF3: Add fusion of range beacon data
AP_NavEKF3: Bring up to date with EKF2
AP_NavEKF3: Misc range beacon updates
AP_NavEKF3: Add mising accessors
AP_NavEKF3: remove duplicate include
AP_NavEKF3: Prevent NaN's when accessing range beacon debug data
AP_NavEKF3: Update range beacon naming
AP_NavEKF3: updates
AP_NavEKF3: miscellaneous changes
AP_NavEKF3: misc updates
AP_NavEKF3: misc range beacons updates
AP_NavEKF3: add missing rover default param