Commit Graph

189 Commits

Author SHA1 Message Date
Peter Barker 560f17a570 AP_NavEKF3: use union to alias array and struct access to states
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.
2018-10-19 08:46:43 +11:00
Peter Barker 27e3a89158 AP_NavEKF3: correct compilation when running MATH_CHECK_INDEXES 2018-10-19 08:46:43 +11:00
Peter Barker 281fad53c2 AP_NavEKF3: always set EKF control limits, even with no cores 2018-10-09 10:47:38 +11:00
Peter Barker b68a91d171 AP_NavEKF3: remove default clause in setAidingMode
All aiding modes should be covered in the switch statement; adding the
default clause squelches a potentially useful compiler warning
2018-10-03 17:49:43 +01:00
Michael du Breuil 1991f223ac AP_NavEKF3: Fix roundoff, and missing offset handling of getLLH 2018-09-21 00:18:49 +01:00
Peter Barker be9235a581 AP_NavEKF3: fix writeOptFlowMeas signature
const some of the vectors, stop taking references to scalars that aren't
being changed
2018-09-11 09:03:22 +10:00
Randy Mackay 3d72022f6e EKF: modify ALT_SOURCE param description
We regularly find users changing the ALT_SOURCE to 1 (range finder) when trying to implement terrain following which is not the correct way to do it
2018-07-18 08:31:09 +09:00
Andrew Tridgell ac40a20c02 AP_NavEKF3: fill in gps_quality_good flag 2018-07-14 17:49:52 +10:00
Peter Barker 6bf5ffdb6d AP_NavEKF3: use compass singleton for logging 2018-07-04 20:11:27 +01:00
murata 4d5e258b19 AP_NavEKF3: Delete unused definitions 2018-06-11 09:11:44 +09:00
murata f0a6cd5846 AP_NavEKF3: Clarify the message 2018-06-04 11:32:15 +09:00
Andrew Tridgell 553abda91c AP_NavEKF3: use single precision ceilf() 2018-05-07 11:43:23 +10:00
Andrew Tridgell 4869dd0ae4 AP_NavEKF3: send airspeed variance over mavlink 2018-04-30 15:41:32 +10:00
Peter Barker 901ba0034c AP_NavEKF3: do not pass GPS into Log_Write_GPS; it uses singleton 2018-04-18 13:50:55 +09:00
Peter Barker a0d874baa2 AP_NavEKF3: const accessors 2018-04-07 09:56:18 +09:00
Peter Barker 6791808ac6 AP_NavEKF3: remove unneeded initialisations
AP_NavEKF3 should never be allocated in uninitialised memory
2018-04-07 09:54:21 +09:00
Peter Barker d38ff1dd2c AP_NavEKF3: initialise EKF3 constants in declaration not constructor 2018-04-07 09:54:21 +09:00
Pierre Kancir 2b2c1e2d78 AP_NavEKF3: only use bcn EKF is the alignement as been completed 2018-04-03 09:55:13 +09:00
Pierre Kancir 44a21bc8ac EKF3: correct acos to acosf 2018-04-03 09:54:45 +09:00
Pierre Kancir 48c5a9b9c5 AP_NavEKF3: style change in BCN mesurements 2018-04-03 09:54:43 +09:00
Pierre Kancir 4d2f2a2aad AP_NavEKF3: correct flag in case of GPS disable 2018-04-03 09:54:41 +09:00
priseborough 5785523a0d AP_NavEKF3: Clarify definition for gps_glitching flag 2018-03-27 20:28:56 +09:00
Peter Barker 55b8a2288e AP_NavEKF3: use ins singleton 2018-03-16 00:37:35 -07:00
Peter Barker 7b1a906c4e AP_NavEKF3: use baro singleton 2018-03-08 21:20:05 -08:00
Paul Riseborough 6a1055389d AP_NavEKF3: Fix origin height estimator indexing bug
EKF3 should use index 9 to access vertical position states
2018-02-21 17:04:30 +10:00
Tatsuya Yamaguchi aef9fa4a63 AP_NavEKF3: delete \n from the log using gcs().send_text 2018-02-02 09:13:54 +09:00
murata 6a87840c7a AP_NavEKF3: Change the if statement to a switch statement. 2018-01-28 22:20:08 +00:00
bugobliterator ea2a880d8a AP_NavEKF3: allocate from MEM_FAST region 2018-01-15 11:46:02 +11:00
Peter Barker 5dc714bf5f AP_NavEKF3: use GPS singleton 2017-12-27 00:58:02 +00:00
Pierre Kancir be96a27fa8 AP_NavEKF3: only report terrain estimator innovations with valid rng value 2017-12-18 22:51:46 +00:00
Andrew Tridgell c13eaf0c7f AP_NavEKF3: removed create() method for objects
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
2017-12-14 08:12:28 +11:00
Andrew Tridgell 6b30c9213a AP_NavEKF3: delay startup until IMU buffer is filled
this prevents a vulnerability where the initial IMU data is processed
26 times (where 26 is the IMU buffer length)
2017-12-12 11:39:38 +11:00
Andrew Tridgell 2c6593e35e AP_NavEKF3: fixed inverted function setInhibitGpsVertVelUse() 2017-11-29 09:47:14 +09:00
priseborough c96bc54254 AP_NavEKF3: correctly use wheel odometry speed for pitched rovers 2017-10-31 08:11:05 +09:00
priseborough ee6b43aabf AP_NavEKF3: Fix bugs in use of wheel encoder data
Found by pavloblindnology
2017-10-28 10:58:01 +09:00
Lucas De Marchi bd6145af6d AP_NavEKF3: add static create method 2017-09-26 03:01:21 +01:00
Peter Barker 63440800fc AP_NavEKF3: use rangefinder backend accessors 2017-08-15 18:30:45 +01:00
priseborough 2310cb6d19 AP_NavEKF3: Enable external control over use of GPS vertical velocity 2017-08-10 19:49:45 +10:00
Michael du Breuil efe70c8d3a AP_NavEKF3: Fix possible compass nullptr dereference 2017-08-01 15:25:05 +01:00
priseborough db7c8439c6 AP_NavEKF3: Fix bug in wheel odometry timestamp correction 2017-07-28 12:48:38 +09:00
priseborough c7f6d52065 AP_NavEKF3: Add wheel encoder odometry
Uses the existing body frame odometry observation model.
Handles each sensored wheel as a separate sensor.
2017-07-27 16:52:27 +09:00
priseborough cbe8f97489 AP_NavEKF3: rename struct used for velocity odometry observations
Do this so we can add other odometry observation types.
2017-07-27 16:52:26 +09:00
priseborough 08a3f55c90 AP_NavEKF3: Fix error in scaling of observation error 2017-07-27 16:52:25 +09:00
priseborough 593437ca95 AP_NavEKF3: Add tuning of visual odometry observation error
Also adjust default values based on replay analysis.
2017-07-27 16:52:25 +09:00
priseborough 58d58b4eac AP_NavEKF3: Initialise EKF origin height to field elevation
Enables copters to set bit position 2 in the EK3_OGN_HGT_MASK parameter without having a large jump in reported local position height.
2017-07-17 02:22:02 +01:00
priseborough 0827b13feb AP_NavEKF3: Fix default behaviour for height origin corrections
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.
2017-07-17 02:22:02 +01:00
Peter Barker 93e09c51d3 AP_NavEKF3: eliminate GCS_MAVLINK::send_statustext_all 2017-07-11 23:53:53 +01:00
Randy Mackay d64b2fcbf0 AP_NavEKF3: final mag reset at 2.5m 2017-07-08 08:39:43 +09:00
priseborough 9d0fa09d39 AP_NavEKF3: Fix calculation of predicted LOS rate in terrain estimator 2017-06-26 14:58:06 +01:00
priseborough a4d18696a7 AP_NavEKF3: Improve variable names and documentation
Also remove unnecessary calculation of innov * gain
2017-06-23 00:43:58 +01:00
priseborough 368983ed5a AP_NavEKF3: Clean up aiding mode logic using switch statements 2017-06-23 00:43:58 +01:00
priseborough 2a9eceaf10 AP_NavEKF3: Fix bugs causing height drift when using range beacons 2017-06-23 00:43:58 +01:00
priseborough 7659e9c31f AP_NavEKF3: Improve checking of time delay validity when setting buffers
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.
2017-06-21 11:44:45 +01:00
priseborough 7d63286088 AP_NavEKF3: update to match AP_GPS interface change 2017-06-21 11:44:45 +01:00
priseborough 06d40a7901 AP_NavEKF3: Fix terrain estimator innovation consistency check 2017-06-20 02:08:56 +01:00
priseborough 284fc0f3c5 AP_NavEKF3: Fix bug in flow fusion for terrain estimation
Also remove unused class variables
2017-06-20 02:08:56 +01:00
Andrew Tridgell a1508b58c1 AP_NavEKF3: use AHRS likely flying state
this sets inFlight when AHRS has indicated flying for 5s
2017-06-20 09:44:44 +10:00
priseborough edee8396ba AP_NavEKF3: Improve in-flight check for non fly forward vehicles
This will enable the EK3_MAG_TYPE 0 option to be used for multirotors
2017-06-19 06:09:07 +10:00
Dr.-Ing. Amilcar Do Carmo Lucas 6a01c65197 AP_NavEKF3: Fix long description of EK3_OGN_HGT_MASK parameter (NFC) 2017-06-16 12:05:20 +01:00
priseborough 49ec2b4032 AP_NavEKF3: Change default value of EK3_OGN_HGT_MASK
Turn off by default.
Update parameter description.
2017-06-14 12:44:41 +01:00
priseborough 6d14cf0ab8 AP_NavEKF3: Ensure reported local height = global height - origin height 2017-06-14 12:44:41 +01:00
priseborough 3ae7998f51 AP_NavEKF3: Allow reporting of origin height for specified instance 2017-06-14 12:44:41 +01:00
priseborough e58ba8044d AP_NavEKF3: Improve protection for badly conditioned dVel bias covariances
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.
2017-06-14 12:44:41 +01:00
priseborough bf963f8b65 AP_NavEKF3: Raise lower limit on del vel bias state variances
This is required to prevent co-variance matrix errors due to long periods without movement causing height divergence.
2017-06-14 12:44:41 +01:00
priseborough 628d140319 AP_NavEKF3: Make target covariance time step larger
The target covariance time step has been increased from 10 to 12 msec to improve conditioning of the covariance prediction calculation.
2017-06-14 12:44:41 +01:00
priseborough 2b97d0f5c9 AP_NavEKF3: Add public accessor for state variances 2017-06-14 12:44:41 +01:00
priseborough 9f97cbfc3b AP_NavEKF3: Revert auto-code to original form and remove micro optimisations
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.
2017-06-14 12:44:41 +01:00
priseborough f38fccd57c AP_NavEKF3: Prevent possible race condition re-zeroing state variances 2017-06-14 12:44:41 +01:00
priseborough 7adaea6019 AP_NavEKF3: Improve partitioning and efficiency of the covariance prediction
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.
2017-06-14 12:44:41 +01:00
priseborough a1c117360c AP_NavEKF3: Ensure Kalman gain calculatons respect deactivated states
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.
2017-06-14 12:44:41 +01:00
priseborough 5058405f8c AP_NavEKF3: add gyro bias state inhibit and rework index limit calculation
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.
2017-06-14 12:44:41 +01:00
priseborough 0cba133a1e AP_NavEKF3: Fix initialisation of state inhibit flags 2017-06-14 12:44:41 +01:00
priseborough 9da3caca47 AP_NavEKF3: Improve GPS reference height estimator
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.
2017-06-14 12:44:41 +01:00
Dr.-Ing. Amilcar Do Carmo Lucas c1eb9fb9c3 AP_NavEKF3: Spell in comments 2017-05-18 09:29:55 +09:00
Dr.-Ing. Amilcar Do Carmo Lucas d3a57b5965 AP_NavEKF3: Use SI units conventions in parameter units
Follow the rules from:
http://physics.nist.gov/cuu/Units/units.html
http://physics.nist.gov/cuu/Units/outside.html
and
http://physics.nist.gov/cuu/Units/checklist.html
one further constrain is that only printable (7bit) ASCII characters are allowed
2017-05-17 18:07:25 +10:00
Dr.-Ing. Amilcar Do Carmo Lucas 9cb068d3f4 AP_NavEKF3: Spell in coments 2017-05-16 20:29:16 +09:00
murata 46cba2c970 libraries: Delete the setting value for specific editor. 2017-05-11 13:18:41 -07:00
Dr.-Ing. Amilcar Do Carmo Lucas 23b7f1e645 AP_NavEKF3: Improve comments, typos 2017-05-03 08:45:01 +09:00
priseborough 4a898037e9 AP_NavEKF3: documentation update 2017-05-01 14:24:55 +10:00
Andrew Tridgell a04aff7a7d AP_NavEKF3: added inter-EKF scheduling cooperation
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
2017-05-01 14:24:55 +10:00
priseborough 0bf50fd56f AP_NavEKF3: Add monitoring of average EKF time step 2017-04-29 11:03:44 +10:00
priseborough 3ce81967ae AP_NavEKF3: Improve calculation and use of average EKF time step 2017-04-29 11:03:44 +10:00
priseborough 7abf9997e6 AP_NavEKF3: Correctly initialise dtIMUavg time step and apply LPF 2017-04-29 11:03:44 +10:00
priseborough 1301b9797a AP_NavEKF3: Fix solution validity reporting bug
Fixes bug that causes relative position status to report as false when using optical flow and using range finder as the primary height sensor.
2017-04-28 17:19:23 +01:00
Andrew Tridgell adb281cd4e AP_NavEKF3: added timing statistics logging 2017-04-28 17:19:39 +10:00
priseborough f208986d43 AP_NavEKF3: Reset covariance if bad mag fusion update 2017-04-27 20:14:21 +10:00
Andrew Tridgell 18b66f9eed AP_NavEKF3: fixed reset of coviariance matrix 2017-04-27 18:33:25 +10:00
Randy Mackay b255c7b370 AP_NavEKF: add setOrigin 2017-04-22 10:37:31 +09:00
priseborough fb7104f4e3 AP_NavEKF3: add fusion method for body frame odometry data 2017-04-19 11:04:40 +09:00
Andrew Tridgell 248773a7c8 AP_NavEKF3: allow access to quaternion for each instance 2017-04-16 14:01:36 +10:00
priseborough 8250fe4943 AP_NavEKF3: fix documentation derivation references 2017-04-10 15:47:35 +09:00
priseborough 06c073e448 AP_NavEKF3: Update tilt alignment check 2017-04-05 20:16:16 +10:00
Jonathan Challinger c7a73e84d6 AP_NavEKF3: apply height innovation floor only when barometer is in use 2017-03-24 14:42:36 -07:00
priseborough 56a9e2c462 AP_NavEKF3: Reference correct derivation 2017-03-13 11:31:51 +11:00
priseborough 18927395d7 AP_NavEKF3: log correct GPS for replay 2017-03-13 11:31:51 +11:00
priseborough 01551a4423 AP_NavEKF3: handle position jump caused by change in GPS receiver
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
2017-03-13 11:31:51 +11:00
Randy Mackay 3e039a6ba4 AP_NavEKF3: minor formatting fixes
No functional change
2017-03-06 18:40:18 +11:00
Randy Mackay a80c0a231d AP_NavEKF3: attempt to set-up every core
previously we would only call setup_core for the 2nd core if the first had been setup successfully
2017-03-06 18:40:18 +11:00
priseborough 7a8783f35e AP_NavEKF3: Fix bug preventing reset to GPS
This fixes a bug that prevented the reset to the GPS position occurring if GPS velocity observations were still passing innovation consistency checks.
2017-03-06 17:11:39 +11:00
Randy Mackay 3f6a734a71 AP_NavEKF3: only use downward facing rangefinder 2017-02-27 15:18:11 +09:00