Commit Graph

63 Commits

Author SHA1 Message Date
kamilritz 9e6d27fafb Add missing const qualifier 2020-01-08 09:00:31 +01: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
Daniel Agar 98a1aae494 EKF: use Matrix cross product 2019-12-17 09:35:08 +01:00
kamilritz 07e804676c Rename IMU biases 2019-12-05 20:09:34 +11:00
kamilritz d5dc6bb8ea Clean get*innov* interface 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 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
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
Nico van Duijn c446ee444a EKF: fake rng if faulty on ground 2019-09-18 10:15:37 +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 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
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
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
Carl Olsson f0889c1760 EKF: fixed some comment typos
Signed-off-by: CarlOlsson <carlolsson.co@gmail.com>
2019-03-18 10:20:33 -04: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
CarlOlsson 8a2e512c2d terrain_estimator: add vehicle_variance_scaler 2018-11-15 08:38:48 +11: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 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 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 fc9f532c34 EKF: relax range finder data continuity check 2018-06-09 22:23:55 +02:00
Paul Riseborough 225057aaf5 EKF: Fix bug preventing use of terrain estimator 2018-06-09 22:23:55 +02:00
Paul Riseborough 868bc01087 EKF: Relax minimum required range finder measurement rate 2018-05-08 08:43:14 +10:00
Daniel Agar c5b2f59f57 PX4 style fixes (excluding EKF generated code) 2018-05-03 22:25:36 -04:00
Paul Riseborough 02055acee2
EKF: Fix non GPS aiding data reset logic (#418)
* EKF: Move optical flow specific state reset to helper functions

* EKF: Ensure loss of optical flow aiding is handled correctly

If data is only source of aiding and has been rejected for too long - reset using flow data as a velocity reference.
If flow data is unavailable for too long - declare optical flow use stopped.
Use consistent time periods for all resets

* EKF: Ensure loss of external vision aiding is handled correctly

If data is only source of aiding and has been rejected for too long - reset using data as a position.
Don't reset velocity if there is another source of aiding constraining it.
If data is unavailable for too long, declare external vision use stopped.
Use consistent time periods for all resets.

* EKF: Update parameter documentation

Make the distinction between the no_gps_timeout_max and no_aid_timeout_max parameters clearer

* EKF: make class variable units consistent with documentation

* EKF: Don't reset states when optical flow use commences if using external vision

* EKF: Stop optical flow fusion when on ground if excessive movement is detected.

* EKF: fix terrain estimator vulnerabilities

Reset estimate to sensor value if rejected for 10 seconds
Protect against user motion when on ground.
Fix unnecessary duplication of terrain validity check and separate validity update and reporting.

* EKF: remove unnecessary Info console prints

Optical flow use information can be obtained from the estimator_status.control_mode_flags message

* EKF: fix inaccurate comment

* EKF: remove duplicate calculation from terrain validity accessor function
2018-04-09 18:35:15 +10:00
Daniel Agar cd12f049fe move geo and geo_lookup from PX4 Firmware to ECL 2018-03-26 21:52:11 -04:00
Carl Olsson f6d23cc621 added rng_stuck to filter control status flags (#392) 2018-03-21 11:46:27 +11:00
Daniel Agar ed9a394029
EKF RingBuffer avoid copying 2017-11-15 18:08:51 -05:00
ChristophTobler e388e59f32 EKF: use uint64_t cast for XeY to avoid float casting of variables
The default type for XeY is float
2017-11-08 11:40:26 +01:00
Paul Riseborough 4db23b7b2e EKF: Don't report terrain estimate invalid immediately when HAGL observations fail checks 2017-10-12 08:26:04 +11:00
CarlOlsson 0a7c3ecbc6 EKF: Parameterize maximum angle for rng fusion 2017-09-26 20:53:48 +02:00
ChristophTobler 8ecec58292 Check for stuck range finder measurements in terrain estimator 2017-07-31 17:59:44 +02:00
ChristophTobler 61a7991693 constrain _terrain_vpos to be a minimum of _params.rng_gnd_clearance larger than _state.pos(2) 2017-07-20 08:29:11 +02:00
Paul Riseborough e1fe5b2229 Revert "Revert "Split get_terrain_vert_pos() into valid and get_vpos"" 2017-07-19 17:52:35 +10:00
Paul Riseborough c887b02f21 Revert "Split get_terrain_vert_pos() into valid and get_vpos" 2017-07-19 17:33:48 +10:00
ChristophTobler eae0522dc2 split into get_terrain_valid and get_terrain_vert_pos 2017-07-17 16:42:42 +02:00
ChristophTobler d2945abd85 return hagl valid false if update was rejected 2017-07-13 14:17:48 +02:00
Roman 7e2597ec28 update range sensor angle parameters in case they have changed
Signed-off-by: Roman <bapstroman@gmail.com>
2017-02-22 14:12:05 +01:00
Roman aa53f45f15 terrain estimator: removed unused hrt dependancy
Signed-off-by: Roman <bapstroman@gmail.com>
2017-02-22 14:12:05 +01:00
Roman 6480fcc3d5 terrain estimator: fixed computation of filtered time since last range update
- do not use hrt to compute delta time
- limit filter state
- do not use static variables

Signed-off-by: Roman <bapstroman@gmail.com>
2017-02-22 14:12:05 +01:00
Paul Riseborough 6561edb9a5 EKF: Clean up terrain estimation functionality.
This is a functionally equivalent. It moves all of the code for the terrain estimator into a single function call from the main filter update, making it clear that it is independent of the main filter.
2017-02-22 14:12:05 +01:00
devbharat 8004e9fe7e EKF: Make range finder data continuous check more robust
Use a filtered arrival time delta to determine if range data is continuous
2017-02-22 14:12:05 +01:00
Paul Riseborough d94068b88a EKF: Simplify calculation of height above terrain observation variance
The tilt compensation being applied previously was based on a flat earth geometric model assuming perfect tilt knowledge which reduces the effect of range errors on height error as the vehicle tilts. however in the real world, variations in terrain gradient and uncertainty in vehicle tilt and sensor alignment tend to increase height error with tilt, so the adjustment of observation variance with tilt has been removed given we do not have a valid mathematical model on which to base it.
2017-02-22 14:12:05 +01:00
Paul Riseborough 3dadc98b43 EKF: enable scaling of range observation variance with height 2017-02-22 14:12:05 +01:00
Paul Riseborough cf9c8de167 EKF: Add arbitrary pitch offset for range sensor 2017-02-22 14:12:05 +01:00