Commit Graph

1151 Commits

Author SHA1 Message Date
kamilritz dae8c2f8dc Group velocity and position as a 3d vector 2019-12-05 20:09:34 +11:00
kamilritz beedf1ce4f Add print statement to reset vel or pos function 2019-12-05 20:09:34 +11:00
kamilritz 5c038a3b43 Add stop*Fusion function 2019-12-05 20:09:34 +11:00
kamilritz d5dc6bb8ea Clean get*innov* interface 2019-12-05 20:09:34 +11:00
kamilritz 86b9079bdc Refactoring velPos fusion 2019-12-05 20:09:34 +11:00
bresch 6b5f011bc2 ekf: use PDOP instead of GDOP as the TDOP (part of GDOP) is usually not available
PDOP is the position dillution of precision and is given by sqrt(VDOP^2+HDOP^2)
2019-11-25 17:18:40 -05:00
RomanBapst 33a2bd0292 added python script for derivation of initial wind covariance matrix
Signed-off-by: RomanBapst <bapstroman@gmail.com>
2019-11-20 16:28:34 +11:00
bresch 811ec81246 parameters: change check_mag_strength from bool to int32_t to comply with the standard interface 2019-11-11 15:29:52 +01: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
bresch a6840655e8 ekf: Extract resetState from main reset and reinitialize
the covariances in the init function
2019-11-05 09:07:25 +01:00
bresch bf48004fb9 ekf: move "reset" part of the init function into a separate function
add getter for the vehicle at rest flag
2019-11-05 09:07:25 +01:00
kamilritz d79199c863 Remove swig and python test related things 2019-10-28 11:04:38 +01:00
kamilritz 71be26efc6 Port RingBuffer Test to GTests 2019-10-28 11:04:38 +01:00
kamilritz cac5f3fd6d GTest and Coverage cleanup and Basic EKF GTest 2019-10-28 11:04:38 +01:00
Martina Rivizzigno fcea13eef8 add gtest, temp disable swig
(cherry picked from commit 4008d163d77f503e6acbd7ddc1d87ac6d479c897)
2019-10-28 11:04:38 +01:00
RomanBapst 9b4b24ee71 removed unused definition
Signed-off-by: RomanBapst <bapstroman@gmail.com>
2019-10-24 07:55:37 +11:00
RomanBapst 0e3a0b8659 range_finder_checks: parametrised signal quality hysteresis duration
Signed-off-by: RomanBapst <bapstroman@gmail.com>
2019-10-24 07:55:37 +11:00
RomanBapst 16d1e15b51 addressed review comments
Signed-off-by: RomanBapst <bapstroman@gmail.com>
2019-10-24 07:55:37 +11:00
RomanBapst 6bc6f26043 range_finder_checks: set range height to valid if signal quality is non-zero
Signed-off-by: RomanBapst <bapstroman@gmail.com>
2019-10-24 07:55:37 +11:00
RomanBapst 6299d8199c ekf_helper: use latest validated range sample to reset height
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
Paul Riseborough 4d37065f1b EKF: Make use of inverse rotation function consistent with name
The quaternion to inverse rotation matrix function has been updated so that the rotation it produces is the inverse to that produced by the matrix library and the the inverse of the quaternion is uses. This function is now used to directly calculate an inverse rotation matrix rather than calculating the forward rotation and then transposing it.
2019-10-23 14:44:08 +03:00
Paul Riseborough 36de2b3dc1 EKF: Use matrix library for quaternion to rotation matrix conversion 2019-10-23 14:44:08 +03:00
bresch 29f71fff96 ekf: Add override specifier for all functions that override virtual functions of the estimator interface class 2019-10-22 09:12:19 -04:00
bresch 50167bfbcf estimator interface: add deprecated functions for backward compatibility 2019-10-22 20:19:56 +11:00
bresch b38458c2ab Terrain estimator: formatting and remove redundant comments 2019-10-22 20:19:56 +11:00
bresch 0aef0eda59 terrain_estimator: remove dead code. Since the terrain estimator is
constantly reset on ground, it is not necessary anymore to fuse fake
measurements on ground if the range measurements are bad.
2019-10-22 20:19:56 +11:00
bresch 370e04ee60 terrain_est: Continuously reset terrain height on ground using known
clearance. This is the best estimate as we should not rely on a distance
sensor while on the ground. This also helps when the drone is carried
over as it avoids starting with a crazy downward distance for optical
flow scaling.
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
kamilritz f005e0ea8f Remove deprecated ev_innov_gate param 2019-09-27 10:00:45 -04: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
kritz bb88d4ce5e Undo wrong comment change 2019-09-24 08:50:29 +10:00
Kamil Ritz 562731936a Update quaternion direction in documentation pdf 2019-09-24 08:50:29 +10:00
kamilritz 8c061fb6a4 Fixing wrong label of quaternion direction 2019-09-24 08:50:29 +10:00
Jannik Beyerstedt fe3fec413c fix #595 and add new all-in-one conversion script (PX4 only) 2019-09-24 08:20:16 +10:00
kamilritz 83eb326076 Missing posNED 2019-09-24 07:48:46 +10:00
kamilritz fd6b364c11 posNED to pos and velNED to vel and add ev vel covariances to reset 2019-09-24 07:48:46 +10:00
kamilritz 4f6ca3a74c Replace rest of spaces with tabs 2019-09-24 07:48:46 +10:00
kamilritz cea053820d Remove spaces with tabs 2019-09-24 07:48:46 +10:00
kamilritz 1e57c4bbec Fix white space 2019-09-24 07:48:46 +10:00
kamilritz 10cbd79db7 Rotate external vision info in reset function if necessary 2019-09-24 07:48:46 +10:00
kamilritz 4511b9ff5e Add missing checks for flags.ev_vel 2019-09-24 07:48:46 +10:00
kamilritz e7d927c899 Stop using bad GPS when we have vision velocity 2019-09-24 07:48:46 +10:00
kamilritz bd8f05567a set vel_pos_test_ratio to zero if no fusion happens 2019-09-24 07:48:46 +10:00
kamilritz 4b30de587f Make vel_pos innov gate variable name clearer 2019-09-24 07:48:46 +10:00
kamilritz 4237d7ccd7 Improve external vision position fusion 2019-09-24 07:48:46 +10:00
kamilritz 3e8139ff9f Enable vision velocity fusion 2019-09-24 07:48:46 +10:00
kamilritz 149233a9ab Add velocity observations to external vision interface 2019-09-24 07:48:46 +10:00
Matthias Grob 62a1e07512 ecl_EKF: Do not include SquareMatrix from Matrix library
because the template of upper_right_triangle() contains /2 and
swig fails to create a wrapper for that (suddenly)
2019-09-18 08:42:58 +02:00
Julian Kent 4c4c1f2984 Use copyTo for writing to memory blocks 2019-09-18 08:42:58 +02:00
Julian Kent 8cc8db211c Fix copy_quaternion reference in code generation 2019-09-18 08:42:58 +02:00
Julian Kent 8d60f8ba8f Remove direct unsafe access to matrix internal data 2019-09-18 08:42:58 +02:00
Nico van Duijn c446ee444a EKF: fake rng if faulty on ground 2019-09-18 10:15:37 +10:00
Andreas Antener 4f19d457c4 ekf, control: make sure mag fusion doesn't start anymore when we have GPS heading fusion active 2019-09-18 09:27:24 +10:00
Jan Brehmer 93eb1266f6 EKF: reset position when stopping GPS use and EV is active 2019-09-18 08:33:40 +10:00
Nico van Duijn 267195a11b EKF: remove check for faulty flag in fake rng
This removes the check for _rng_hgt_faulty in the decision of publishing
a fake range measurement. The reason for this is that some distance sensors
don't populate the quality flag, even if they are saturated. Hence, if we
are on the ground and not moving, it is safe to publish a fake measurement
of the distance sensor and overwrite the actual sensor data.
2019-09-12 17:45:37 +10:00
Nico van Duijn 933189eac0 EKF: fix rng_faulty flag when sensor is stuck 2019-09-12 17:45:37 +10:00
Nico van Duijn 640e41cba7 EKF: change rangeSample quality to int8_t 2019-09-12 17:45:37 +10:00
Nico van Duijn a12186c285 terrain_estimator: introduce quality metric in rng
This commit introduces a quality measure in the range data. It is
used to properly decide whether to initialize the HAGL estimate on
 sensor data or MIN_HGT parameter, as well as in the decision of
whether a 'fake' measurement should be published on the ground to
allow for optical flow take-offs.
2019-09-12 17:45:37 +10:00
Paul Riseborough 3e05fd552e EKF: Compensate for bad range finder data when on ground 2019-09-12 17:45:37 +10:00
bresch 3b32ee4166 Flow aiding - Reset state when flow is enabled only if it is the only
position/velocity aiding sensor.
Until now, it was alway resetting if the vehicle does not have gps or
external vision. This caused a reset/glitch at every stop (when range data gets
valid)
2019-09-03 09:58:33 +02:00
kamilritz be368f3656 Update comment 2019-08-29 08:34:10 +10:00
kamilritz c5abfe626f remove canonicalize and adapt comments 2019-08-29 08:34:10 +10:00
kamilritz a2ff415fe4 Fix get frame aligning quaternion function 2019-08-29 08:34:10 +10:00
kamilritz 53eac6e94e Canonicalize alignment quaternion 2019-08-29 08:34:10 +10:00
kamilritz 933c32c921 Enable local frame alignment also without using it 2019-08-29 08:34:10 +10:00
kamilritz ea352a6631 Dont use mag suffix for magnitude 2019-08-29 08:34:10 +10:00
kamilritz 05196db79e Fix alignment of local frame 2019-08-29 08:34:10 +10:00
bresch e1751188fd EKF - Initialize _deadrekon_time_exceeded to true.
If no sample have been received, deadrekoning and local position should be invalid.
2019-06-28 10:52:52 -04:00
Paul Riseborough a036cf82cc EKF: Remove use of of quaternion self product operator and fix delta rotation sign 2019-06-17 19:24:55 +10:00
Paul Riseborough 0e946f25fd EKF: Remove use of quaternion self product operator and fix delta rotation sign error 2019-06-17 19:24:55 +10:00
CarlOlsson ad7f7af03b ekf: correct quaternion multiplication order 2019-06-17 19:24:55 +10:00
CarlOlsson d6351bd7a5 EKF: update comment 2019-06-17 19:24:55 +10:00
Paul Riseborough 7612fa40ed EKF: Don't start using GPS for height until all validity checks have passed
Consolidate intermittent data checks, improve variable and clarify usage.
2019-06-13 19:36:37 +10:00
Roman cef2ba5ab9 implemented Kahan summation algorithm for adding process noise to delta
angle- and delta velocity bias variance

- the contribution of process noise per iteration for these states can be so
small that it gets lost if using standard floating point summation

Signed-off-by: Roman <bapstroman@gmail.com>
2019-06-11 19:28:06 +10:00
RomanBapst 0f49eb34a0 fixed method which calculates validity of terrain estimate
Signed-off-by: RomanBapst <bapstroman@gmail.com>
2019-05-28 19:43:13 +10:00
Robert de Vries 340d85afc1 EKF: fix variable names in estimator_interface.h
This fixes issue #566
2019-05-27 17:39:42 -04:00
Beat Küng 54ac147ae8 Ekf: add set_min_required_gps_health_time() to allow configure minimum GPS health time
This does not change the default of 10 seconds.
2019-05-15 09:00:24 +01:00
Roman 770cd3c5cc added python script for terrain flow derivation (optical flow for terrain
height estimation)

Signed-off-by: Roman <bapstroman@gmail.com>
2019-05-15 17:16:36 +10:00
Roman c085d7295d addressed review comments 2019-05-15 17:16:36 +10:00
Roman 8673ab0346 terrain estimator: constrain terrain state properly
Signed-off-by: Roman <bapstroman@gmail.com>
2019-05-15 17:16:36 +10:00
Roman fbb51147b7 implemented use of optical flow for terrain estimation
Signed-off-by: Roman <bapstroman@gmail.com>
2019-05-15 17:16:36 +10:00
Mohammed Kabir 3f691891c4 EKF: control: stop vision yaw fusion on timeout 2019-04-22 12:56:24 +10:00
Martina c4492b17c1 do not reset yaw if vehicle on ground 2019-04-09 20:50:37 +10:00
Paul Riseborough f97f0b6ea3 EKF: Remove unnecessary code
_flt_mag_align_start_time is set on initial alignment and will always be >0 before this check can run
2019-04-08 06:57:17 +10:00
Paul Riseborough 43b5e26fe4 EKF: Fix bug causing continual yaw reset when EKF2_MAG_TYPE = 2 2019-04-08 06:57:17 +10:00
Roman f95cd4b358 ground effect: removed dependency on local position
Signed-off-by: Roman <bapstroman@gmail.com>
2019-03-19 13:14:57 +11:00
CarlOlsson 7845ff4360 EKF: increase wind process noise scaler to 0.5
Signed-off-by: CarlOlsson <carlolsson.co@gmail.com>
2019-03-19 13:10:12 +11:00
CarlOlsson 32ca6f7030 ekf: scale wind process noise with low pass filtered height rate 2019-03-19 13:10:12 +11:00
CarlOlsson 938c8ad9ad EKF: use hagl estimate if valid for when to trigger yaw reset on takeoff 2019-03-19 13:04:54 +11:00
Carl Olsson f0889c1760 EKF: fixed some comment typos
Signed-off-by: CarlOlsson <carlolsson.co@gmail.com>
2019-03-18 10:20:33 -04:00
Paul Riseborough fabd216ca5 EKF: Documentation edits 2019-03-13 08:14:23 +11:00
CarlOlsson 8d6e8ae078 EKF: update get_mag_decl_deg()
Signed-off-by: CarlOlsson <carlolsson.co@gmail.com>
2019-03-13 08:14:23 +11:00
CarlOlsson 2b17ced405 EKF: Clean up use of magnetometer declination. Before the innovation was not zero in fuseDeclination()
Signed-off-by: CarlOlsson <carlolsson.co@gmail.com>
2019-03-13 08:14:23 +11:00
CarlOlsson 1d91785a8e EKF: correct quaternion order 2019-03-12 19:07:55 +11:00
CarlOlsson 000aa0de5d EKF: do not update the newest attitude estimate in initialiseFilter(). Is is now done in alignOutputFilter() 2019-03-12 19:07:55 +11:00
CarlOlsson 96c5c14041 EKF: Change the EKF initialization to
1) init tilt
2) init yaw
3) init tilt uncertainty
4) init yaw uncertainty

Signed-off-by: CarlOlsson <carlolsson.co@gmail.com>
2019-03-12 19:07:55 +11:00
CarlOlsson ea259d358d EKF: initialize the newest attitude estimate to a valid quaternion
Signed-off-by: CarlOlsson <carlolsson.co@gmail.com>
2019-03-12 19:07:55 +11:00
CarlOlsson 6cf512f103 EKF: Also update the newest and oldest quaternion estimate in
alignOutputFilter()

Signed-off-by: CarlOlsson <carlolsson.co@gmail.com>
2019-03-12 19:07:55 +11:00
CarlOlsson 78122b20a6 EKF: fix the rotation direction of the buffered attitude solutions
in alignOutputFilter()

Signed-off-by: CarlOlsson <carlolsson.co@gmail.com>
2019-03-12 19:07:55 +11:00
CarlOlsson 56b6b7a778 EKF: cleanup use of _mag_filt_state
Signed-off-by: CarlOlsson <carlolsson.co@gmail.com>
2019-03-12 19:07:55 +11:00
CarlOlsson 37339de57c EKF: remove unused variable
Signed-off-by: CarlOlsson <carlolsson.co@gmail.com>
2019-03-12 19:07:55 +11:00
Nuno Marques 4e0e68e905 Ekf: add more useful methods to interface with the covariances (#543) 2019-03-09 11:57:35 -05:00
Daniel Agar c66f7f4a09 EKF drop unused timestamp from collect_gps() and pass data by const reference 2019-03-05 17:26:19 -05:00
Freek van Tienen 78b899c72d Add Paparazzi compatibility (#580)
This adds support for the paparazzi autopilot to use this library as EKF.
The header order change has to be done in order to have std.h included to get certain defines at the start of the estimator_interface.h.
2019-03-05 12:41:21 -05:00
Daniel Agar 1378ec1797 EKF mag_fusion avoid unnecessary double promotion 2019-02-08 08:24:24 -05:00
Carl Olsson 54ab8191e3 EKF: add method to get the terrain variance 2019-02-06 08:49:16 -05:00
Daniel Agar c5554cae96 EKF tests update SWIG usage and use latest containers 2019-02-03 18:27:00 -05:00
Paul Riseborough dd58e69549 EKF: Ensure FW yaw alignment method is used on first in-air reset 2019-01-31 09:53:57 -05:00
Paul Riseborough 3accab1ac5 EKF: protect declination fusion from badly conditioned earth field estimates
Fusion with large initial magnetometer biases errors can result in the the NE earth field states reducing in magnitude and effectively flipping sign.

EKF: Move declination state limiting into a separate function

EKF: Limit NE mag states after each 3-axis mag fusion

EKF: Fix bug in mag field strength look-up scale factor
2019-01-31 09:53:57 -05:00
Paul Riseborough 7bddbd1cc5 EKF: Update cleaned up autocode fragment with sign error fix and missing LD 2019-01-31 09:53:57 -05:00
Paul Riseborough fe378fd761 EKF: Prevent unwanted declination fusion when re-starting 3-axis fusion 2019-01-31 09:53:57 -05:00
Paul Riseborough bd1647a7fb EKF: Rework use of fuseDeclination()
Simplify calling so that it is only called in two ways:
1) Immediately before 3-axis mag fusion if not called since the last earth field covariance reset so that the earth field declination information can be formed.
2) Immediately after 3-axis mag fusion otherwise.
2019-01-31 09:53:57 -05:00
Paul Riseborough d52f53635b EKF: Save mag field covariance data before reset 2019-01-31 09:53:57 -05:00
Paul Riseborough 82ce7a83a5 EKF: Save mag field covariance information on startup 2019-01-31 09:53:57 -05:00
Paul Riseborough 708c79eb8f EKF: Ensure mag field state covariance data is always available for re-use
Prevents use of  _saved_mag_ef_covmat and _saved_mag_bf_variance before being initialised or when stale.
2019-01-31 09:53:57 -05:00
Paul Riseborough 8839e4e1f4 EKF: Don't discard declination certainty information when resuming 3-axis fusion.
In the case where the EKF is switching between 3-axis and heading fusion, off-diagonal elements containing the correlation between N,E  components of the earth field were being lost on each switch event. These elements contained information about the declination uncertainty and should be preserved.
2019-01-31 09:53:57 -05:00
Paul Riseborough 25148e1b45 EKF: Prevent rapid changes in declination estimate after a reset
Ensures that each time the earth field covariance and variance data is reset, that the off-diagonal elements containing earth field declination angle certainty is restored.
2019-01-31 09:53:57 -05:00
CarlOlsson 6e7c119b31 EKF: limit yaw variance increase to 0.01 rad^2 to prevent a badly conditioned covariance matrix
Signed-off-by: CarlOlsson <carlolsson.co@gmail.com>
2019-01-31 09:53:57 -05:00
CarlOlsson 0896f7b9bd EKF: Also fill in lower part of covariance matrix in increaseQuatYawErrVariance()
Signed-off-by: CarlOlsson <carlolsson.co@gmail.com>
2019-01-31 09:53:57 -05:00
Paul Riseborough 4b3140e5f7 EKF: Fix rebase error 2019-01-31 09:53:57 -05:00
Paul Riseborough 911d4d8f49 EKF: Fix sign error in increaseQuatYawErrVariance function 2019-01-31 09:53:57 -05:00
Paul Riseborough a0b9cb002e EKF: Use consistent method for recording completion of in-flight yaw alignment 2019-01-31 09:53:57 -05:00
Paul Riseborough ef5a87c1d4 EKF: Rework quaternion yaw reset.
Use a new method that preserves the roll and pitch information and adds the uncertainty for yaw only.
Ensure that correlation information to non-quaternion states is removed when a reset occurs to prevent fusion of subsequent observations (e.g. GPS) causing incorrect yaw.
2019-01-31 09:53:57 -05:00
Paul Riseborough fc2a089823 EKF: Add function to un-correlate quaternion states
This is necessary after a quaternion reset to prevent incorrect attitude corrections with subsequent observation fusions.
2019-01-31 09:53:57 -05:00
Paul Riseborough bce1b96d17 EKF: Add function enabling yaw variance to be increased 2019-01-31 09:53:57 -05:00
Paul Riseborough bf1f3a224e EKF: Derive equations enabling yaw variance to be increased 2019-01-31 09:53:57 -05:00
Daniel Agar a5e6191ba7 EKF add clarity brackets to avoid potential confusion
- fixes https://github.com/PX4/ecl/issues/555
2019-01-30 09:15:53 -05:00
Anna Dai 721f5e61a5 increase optical flow buffer to imu buffer length 2019-01-17 10:23:15 +11:00
Anna Dai 44200e9649 add GPS drop out case to GPS fusion logic
EKF waits 10s after GPS signal is lost before setting GPS control status flag to false. As the position information given by the alternative position sources drifts from the last GPS position, the controller over corrects.
With this update, the time horizon until GPS control flag set to false is reduced and only alternative position source is used for estimation.

tested with optical flow as position souce

log from as is https://review.px4.io/plot_app?log=d624af5e-dde4-40ab-ba5b-a693a49f5a36

log with update https://review.px4.io/plot_app?log=13ed6dc3-22dd-43f8-b898-4add41d60439
2019-01-17 10:23:15 +11:00
CarlOlsson 8a813c57ec EKF: fix comment typo 2019-01-14 09:57:44 +11:00
CarlOlsson 472f2286b7 EKF: initialize covariances before we reset the heading in order to preserve the yaw uncertainty
Signed-off-by: CarlOlsson <carlolsson.co@gmail.com>
2019-01-14 09:57:44 +11:00
CarlOlsson 490888285d EKF: Remove flag prefix
Signed-off-by: CarlOlsson <carlolsson.co@gmail.com>
2019-01-13 23:48:46 +01:00
CarlOlsson d223680197 EKF: add flt_mag_align_complete to control_status flags
Signed-off-by: CarlOlsson <carlolsson.co@gmail.com>
2019-01-13 23:48:46 +01:00
Daniel Agar b920910483 replace <cfloat> with <float.h>
- <cfloat> isn't available in the NuttX c++ library
2019-01-06 12:09:05 -05:00
Paul Riseborough c032126745 EKF: Fix bug causing incorrect yaw variance value to be used
This bug causes the variance of the Z axis rotation vector uncertainty to not be reset to the correct value.
2019-01-04 11:01:06 +01:00
Paul Riseborough 48d83f3bcb EKF: Fix vulnerability to ground level mag anomally when using heading fusion (#544)
Previously, the reset of the yaw when climbing above 1.5m was not performed until 3-axis fusion was enabled. This could result in loss of navigation depending on the value of  EKF2_MAG_TYPE and the flight profile.
2019-01-03 09:41:55 -05:00
Hamish Willee 4822bf8386 Fix links to moved files in readme 2018-12-10 03:34:53 +01:00
CarlOlsson 1a969aed07 EKF: use low pass filtered mag measurements for heading initialization 2018-12-05 10:08:11 +01:00
Roman 27f7846495 optical flow: fixed sign in calculation of optical flow sensor velocity
- the velocity of the optical flow sensor relative to the IMU expressed in
body frame is the cross product of the angular velocity with the vector
from IMU to the sensor. If we use the angular velocity stored in the flow
sample struct we need to use a negative sign as that angular velocity
follows the opposite sign convention.

Signed-off-by: Roman <bapstroman@gmail.com>
2018-12-04 01:26:40 +11:00
Paul Riseborough c49ab760c7 EKF: Allow EKF to start without using mag data when not using earth frame data 2018-11-15 09:03:03 +11:00
Daniel Agar 572710ed27 EKF add typed Quatf getter 2018-11-14 22:50:39 +01:00
CarlOlsson 8a2e512c2d terrain_estimator: add vehicle_variance_scaler 2018-11-15 08:38:48 +11:00
Paul Riseborough acde4ebcc3 EKF: fix comment 2018-11-15 07:16:31 +11:00
Paul Riseborough df571202c5 EKF: Fix bug preventing saved declination being used for first alignment 2018-11-15 07:16:31 +11:00
Paul Riseborough 4657a9cd21 EKF: Ensure yaw gets reset when declination is set 2018-11-15 07:16:31 +11:00
Roman 68a3cbc368 addressed review comment
Signed-off-by: Roman <bapstroman@gmail.com>
2018-11-13 08:42:28 +11:00
Roman a74b7ef60b 3D only mag fusion: make sure _flt_mag_align_complete is set
- _flt_mag_align_complete was not set when choosing pure 3D mag fusion.
one effect of this was that the declination used in the filter was not
the one calculated from the magnetic field states.

Signed-off-by: Roman <bapstroman@gmail.com>
2018-11-13 08:42:28 +11:00
jie.zhang 10a0fef7b7 EKF/control: remove unnecessary yaw_align update 2018-10-17 15:50:00 -04:00
Daniel Agar 8bbaf898a5
EKF add new simple setIMUData() interface (#512) 2018-10-17 15:30:25 -04:00
Paul Riseborough e6cd6eff87 EKF: Fix bug preventing use of flow sensors without gyros
The handling of invalid flow data when on ground is performed in controlOpticalFlowFusion() where it is able to handle flow sensors that don't publish gyro data.
2018-10-11 07:12:54 +11:00
Paul Riseborough f240eaa5b0 EKF: Fix test script 2018-09-19 06:32:43 +10:00
Paul Riseborough 5cb228e1b3 EKF: Remove duplicate line 2018-09-19 06:32:43 +10:00
Paul Riseborough 0220f469b0 EKF: Use more generic variable name for bad yaw fusion flag
This flag now reports on  fusion of data that is not from a magnetometer.
2018-09-19 06:32:43 +10:00
Paul Riseborough eb52f7c410 EKF: Remove implicit conversion and use single precision trig operator
Double precision accuracy is not required for this operation.
2018-09-19 06:32:43 +10:00
Paul Riseborough 6847acb72e EKF: Add protection for undefined GPS antenna array heading offset 2018-09-19 06:32:43 +10:00
Paul Riseborough d1f3f4c916 EKF: Use #define function for isfinite check 2018-09-19 06:32:43 +10:00
Paul Riseborough 91f886cb5e EKF: Add support for use of GPS heading data.
Heading data is assumed to be from a  dual antenna array at a specified yaw angle offset in body frame, but with the heading data already corrected for antenna offset. The offset is required to apply the correct compensation for combined rotations and to determine when the yaw observation has become badly conditioned.
2018-09-19 06:32:43 +10:00
Paul Riseborough af60e6bbc8 EKF: Add derivation for for dual antenna yaw observations 2018-09-19 06:32:43 +10:00
Paul Riseborough 342c3ab202 EKF: Fix timeout parameter documentation and name
The parameter used to control the maximum dead reckoning time had 'gps' in the parameter name which was confusing because it was used for all measurement types capable of constraining horizontal velocity error growth. The parameter variable has been renamed and the documentation for it improved.
The parameter used to control the maximum time since fusing a measurement before the measurement is considered to be not contributing to aiding had misleading documentation which has been updated.
2018-09-19 06:32:43 +10:00
Dion Gonano 2354c30d81 Add vision height covariance passthrough (#507)
* Add vision height covariance passthrough

* Fix hgtErr layout
2018-09-11 06:36:13 +10:00
Kabir Mohammed a7245229cb EKF : Fix divergence when optical flow is not fused for a long time (#503)
* terrain_estimator : guard against case where latest range sample is newer than IMU sample

* EKF : control : correct detection of no optical flow fusion over a time period
2018-09-03 14:26:43 +10:00
Paul Riseborough b861594d0b EKF: enable optical flow use to bootstrap 2018-09-01 14:49:45 +02:00
Daniel Agar 0d39072a6d EKF add missing header guards 2018-08-30 12:07:25 -04:00
Kabir Mohammed a6a1edbe3f EKF : Fix type of flow data navigation variable (#499) 2018-08-30 18:26:17 +10:00
Paul Riseborough a53ad9c261 EKF: Add missing optical flow ground motion protection
Motion compensated optical flow rates are supposed to be zeroed if reported flow quality is below the minimum threshold value when on ground.
The comments and logic have been amended to be consistent and make the design intent clearer.
2018-08-28 21:31:50 +02:00
dakejahl 56b8bb08a1 added a checking for range_aid to determine if we are relying on the range finder as our primary source of height observation (#491) 2018-08-24 06:42:58 +10:00
Paul Riseborough 35f628e68f
EKF: Add interface to enable logging of GPS drift metrics (#490)
* EKF: Add interface to enable logging of GPS drift metrics

* EKF: Fix bug affecting rate of GPS drift publication

Also fix variable name.
2018-08-03 13:24:31 +10:00
Paul Riseborough 748446b92f EKF: Use parameter for stuck range test threshold
The default has been reduced to make it suitable for low altitude optical flow navigation.
2018-07-26 07:53:39 +02:00
Paul Riseborough 628079719f EKF: Fix inconsistency in timeout for terrain validity
Terrain validity is determined solely by successful range finder fusion and terrain state initialisation.
A range finder that has been declared faulty requires continuous range finder data fusion requires  data to be continuous before the fault status _rng_hgt_faulty  can be cleared. This will enforce the requirement for continuous data before fusion can commence.
2018-07-26 07:53:39 +02:00
Paul Riseborough d1d49857f9 EKF: Prevent stuck range checks running without new data 2018-07-26 07:53:39 +02:00
dakejahl 80146273ba removed if statement that would prevent the update of the _rng_hgt_faulty flag (#480) 2018-07-26 07:53:39 +02:00
Paul Riseborough 17d40478bb EKF: Rework range height validity checking
Eliminate race condition caused by checking for data freshness using time stamps from buffer push instead than buffer pop events.
Consistent use of range data ready and range data fault flags. This achieved by ensuring that _rng_hgt_faulty is set to true for all range data faults, not just data freshness.
Include range data validity requirement in rangeAidConditionsMet() check.
2018-07-26 07:53:39 +02:00
Paul Riseborough e0bcfeb533 EKF: Add validity boolean to mag declination accessor 2018-07-26 07:51:58 +02:00
Paul Riseborough 1e610894b9 EKF: Correct documentation and function name for declination accessor
The function name and documentation are misleading given the function is only a getter.
This change makes the usage clearer.
2018-07-26 07:51:58 +02:00
Paul Riseborough 4d01883f75 EKF: Disable GPS drift checks when the vehicle is moving. 2018-07-24 07:31:45 +02:00
Roman Bapst ee85a29202 Pr opt flow (#482)
* optical flow: fixed calculation of velocity of the flow sensor relative to
the IMU

- gyroXYZ holds a delta angle and first needs to converted to a gyro rate

Signed-off-by: Roman <bapstroman@gmail.com>

* optical flow: calculate height above the ground with respect to the flow
camera
- the flow camera can be offset from the IMU which needs to be considered

Signed-off-by: Roman <bapstroman@gmail.com>

* estimator interface: fixed comment regarding optical flow sample timestamp

- the timestamp on an optical flow sample corresponds to the trailing
edge of the flow integration period

Signed-off-by: Roman <bapstroman@gmail.com>
2018-07-16 11:41:35 +10:00
Paul Riseborough 4d59c834eb EKF: Consolidate range finder checking
This brings all the range finder data checks (excluding innovation consistency checks) into one place and eliminates the need to perform range checking external to the library.
The hard coded optical flow tilt limit is changed to use the same value as the range finder.
Variable names are changed to make a clear distinction between the max/min values calculated by the stuck range check and the max/min valid values for the sensor.
2018-07-12 18:20:50 +02:00
Kabir Mohammed e1661a92c3 EKF : allow init without external vision measurements (#464) 2018-07-12 11:36:47 +10:00
Paul Riseborough a0ed08967e EKF: Add missing range validity check 2018-07-11 14:53:37 +02:00
Daniel Agar 41953ab582 EKF angle constants in degrees for readability (#465)
* EKF angle constants in degrees for readability

* EKF make FILTER_UPDATE_PERIOD_MS static constexpr and add FILTER_UPDATE_PERIOD_S

* EKF controlOpticalFlowFusion() use constants and update comments

* EKF controlMagFusion() use angle in degrees

* EKF move earth spin rate to geo and update usage

* EKF: Fix numerical constant error and clean up comments

Comments do not need to contain numerical values when the code makes these clear.
2018-07-05 08:55:22 +10:00
Daniel Agar cebdc3d829 ekf run output predictor immediately with new IMU data (#471)
* EKF collect_imu take const imu sample and populate buffer

* EKF calculateOutputStates cleanup

* EKF add calculate_quaternion output predictor method

* EKF: update documentation

* EKF: remove unnecessary getter function

* EKF calculateOutputStates only apply dt correction to bias

* EKF pytest assert attitude validity, not update() return

* EKF: correct documentation

* EKF: Do not make attitude validity dependent on yaw alignment status

Yaw alignment could fail in flight due to temporary loss of data and yet the quaternions would still usable for stabilisation even though the absolute earth yaw angle wrt true north was uncertain.
2018-07-05 07:59:35 +10:00
Paul Riseborough 1cba257bac
Merge branch 'master' into pr-ekfOptFlowGyro 2018-06-18 09:36:16 +10:00
Paul Riseborough 1a1106878d
EKF: Prevent timestamp jitter failing GPS data arrival check (#462)
This fixes a error condition that occurs if _time_last_gps is greater than _time_last_imu.
By checking time stamps at the fusion time horizon, we guarantee that this cannot happen because all observations must have a time stamp smaller or equal to _imu_sample_delayed.time_us before they are retrieved from the buffers.
2018-06-15 16:03:54 +10:00
Roman c8af315aa7 flow_fusion: corrected sign of gyro data when it is taken from the ekf
gyro data

Signed-off-by: Roman <bapstroman@gmail.com>
2018-06-13 21:52:42 +02:00
Paul Riseborough c6ed2ccfcd EKF: Fix half frame offset in flow gyro compensation.
The gyro data accumulation needs to be across the same integration period as the flow sensor. The previous code didn't sample the accumulation until the midpoint of the flow data had fallen behind the fusion time horizon.

This PR changes the optical flow time stamp definition so that flow data is retrieved when the leading edge of the flow accumulation period falls behind the fusion time horizon. This enables the accumulated gyro data to be sampled at the correct time. Fusion is then delayed until the mid sample time has fallen behind the fusion time horizon.
2018-06-13 16:51:42 +10:00
Paul Riseborough 48561b0c8a EKF: Update optical flow interface documentation 2018-06-12 16:52:26 +10:00
Paul Riseborough de7c9d85a4 EKF: Handle flow data without valid gyro data 2018-06-12 16:24:25 +10:00
elia 26dcf05d80 keep ev timeout sign always positive 2018-06-11 00:17:19 +02:00
Paul Riseborough d177e96508 EKF: Fix bug causing slow drift when high rate flow data is used
High rate optical flow data could make flow fusion to run every major update cycle, resulting in the calculation of bias errors in the body rates used to compensate flow data failing time validity checks and not running. This resulted in a slow drift of the nav solution if bias errors were present in the in the gyro data used for flow sensor motion compensation.
2018-06-09 22:23:55 +02:00
Paul Riseborough ee2dc7d790 EKF: Rework optical flow selection logic
Fixes a race condition caused by the _is_dead_reckoning test.
Only checks flow selection when flow is available.
2018-06-09 22:23:55 +02:00
Paul Riseborough e383b6a272 EKF: rework optical flow selection logic
Make use of range aiding movement check clearer.
Fix logic errors that caused rapid toggling of flow use when on ground.
2018-06-09 22:23:55 +02:00
Paul Riseborough 487e6a0901 EKF: enable user selection of auto mag free operation
Also modify check to not apply if EV yaw is being used.
2018-06-09 22:23:55 +02:00
Paul Riseborough 6bdbe032f9 EKF: Fallback to optical flow for all in-flight loss of navigation scenarios 2018-06-09 22:23:55 +02:00
Mohammed Kabir b4d2b8c57d EKF : introduce new architechture for navigation limits 2018-06-09 22:23:55 +02:00
Paul Riseborough 8a713398cb EKF: Improve ground effect compensation
Start deadline at zero so that initial rotor wash effect is rejected.
2018-06-09 22:23:55 +02:00
Paul Riseborough 39697f1196 EKF: rework optical flow switching 2018-06-09 22:23:55 +02:00