229 Commits

Author SHA1 Message Date
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
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
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
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
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
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
Paul Riseborough
5cb228e1b3 EKF: Remove duplicate line 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
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
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
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
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
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
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
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
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
39697f1196 EKF: rework optical flow switching 2018-06-09 22:23:55 +02:00
Paul Riseborough
1cfe845751 EKF: rework GPS quality check 2018-06-09 22:23:55 +02:00
Paul Riseborough
99a80387ed EKF: improve optical flow GPS quality checking 2018-06-09 22:23:55 +02:00
Paul Riseborough
f59cd0f5b0 EKF: Don't make detection of indoor operation dependent on optical flow
This is required because it can take several seconds for an optical flow sensor operation to be confirmed and there are also many use cases for indoor operation where no optical flow is used.
2018-06-09 22:23:55 +02:00
Paul Riseborough
ea9e8246ed EKF: Improve detection of indoor flight condition 2018-06-09 22:23:55 +02:00
Paul Riseborough
2d3b65231b EKF: Reset yaw gyro bias learning when resuming use of magnetometer
The previous lack of yaw drift constraint will also mean that the yaw gyro bias estimate is likely to be incorrect and needs to be re-learned.
2018-06-09 22:23:55 +02:00
Paul Riseborough
8191068959 EKF: Don't start using mag if optical flow use is interrupted
If magnetometer use is being inhibited because an indoor condition has been detected (optical flow and poor or no GPS) and the optical flow fusion checks fail causing the EKF to stop navigating, we do not want the EKF to start using the magnetometer.
2018-06-09 22:23:55 +02:00
Paul Riseborough
4889e8432c EKF: Don't fuse multi rotor drag if yaw angle is bad 2018-06-09 22:23:55 +02:00
Paul Riseborough
092a8d8f21 EKF: Fix GPS validity time check error 2018-06-09 22:23:55 +02:00
Paul Riseborough
0160aaa568 EKF: Don't use magnetometer with optical flow only nav if GPS checks are failing 2018-06-09 22:23:55 +02:00
Paul Riseborough
bf902e5eca EKF: Prevent flow motion check false positives
The previous implementation could false trigger if there was significant vibration below 200Hz during startup.
2018-05-09 07:47:17 +10:00
Paul Riseborough
e26711af7d EKF: relax terrain update requirements for continuing optical flow use 2018-05-08 08:43:14 +10:00
Paul Riseborough
02963a85c4 EKF: relax optical flow on ground motion checks 2018-05-08 08:43:14 +10:00
Paul Riseborough
24b005ed57 EKF: range finder aiding logic fixes 2018-05-08 08:42:29 +10:00
Paul Riseborough
0c0a6602b0 EKF: Decouple range finder use criteria checking and selection 2018-05-08 08:42:29 +10:00
Paul Riseborough
6708bec1b4 EKF: Don't auto select range finder for height when on ground. 2018-05-08 08:42:03 +10:00