311 Commits

Author SHA1 Message Date
Mathieu Bresciani
3bd09fdcd3
EKF: fix range height sensor offset (#787)
The offset needs to be updated directly when switching to range height
2020-03-26 20:22:32 +11:00
bresch
d09473da89 Ekf control: do not set hgt mode if already set
If we are in a certain height mode and that we do a reset to the
same mode, there is no need to set the mode again.
2020-03-09 20:22:57 +01:00
bresch
684737eab1 Ekf control: replace individual by global check of baro/GPS health
Use _gps_data_intermittent and _baro_hgt_faulty to know is the sensors
provide fresh data
2020-03-09 20:22:57 +01:00
bresch
320a90d146 EKF control: extract checkVerticalAccelerationHealth logic
This is done to reduce the size of the controlHeightSensorTimeouts
function and to clarify the logic
2020-03-09 20:22:57 +01:00
CarlOlsson
93be6ea49a EKF: dont print wrong reset message on baro timeout
Signed-off-by: CarlOlsson <carlolsson.co@gmail.com>
2020-03-09 09:06:49 +01:00
Paul Riseborough
4669aa6312
EKF: Add Emergency yaw recovery using EKF-GSF estimator (#766)
* EKF: Use common rate vector calculation for offset corrections

* EKF: Remove duplicate matrix entry calculations

* EKF: Create a EKF-GSF yaw estimator class

* EKF: add emergency yaw reset functionality

* EKF: remove un-used function

* EKF: Ensure required constants are defined for all builds

* EKF: Fix CI build error

* Revert "EKF: remove un-used function"

This reverts commit 93005309c7f3794414ad99c86218b3062e00bbd3.

* EKF: Replace in-lined Tait-Bryan 312 conversions with function call

Also remove unnecessary operations

* EKF: Remove unnecessary update of external vision rotation matrix

* EKF: Use const

* EKF: use const

* EKF: don't use class variable as a temporary variable

* EKF: update comments

* EKF: Improve efficiency of yaw reset

Use conversion from rotation matrix to Euler angles instead of quaternion to euler angles.

* EKF: use const

* EKF: remove un-used struct element

* EKF: more descriptive function name

* EKF: use existing matrix row operator

* EKF: remove unnecessary rotation matrix update

* EKF: Use square matrix type

* EKF: Improve protection for bad innovation covariance

* EKF: Use matrix library operations

* EKF: Replace memcpy with better alternative

memcpy bypasses compiler sanity checks and is unnecessary in this instance.

* EKF: Split EKF-GSF yaw reset function

Adds a common function to support yaw reset that can be used elsewhere.

* EKF: Use common function for quaternion state and covariance yaw reset

* EKF: Replace inlined matrix operation

* EKF: Use const

* EKF: Change accessor function name

* EKF: Use const

* EKF: Don't create unnecessary duplicate variable locations

* EKF: Remove duplicate covariance innovation inverse

* EKF: Don't create unnecessary duplicate variable locations

* EKF: Rely on geo library to provide gravity

* EKF: Improve protection from bad updates

* EKF: Reduce effect of vibration on yaw estimator AHRS

* EKF: Improve yaw estimator AHRS accuracy during manoeuvre transients
2020-03-05 21:50:52 +11:00
Mathieu Bresciani
230c865fa9
EKF: do not fuse multiple times the same height (#767)
* EKF: do not fuse multiple times the same height

The _fuse_height flag was never set to zero, hence the fusion was called
at each iteration, even if no new data is available.
The effects were: high CPU usage and virtually less measurement noise
due to multiple fusion of the same sample

Also remve unused variables
2020-03-04 10:31:22 +01:00
Daniel Agar
4fab6057a7 EKF control height fusion add switch statement for all dist sensor types 2020-03-03 11:29:07 +01:00
bresch
81c6d6655f ekf: clean uncorrelateQuatStates function
As the name can be ambiguous, it gets renamed
"uncorrelateQuatFromOtherStates".
Also replace the loops storing the values and reapplying them by simply
zeroing two slices (this also saves 130B of flash).
2020-02-13 14:33:32 +01:00
kamilritz
da752c9e30 Hot flow fusion fix 2020-01-28 17:19:51 +01:00
kritz
ee859e092a Robustify timestamp checks (#729)
* Robustify timestamp checks

* Remove lowerbound on sensor timestamp

* Add tests for fusion timeouts

* Inline and const time check functions

* Rename dead_reckoning time variable
2020-01-28 20:33:16 +11:00
bresch
e3af91c9ce Ekf: use helper functions to centralize the checks of horizontal aiding (gps, flow, ev_pos, ev_vel) 2020-01-24 17:22:50 +04:00
kamilritz
f3d790a664 Update optical flow interface 2020-01-24 16:18:42 +03:00
kamilritz
4b0e7b2cff Remove filtering on external vision alignment 2020-01-24 08:23:12 +01:00
bresch
0f4439d281 optical flow: inhibit flow fusion only when the terrain estimate gets invalid 2020-01-15 16:07:17 +11:00
kamilritz
94484f01ce save flash space 2020-01-08 14:36:03 +01:00
kamilritz
84dcb32bd8 Extend auxVel interface to support 3d velocity 2020-01-08 14:36:03 +01:00
kamilritz
07e8e88e88 Support full vision variance 2020-01-08 14:36:03 +01:00
kamilritz
2657e4fc0c Improve naming and white space 2020-01-08 09:00:31 +01:00
kamilritz
1fcfd394dd Various small non-functional improvements 2020-01-08 09:00:31 +01:00
kamilritz
deeac03d6a Clean up height reset logic booleans 2020-01-08 09:00:31 +01:00
kamilritz
48787c0160 Improve Matrix library usage 2020-01-08 09:00:31 +01:00
kamilritz
9e6d27fafb Add missing const qualifier 2020-01-08 09:00:31 +01:00
kamilritz
1c68709949 Rename mag ambiguous mag abbreviations with magnitude 2020-01-07 08:14:59 +11:00
kamilritz
92ba618f57 Improve on flash memory usage 2020-01-02 19:26:57 +11:00
kamilritz
459b76f9fd Make covariance matrices of type matrix::SquareMatrix
and use functions from Matrix to reset covariances.
2020-01-02 19:26:57 +11:00
kamilritz
ef9f1053d0 Random improvements 2019-12-18 09:46:32 +01:00
kritz
532c9abd4a Expand test framework and test cases (#685)
* Fix comment

* Ekf wrapper for testing

Add utility function for accessing information in the ekf object

* Add step function for Gps sensor

* Add RangeFinder and Flow to simulated sensors

* Add first fusion logic tests

* Add units to function name

* Use EXPECT_TRUE

* Adding missing qualifiers

* Improve EXPECT_ calls

* Improve naming
2019-12-17 11:35:45 +01:00
kritz
6c25ac5731 Tilt Initialisation: Average Filter -> LowPass Filter (#686)
* Tilt Initialisation: Average Filter -> LowPass Filter

* Add _is_first_imu_sample variable

* Remove not needed comments
2019-12-17 11:01:25 +01:00
Daniel Agar
98a1aae494 EKF: use Matrix cross product 2019-12-17 09:35:08 +01:00
kamilritz
1bf09fd370 Remove EKF prefix from logged messages 2019-12-12 08:48:10 +01:00
kamilritz
181303488c Log height innovation sensor specific 2019-12-05 20:09:34 +11:00
kamilritz
f32fce28a3 Fix gps vertical observation variance 2019-12-05 20:09:34 +11:00
kamilritz
ecd199d5d0 Fix vel pos test ratio 2019-12-05 20:09:34 +11:00
kamilritz
2df2dede2f Fix variance vs stdDev bug
(cherry picked from commit 0faea89da2a3326d070a6ecca93ec52ec3e29591)
2019-12-05 20:09:34 +11:00
kamilritz
07e804676c Rename IMU biases 2019-12-05 20:09:34 +11:00
kamilritz
dae8c2f8dc Group velocity and position as a 3d vector 2019-12-05 20:09:34 +11:00
kamilritz
5c038a3b43 Add stop*Fusion function 2019-12-05 20:09:34 +11:00
kamilritz
86b9079bdc Refactoring velPos fusion 2019-12-05 20:09:34 +11:00
Mathieu Bresciani
c7bdf25663
[ekf] controlMagFusion refactor and mag field strength check (#662)
* ekf_control: Inhibit mag fusion when field magnitude is large
Move mag inhibition check in separate function

* ekf_control: pull out of functionalities out of controlMagFusion
- yaw abd mag bias observability checks
- mag 3D conditions
- load mag covariances
- set and clear mag control modes

* ekf_control: refactor mag heading/3D start/stop.
Move mag declination, mag 3d and mag heading fusion out of the main function

* ekf_control: extract mag yaw reset and mag declination fusion requirements

* ekf_control: use WMM in isStronMagneticField for mag fusion inhibition
- Correct units of WMM strength table

* ekf_control: extract mag_state_only functionality of AUTOFW (VTOL custom)
Also split inAirYawReset from onGroundYawReset

* ekf_control: extract mag automatic selection
- transform if-else into switch-case for parameter fusion type selection

* ekf_control: extract run3DMagAndDeclFusion, reorganize functions, fix
flag naming in Test script

* ekf_control: do not run mag fusion if tilt is not aligned.
Reset some variables on ground even if mag fusion is not running yet. It
could be that it runs later so we need to make sure that those variables
are properly set.

* ekf_control: move controlMagFusion and related functions to mag_control.cpp

* ekf control: check for validity of mag strength from WMM and falls back
to average earth mag field with larger gate if not valid

* ekf control: remove evyaw check for mag inhibition

* ekf control: change nested ternary operator into if-else if

* Ekf: create AlphaFilter template class for simple low-pass filtering
0.1/0.9 type low-pass filters are commonly used to smooth data, this
class is meant to abstract the computation of this filter

* ekf control: reset heading using mag_lpf data to avoid resetting on an outlier
fixes ecl issue #525

* ekf control: replace mag_states_only flag with mag_field_disturbed and
add parameter to enable or disable mag field strength check

* ekf control: remove AUTOFW mag fusion type as not needed This was implemented for VTOL but did not solve the problem and should not be used anymore

* ekf control: use start/stop mag functions everywhere instead of setting the flag

* ekf control: Run mag fusion depending on yaw_align instead of tilt_align
as there is no reason to fuse mag when the ekf isn't aligned

* AlphaFilter: add test for float and Vector3f
2019-11-08 16:02:59 +01:00
RomanBapst
16d1e15b51 addressed review comments
Signed-off-by: RomanBapst <bapstroman@gmail.com>
2019-10-24 07:55:37 +11:00
RomanBapst
00f49e62c2 cleanup checks of range finder data
Signed-off-by: RomanBapst <bapstroman@gmail.com>
2019-10-24 07:55:37 +11:00
bresch
b38458c2ab Terrain estimator: formatting and remove redundant comments 2019-10-22 20:19:56 +11:00
bresch
e09e3e17a1 control: rename _range_aid_enabled to _is_range_aid_suitable
rename rangeAidConditionsMet to checkRangeAidSuitability
2019-10-15 11:10:36 +02:00
bresch
fac69d07a3 control: refactor rangeAidConditionsMet function 2019-10-15 11:10:36 +02:00
Paul Riseborough
eae6e8f19c EKF: Fix on ground yaw drift when using EKF2_MAG_TYPE = 4 2019-10-08 20:08:42 +11:00
RomanBapst
4e946d5bcb implemented synthesized magnetometer Z measurement
- calculate a theoretical value based on the knowledge of the direction
and strength of the magnetic field vector and X/Y sensor measurements
- needs knowledge about location on earth to work
2019-10-08 20:02:16 +11:00
kritz
4a38f5a2f6 Add timestamp to ECL print statements, (#644)
which is helpful for EKF replay debugging.
2019-09-25 11:24:42 +02:00
kamilritz
83eb326076 Missing posNED 2019-09-24 07:48:46 +10:00
kamilritz
4f6ca3a74c Replace rest of spaces with tabs 2019-09-24 07:48:46 +10:00