Commit Graph

308 Commits

Author SHA1 Message Date
Andrew Tridgell 197d31e9cc AP_NavEKF3: fixed in-flight yaw reset 2020-04-24 09:43:23 +10:00
Randy Mackay 86d221708c AP_NavEKF3: more white space fixes 2020-04-24 09:43:23 +10:00
Randy Mackay c1ef894a30 AP_NavEKF3: getDataEKFGSF and getYawData pass by reference 2020-04-24 09:43:23 +10:00
Randy Mackay 8a8271c2c7 AP_NavEKF3: minor format fixes 2020-04-24 09:43:23 +10:00
Randy Mackay ed3d072318 AP_NavEKF3: rename GSF_RUN_MASK, GSF_USE_MASK, GSF_RST_MAX 2020-04-24 09:43:23 +10:00
Paul Riseborough 7ba39c844c AP_NavEKF3: Split GSF yaw estimator processing
Separate prediction and correction steps are required to provide an up to
2020-04-24 09:43:23 +10:00
Andrew Tridgell 216935c1f2 AP_NavEKF3: fixed loss of GPS fusion
we must not do a storedGPS.recall unless we will be using the data,
otherwise we will lose GPS samples and risk stopping GPS fusion
2020-04-24 09:43:23 +10:00
Paul Riseborough 9f5e037015 AP_NavEKF3: Restore bug fix lost during rebase 2020-04-24 09:43:23 +10:00
Paul Riseborough 53df8a0238 AP_NavEKF3: Fix timer wrapping bug 2020-04-24 09:43:23 +10:00
Paul Riseborough 12d639fc17 AP_NavEKF3: Misc changes arising from review
AP_NavEKF3: Fix typo in comment

AP_NavEKF3: Use uint32_t data type for msec timers

AP_NavEKF3: Misc msec timer fixes

Fix wrapping bug.
Use common timestamp.

AP_NavEKF3: Format fixes - remove tabs

AP_NavEKF3: Fix typing and wrap issue on time comparison
2020-04-24 09:43:23 +10:00
Paul Riseborough 4b3952bd15 AP_NavEKF3: Eliminate unnecessary function call 2020-04-24 09:43:23 +10:00
Paul Riseborough 6ec69e6ed1 AP_NavEKF3: Update EK3_MAG_CAL parameter advice 2020-04-24 09:43:23 +10:00
Paul Riseborough 863f989130 AP_NavEKF3: Fix integration of GPS yaw options
AP_NavEKF3: fix failure to arm with EK3_MAG_CAL = 7

AP_NavEKF3: Fix failure to arm when not using magnetometer

AP_NavEKF3: Reduce yaw drift when EK3_MAG_CAL = 7
2020-04-24 09:43:22 +10:00
Paul Riseborough 410b5825fb AP_NavEKF3: Enable use of EKF-GSF yaw estimate
AP_NavEKF3: Add emergency yaw reset using a Gussian Sum Filter estimate

AP_NavEKF3: Reduce default minimum GPS velocity noise for Copters

Enables fail-safe to be set with more sensitivity and improves tracking accuracy.
Origin values were set using typical GPS performance for receivers on sale 6 years ago. Receiver performance has improved since then.

AP_NavEKF3: Prevent constant mag anomaly yaw resets

Prevents constant magnetic anomaly induced resets that can be triggered when flying with vehicle generated magnetic interference.
Allows for two resets per takeoff. Allowance for two resets is required, becasue a large ground based magnetic yaw anomaly can cause a sufficiently large yaw innovation that two resets in close succession are required.

AP_NavEKF3: Add option to fly without magnetometer

AP_NavEKF3: Rework emergency yaw reset logic

Use a separate external accessor function to request the yaw reset.
Allow reset requests to remain active for a defined period of time.
Tidy up reset function to split out accuracy check.

AP_NavEKF3: Fix vulnerability to lane switch race condition

Prevents the situation where a lane switch results in a lane being selected that does not have the correct yaw. This can occur if the primary lane becomes unhealthy before the external failsafe monitor has time to react.

AP_NavEKF3: Fix EKF_MAG_CAL = 6 behaviours

Fix bug causing the yaw alignment to be performed at startup before the GSF had a valid estimate.
Fix bug causing emergency yaw message to be output for a normal reset.
Fix vulnerability to reported negative yaw variance.
Remove duplicate timer checks.

AP_NavEKF3: Update EK3_MAG_CAL documentation

AP_NavEKF3: Relax yaw gyro bias convergence check when not using mag

AP_NavEKF3: Reduce yaw drift in hover with no yaw sensor

Uses the GSF yaw estimate if available which is better than the EKF's own yaw when no yaw sensor is available.
2020-04-24 09:43:22 +10:00
Randy Mackay 7470bc9994 AP_NavEKF3: CorrectGPSForAntennaOffset made const
also reduce scope of call to slightly reduce CPU load
2020-04-21 10:21:23 +10:00
Peter Barker 87108b86c8 AP_NavEKF3: add documentation for XKFM message 2020-04-21 09:48:43 +10:00
Randy Mackay 22c9081c83 AP_NavEKF3: minor comment fix 2020-04-15 19:35:30 +09:00
Peter Barker d19f8db06f AP_NavEKF3: rename APMrover2 to Rover 2020-04-14 09:50:34 +09:00
Andrew Tridgell 1f8cd830ea AP_NavEKF3: fixed use of tabs 2020-04-11 21:14:31 +10:00
Paul Riseborough f68f355852 AP_NavEKF3: Fix timestamp wrapping 2020-04-11 21:14:31 +10:00
Paul Riseborough 33ab1a7b15 AP_NavEKF3: Ensure yaw fusion commences when starting from rest 2020-04-11 21:14:31 +10:00
Paul Riseborough a3725e2581 AP_NavEKF3: Fix bug in calculation of rotation order 2020-04-11 21:14:31 +10:00
Paul Riseborough eeac0a05b9 AP_NavEKF3: Improvements to on ground movement check
Reduce sensitivity and log test ratios.
Reduce base logging rate to 5Hz and log when status changes.
2020-04-11 21:14:31 +10:00
Paul Riseborough ebb8bb4f6f AP_NavEKF3: Enable use of yaw fusion before external yaw sensor starts 2020-04-11 21:14:31 +10:00
Andrew Tridgell 3ae0b0d446 AP_NavEKF3: added using_external_yaw() method
needed by AHRS for attitudes_consistent() check
2020-04-11 21:14:31 +10:00
Andrew Tridgell 6f04fae4a0 AP_NavEKF3: added fallback to mag option with external yaw
this allows for a magnetometer to be used as a fallback yaw source in
flight when using an external yaw source such as a GPS. The
magnetometer bias is learned while the GPS yaw is available and
fallback is only done if the mag yaw and GPS yaw are consistent when
fallback is enabled

This also learns the Z gyro bias until first yaw alignment when
MAG_CAL is EXTERNAL_YAW_FALLBACK. This prevents large gyro bias
building while waiting for GPS lock
2020-04-11 21:14:31 +10:00
Andrew Tridgell a3100251a8 AP_NavEKF3: use enum class for EK3_MAG_CAL values
and use effective_magCal() everywhere for consistency
2020-04-11 21:14:31 +10:00
Andrew Tridgell be674fc36c AP_NavEKF3: make mag variance reporting consistent
logged scaled variance should match the value used in MAVLink
EKF_STATUS_REPORT
2020-04-06 17:30:29 +10:00
Peter Barker 609b66a053 AP_NavEKF3: rename struct log_NKF2a to log_XKF2 2020-03-31 10:25:59 +11:00
Daniel Magree b3ff81648b Nav_EKF3: varInnovBodyVel assigned the innovation covariance, rather than inverse 2020-03-25 21:52:49 +11:00
Peter Barker 4c19eb4bab AP_NavEKF3: use compass reference rather than repeatedly asking AHRS for it 2020-03-13 08:26:18 +11:00
Andrew Tridgell 772438f3ed AP_NavEKF3: fixed use of antenna position when switching GPS primary
when GPS primary switches we were using a position which had not been
corrected for antenna offset. This was used for calculating the reset
for sensor change.

This fixes that (trivial fix) and also fixes a similar issue on
position reset
2020-02-19 18:12:54 +11:00
Siddharth Purohit 545331024f AP_NavEKF3: Primary compass is always at serial number 0 2020-02-19 13:59:53 +09:00
Peter Hall 47e3fda8e9 AP_NavEKF3: add initalized flag and change to uint32_t 2020-02-19 06:45:07 +11:00
Peter Barker e289020332 AP_NavEKF3: stop taking ahrs in constructor 2020-01-21 11:53:18 +11:00
Peter Hall dd75609599 AP_NavEKF3: get_time_flying in vehicle 2020-01-14 22:34:37 -07:00
Peter Barker 03cca68c5a AP_NavEKF3: use instance number when logging rather than multiple message IDs 2019-12-17 12:22:07 +11:00
Peter Barker 9ed37e4486 AP_NavEKF3: make send_status_report const 2019-12-11 07:54:41 +09:00
Peter Barker 4431d01230 AP_NavEKF3: stop relying on the presence of a RangeFinder 2019-12-11 08:09:01 +11:00
Peter Barker b055eb8889 AP_NavEKF3: use instance # when logging EKF core timings 2019-12-06 12:52:03 +09:00
Andrew Tridgell c6aad9b1ec AP_NavEKF3: don't use WMM tables unless we have a compass scale factor set 2019-12-03 20:48:23 +11:00
Peter Barker fe8599d6d7 AP_NavEKF3: adjust for renaming of RangeFinder files 2019-11-12 07:14:37 +08:00
Peter Barker 11b372a986 AP_NavEKF3: use enum-class for RangeFinder Status 2019-11-09 08:01:53 +11:00
Randy Mackay f24afbcf4b AP_NavEKF3: initialise pre-arm failure message 2019-10-31 09:51:27 +08:00
Mark Whitehorn 3e21ef1389 AP_NavEKF3: add prearm failure message for null core pointer 2019-10-29 11:59:29 +08:00
Randy Mackay b4a8691a9e AP_NavEKF3: remove wheel encoder update limit 2019-10-22 07:15:48 +08:00
Randy Mackay 63309c6925 AP_NavEKF3: suppress ekf fail-to-set-origin if core disabled 2019-10-22 07:15:48 +08:00
Jaaaky 54f8e1137e AP_NavEKF3: added EK3_MAG_EF_LIM parameter
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.
2019-10-20 07:34:35 +11:00
Randy Mackay 5baed38266 AP_NavEKF3: reduce EK3_HRT_FILT max to 30 2019-10-18 11:15:25 +09:00
Paul Riseborough 5b1d9ed868 AP_NavEKF3: Add missing vertical position derivative calculation 2019-10-18 11:15:25 +09:00
Andrew Tridgell c2067d5bc2 AP_NavEKF3: set a min yaw accuracy from GPS of 5 degrees
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
2019-10-15 11:06:11 +11:00
Andrew Tridgell 3995db49a4 AP_NavEKF3: use parent class for intermediate static variables
this makes the code faster as well as using less memory when both EK2
and EK3 are enabled
2019-10-01 15:39:03 +10:00
Andrew Tridgell 0e3a27f74f AP_NavEKF3: change optimisation from -O3 to -O2 2019-09-28 08:57:26 +10:00
Andrew Tridgell 96c6544997 AP_NavEKF3: moved intermediate variables to common memory
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
2019-09-24 12:51:54 +10:00
Andrew Tridgell 05d62c62bb AP_NavEKF3: fixed use of uninitialised variable in EKF3 mag fusion
not all elements of H_MAG are initialised, but they are used, as found
by valgrind
2019-09-22 21:06:36 +10:00
Andrew Tridgell c6f43e9700 AP_NavEKF3: fixed use of old irqsave() API 2019-09-21 15:36:47 +10:00
Peter Barker 1c187d8feb AP_NavEKF3: correct return of empty prearm string 2019-09-19 08:47:47 +09:00
Andrew Tridgell fae2e44eac AP_NavEKF3: reset inhibitMagStates on in-flight yaw reset
this is needed to prevent the next ConstrainVariances() from zeroing
the variances, which leads to very slow learning of mag states
2019-09-11 14:22:18 +10:00
Randy Mackay 0e1a2efb7c EKF3: RNG_USE_HGT param only used when ALT_SOURCE = rangefinder 2019-09-10 18:44:52 +10:00
Michael du Breuil 9a7d64e8fc AP_NavEKF3: Allow the GPS to be responsible for logging 2019-09-10 09:09:17 +10:00
Peter Barker 7ea449076f AP_NavEKF3: use timing logging from AP_NavEKF 2019-09-03 09:28:37 +10:00
Peter Barker 61ed6e07eb AP_NavEKF3: shorten EKF3 initialisation send-text string
Now:
pbarker@bluebottle:~/rc/ardupilot(master)$ echo -n "EKF3 IMU1 buffers IMU=11 OBS=4 OF=10, dt=0.0120" | wc
      0       7      47
pbarker@bluebottle:~/rc/ardupilot(master)$

Closes #11952
2019-08-05 19:50:32 +10:00
Andrew Tridgell fc65e04ef2 AP_NavEKF3: fixed baro innovation gate when on ground with AIDING_NONE
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
2019-07-30 08:23:21 +10:00
Andrew Tridgell 04944fa6ce AP_NavEKF3: review fixes
thanks Paul!
2019-07-29 10:08:22 +10:00
Andrew Tridgell 451fe840ee AP_NavEKF3: ensure that EKF origin stays in sync on all cores
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
2019-07-29 10:08:22 +10:00
Andrew Tridgell 0fcb2037e1 AP_NavEKF3: use origin lat for earth rates
home may not yet be set when this code is run, so using home may be
invalid
2019-07-29 10:08:22 +10:00
Andrew Tridgell a3411efdb5 AP_NavEKF3: set origin on all cores
when EKF origin is set, make sure it is set on all cores
2019-07-29 10:08:22 +10:00
Andrew Tridgell 3818d8ecda AP_NavEKF3: restrict setting of EKF origin
only allow EKF origin to be set if EKx_GPS_TYPE is set to 3, which is
used for indoor operation
2019-07-29 10:08:22 +10:00
Siddharth Purohit db9f7c3dd5 AP_NavEKF3: do logging for 3rd EKF core 2019-07-23 12:34:38 +10:00
priseborough 209a32b8b9 AP_NavEKF3: Fix bug in use of external 321 yaw to align 2019-07-13 11:05:57 +10:00
priseborough 122f214416 AP_NavEKF3: Don't allow mag to interfere with use of external yaw sensor 2019-07-13 11:05:57 +10:00
Andrew Tridgell b56914b879 AP_NavEKF3: use GPS yaw if available and enabled
this allows a suitable GPS to be used as an external yaw source
2019-07-13 11:05:57 +10:00
priseborough 0c4f92d4c1 AP_NavEKF3: Add control logic to use external yaw sensor 2019-07-13 11:05:57 +10:00
priseborough 71d358803a AP_NavEKF3: Fix yaw sensor alignment status reporting 2019-07-13 11:05:57 +10:00
priseborough 977a7b68ed AP_NavEKF3: Add push to buffer for external yaw sensor data 2019-07-13 11:05:57 +10:00
priseborough 0a971c5181 AP_NavEKF3: Add function to reset yaw to external measurement 2019-07-13 11:05:57 +10:00
Andrew Tridgell 62575a194c AP_NavEKF3: Add data buffers for yaw sensor 2019-07-13 11:05:57 +10:00
priseborough 87c7649d09 AP_NavEKF3: Add interface for yaw angle measurements 2019-07-13 11:05:57 +10:00
Andrew Tridgell 634db441f8 AP_NavEKF3: origin handling fixes from Francisco 2019-07-11 06:40:55 +10:00
Andrew Tridgell 92783bccfa AP_NavEKF3: don't allow height datum reset when not on ground 2019-07-07 19:20:32 +10:00
Andrew Tridgell 3f9e48951b AP_NavEKF3: set terrainState to zero on height datum reset 2019-07-07 19:20:32 +10:00
Andrew Tridgell f3fc910abe AP_NavEKF3: continuously update gpsGoodToAlign
use it to determine how to handle a height datum reset
2019-07-07 19:20:32 +10:00
Andrew Tridgell b9a5794671 AP_NavEKF3: ensure that both AMSL and relative alt are correct after a reset
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
2019-07-07 19:20:32 +10:00
Andrew Tridgell 2208689893 AP_NavEKF3: don't use disabled gyros in opticalflow takeoff detection 2019-07-07 19:03:01 +10:00
Andrew Tridgell 209bca162c AP_NavEKF3: added inactive bias learning
this allows for biases on inactive IMUs to be learned so that an IMU
switch within an EKF lane does not cause a jump in the IMU data
2019-07-07 19:03:01 +10:00
Peter Barker ce45baa034 AP_NavEKF3: factor out and logging functions, reuse for 2nd core 2019-07-06 19:05:51 +10:00
Peter Barker f3f364de26 AP_NavEKF3: move logging in from AP_Logger 2019-07-06 19:05:51 +10:00
Andrew Tridgell 5151416080 AP_NavEKF3: force first EKF lane when disarmed
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.
2019-07-04 06:48:23 +10:00
Peter Barker ef2589738d AP_NavEKF3: use beacon singleton 2019-07-01 07:20:58 +09:00
Michael du Breuil b624f6f008 AP_NavEKF3: Reduce scope of AP_Baro.h 2019-06-27 14:56:21 +10:00
Michael du Breuil be74b631fe AP_NavEKF3: Fix AP_GPS.h include 2019-06-18 10:02:05 +10:00
Andrew Tridgell 60831c2878 AP_NavEKF3: added checkLaneSwitch()
this allows the vehicle code to ask the EKF to change lanes if it is
about to do an EKF failsafe
2019-06-12 09:52:20 +10:00
Peter Barker dce472745e AP_NavEKF3: take EAS2TAS from AHRS rather than airspeed 2019-06-06 12:44:36 +10:00
Jaaaky f21e4d833c AP_NavEKF3: Fix GPS < 3D empty PreArm: msg-as EKF2 2019-05-20 16:57:57 +10:00
Randy Mackay 0a5d6a430a AP_NavEKF3: accept optical flow data at up to 50hz 2019-05-11 16:23:57 +09:00
Andrew Tridgell e4f6ffe719 AP_NavEKF3: fixed bug in EKF lane selection
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
2019-05-07 06:59:50 +10:00
Michael du Breuil fe3b29a088 AP_NavEKF3: Allow checking all cores for health 2019-04-09 10:53:25 +10:00
Pierre Kancir b3a1c9c90c AP_NavEKF3: use get_distance_NE instead of location_diff 2019-04-08 08:00:52 -07:00
Paul Riseborough 9aaa0cd2e0 AP_NavEKF3: Fix typo in comment 2019-04-02 10:51:12 +11:00
Paul Riseborough b7e0a2345c AP_NavEKF3: Fix indexing error
Caused by copy and paste from AP_NavEKF2 which useds index 5 for vertical velocity. EKF3  should use index 6.
2019-04-02 10:51:12 +11:00