Commit Graph

225 Commits

Author SHA1 Message Date
priseborough e4c969084d AP_NavEKF: Improve behaviour recovering from a GPS timeout
When regaining GPS after a timeout, an offset is applied when fusing  GPS velocity so that GPS velocity and position data as fused by the EKF is kinematically consistent.
This velocity offset is also accounted for when fusing air data so that wind estimates are not corrupted when the GPS position offset is being pulle back to zero.
The intended behaviour is that the EKF position will be pulled back to the GPS position at a rate of 5m/s for planes and 1 m/s for copters. This avoids large deviations in trajectory when GPS is regained.
2014-12-31 13:13:50 +09:00
priseborough 3891dada78 AP_NavEKF: remove unnecessary function 2014-12-31 13:13:44 +09:00
priseborough a42100e4c5 AP_NavEKF: Improved handling of no GPS
This patch enables indoor operation of the EKF by putting it into static mode if optical flow operation is not enabled and no GPS is available
2014-12-31 13:13:40 +09:00
priseborough 4eb19c2324 AP_NavEKF: Rationalise health status reporting
1) Un-used public methods to report height and position drifting have been removed
2) A time-out has been added to the airspeed innovation consistency check so that if we are relying on airspeed to constrain velocity drift, a filter divergence or other fault that causes the airspeed to be continually rejected will trigger a change in health status.
3) A timeout of velocity, position or height measurements does not cause a filter fault to be reported. Timeouts can be due to sensor errors and do not necessarily indicate that the filter has failed.
4) Time-outs of various measurements are used to present a consolidated bitmask which inidicates which parts of the solution can be used, eg attitude, height, velocity, relative position, absolute position, etc.
2014-12-31 13:13:31 +09:00
priseborough a2bd3b4a42 AP_NavEKF: Add public method returning height above ground level 2014-12-06 18:16:51 +11:00
priseborough d994da0886 AP_NavEKF: Expand EKF speed limit public method to handle control limits 2014-12-06 18:16:50 +11:00
priseborough bc2255d6b1 AP_NavEKF: Improve comments in setInhibitGPS public method 2014-12-06 18:16:50 +11:00
priseborough b56b68ce10 AP_NavEKF: Add public method reporting horizontal speed limit
This is required if using optical flow, as depending on height, the speed must be limited to prevent the sensor saturating
2014-12-06 18:16:50 +11:00
priseborough 083e22966c AP_NavEKF: Add public method to report available output data 2014-12-06 18:16:49 +11:00
priseborough e53d28854e AP_NavEKF: Add public method to inhibit GPS use and clean-up GPS use logic
This provides the calling vehicle software the abiity to request the EKF to not use GPS.
An integer is returned that indicates the type of operation available:
0 = request rejected (request will only be accepted if the EKF is in static mode, eg pre-armed)
1 = request accepted, attitude, vertical velocity and position estimates available
2 = request accepted, attitude, height rate, height, horizontal velocity and relative position estimates available
2014-12-06 18:16:49 +11:00
priseborough 8fb1d9cf8d AP_NavEKF: Fix bug preventing opt flow scale factor estimation
Also removes un-used variable declarations
2014-12-06 18:16:49 +11:00
priseborough a78920761c AP_NavEKF: Update comments in flow data interface 2014-12-06 18:16:49 +11:00
priseborough 52c7e56a4a AP_NavEKF: Add parameter for max valid optical flow rate magnitude 2014-12-06 18:16:49 +11:00
priseborough 0bf991eef9 AP_NavEKF: Fix bug in optical flow fusion smoothing 2014-12-06 18:16:48 +11:00
priseborough 517026980b AP_NavEKF : Add fault and timeout logging 2014-12-06 18:16:47 +11:00
priseborough 06c19a3a4d AP_NavEKF : Update optical flow debug logging 2014-12-06 18:16:47 +11:00
priseborough 1791dec622 AP_NavEKF : Fix velocity hold mode 2014-12-06 18:16:47 +11:00
priseborough 8faeb190de AP_NavEKF : Rework logic to cope with bad flow data 2014-12-06 18:16:46 +11:00
priseborough 41f0231cfb AP_NavEKF : improve logic dealing with lack of flow or range data 2014-12-06 18:16:46 +11:00
priseborough 4c92a5f23f AP_NavEKF : Use GPS velocity if PX4Flow sensor fails 2014-12-06 18:16:46 +11:00
priseborough 283811edcb AP_NavEKF : stop velocity change when flow measurements drop out 2014-12-06 18:16:46 +11:00
priseborough 117bd2a998 AP_NavEKF : Add time based noise to terrain offset state 2014-12-06 18:16:45 +11:00
priseborough 8dd1081f54 AP_NavEKF : Add range measurement to EKF debug message 2014-12-06 18:16:45 +11:00
priseborough a20729f60f AP_NavEKF : Update names in optical flow debug logging 2014-12-06 18:16:45 +11:00
priseborough 235b3bebda AP_NavEKF : Add range finder health and enable range finder fusion
The 2-state auxiliary filter is also renamed.
2014-12-06 18:16:45 +11:00
priseborough 988de2a898 AP_NavEKF : Add smoothing to optical flow fusion 2014-12-06 18:16:44 +11:00
priseborough 81b09c9361 AP_NavEKF : temporary mods to test use of flow sensor internal gyro data 2014-12-06 18:16:44 +11:00
priseborough cd418c946c AP_NavEKF : preliminary implementation for optical flow and range finder fusion
Range finder measurements are not input to EKF at this time, however the method for fusing them is
implemented.
2014-12-06 18:16:44 +11:00
Jonathan Challinger 7692761f34 AP_NavEKF: Added getAccelNED function 2014-12-05 19:40:01 +09:00
priseborough 874d0780aa AP_NavEKF: Reduce vulnerability to ground fixed magnetic interference
Re-initialisation of the magnetic field states and yaw angle is now only performed a maximum of two times after start-up.

Once when coming out of static modefor the first time (first arm event)
Again (for copter only) when the altitude gain above the arming altitude exceeds 1.5m

this prevents magnetic interference present at arming (eg arming on a metal roof)from corrupting the magnetic field states enough to cause bad heading errors and toilet bowling on copter
2014-12-05 14:33:04 +11:00
Andrew Tridgell 46f601d703 AP_NavEKF: added getStaticMode() function 2014-11-22 18:27:51 +11:00
priseborough 5359da9c68 AP_NavEKF : Improved Magnetometer Error Handling
(Plane Only) If the yaw and GPS heading disagree by more than 45 degrees on takeoff, then the magnetometer is declared as failed. The heading is then reset based on the difference between GPS ground track and stgate velocity vector.
Magnetometer fusion uses corrected data and bias states are initialised to zero. This allows the compass to be switched in flight.
For persistent compass errors that trigger a timeout, the compass is not permanently failed, however for non-forward fly vehicles the compass weighting is reduced.
2014-11-14 10:34:48 +11:00
Jonathan Challinger 6c4d4713aa AP_NavEKF: Add parameter that specifies EKF-to-DCM/INAV fallback strictness 2014-11-06 10:03:52 +11:00
Jonathan Challinger 967986d5c6 AP_NavEKF: Split getAccelBias into getAccelZBias and getIMU1Weighting 2014-10-30 18:17:38 +11:00
Jonathan Challinger 0727ac5c79 AP_NavEKF: clean up unused variable lastDivergeTime_ms 2014-10-30 18:17:37 +11:00
priseborough 5e51c09978 AP_NavEKF : Remove ineffective numerical divergence checks 2014-10-30 18:17:37 +11:00
priseborough fb14da7a4b AP_NavEKF : Add public method to reset gyro bias states 2014-10-29 15:32:21 +09:00
priseborough b61a6c64d7 AP_NavEKF : Reduce weighting on GPS when not enough satellites
GPS measurement variance is doubled if only 5 satellites, and quadrupled if 4 or less.
The GPS glitch rejection thresholds remain the same
This will reduce the impact of GPS glitches on attitude.
2014-10-01 12:55:29 +10:00
priseborough 36bf304f29 AP_NavEKF : Reduce ripple in estimates that can cause copter motor 'pulsing'
This patch reduces the level of 5Hz and 10Hz 'pulsing' heard in motors due to GPS and altimeter fusion which cause a small 5Hz and 10Hz ripple on the output under some conditions. Attitude, velocity and position state corrections from GPS, altimeter and magnetometer measurements are applied incrementally in the interval from receiving the measurement to the predicted time of receipt of the next measurement. Averaging of attitude state corrections is not performed during periods of rapid rotation.
2014-09-17 10:22:49 +09:00
priseborough 5b72cb7610 AP_NavEKF : Clean up time stamps
Time stamps are now explicitly initialised to the current IMU time to avoid unwanted activation of timeout logic on filter start and various calls to the hal.scheduler->millis() object have been consolidated.
2014-09-17 10:22:45 +09:00
Andrew Tridgell 5d40ec8014 AP_NavEKF: make use_compass() public 2014-08-24 21:00:24 +10:00
priseborough d5442fe64e AP_NavEKF : Modified compass fail logic
If the vehicle can fly without a compass (a fly forward vehicle)
then if the compass times out (large errors for more than 10 seconds,
then it will be declared permanently failed and will not be
used until the filter is reset
2014-07-31 21:12:11 +10:00
Emile Castelnuovo 946a461873 VRBRAIN: added VRBRAIN to #if 2014-06-19 11:27:44 +02:00
Andrew Tridgell 5edf4ba596 AP_NavEKF: fixed up handling of bitfields in faultStatus
Pair-Programmed-With: Paul Riseborough <p_riseborough@live.com.au>
2014-05-15 21:42:39 +10:00
priseborough ce8e1daa16 AP_NavEKF: Improved divergence detection and reset
Divergence is now detected by looking for very large changes in the gyro
bias. This will cause the filter to be reset and declared unhealthy for
10 seconds.

Don't reset filterDiverged status immediately during reset

Set filterDiverged true if covariance blows up

Add fault status reporting
2014-05-15 21:14:21 +10:00
priseborough 925c5751bd AP_NavEKF: Add ability to inhibit in-flight mag cal and clean up moding
This will enable in-flight magnetometer calibration to be inhibited unconditionally,
This is required for long balloon carriage flights where ground speed can be high
enough to put it into in-air state, but with very poor observability of magnetic field
states causing bad state estimates and heading offsets to develop over time.

The covariance matrix no longer has rows and columns artificially zeroed when in static
mode. Instead booleans indicating whether wind or magentic field state estimation is
active are used to:

a) Set the process noise on these states to zero to stop their variances from increasing
unchecked when not being updated, and
b) Turn off updates for these states when measurement fusion is being performed.

This reduces the likelihood of a badly conditioned covariance matrix forming
during static mode operation.

A filter divergence check has also been added that will declare the filter unhealthy if
position, velocity and magnetic field observations are all failing their innovation
consistency checks. This unhealthy status will persist for 10 seconds after the
condition clears.

AP_NavEKF: Remove unnecessary zeroing of wind covariances
2014-05-11 18:00:38 +10:00
priseborough ecc8e45eda AP_NavEKF: Fix bug in position reset logic 2014-04-23 18:16:02 +10:00
Andrew Tridgell 25667a11a0 AP_NavEKF: use AHRS vehicle class for sideslip calculation
Pair-Programmed-With: Paul Riseborough <p_riseborough@live.com.au>
2014-04-21 18:13:12 +10:00
Andrew Tridgell 5acd17b843 AP_NavEKF: cleanup some build warnings
Pair-Programmed-With: Paul Riseborough <p_riseborough@live.com.au>
2014-04-21 18:13:12 +10:00
priseborough bd28cdbdcf AP_NavEKF: Improved magnetometer consistency checks
A magnetometer axis that fails the innovation consistency check will cause
all axes not to be used. If this condition continues for 10 seconds, a
magnetometer timeout condition will be declared. When the timeout has
occurred, if it is not a fly forward vehicle, then individual channels
will be used again, but with a reduced weighting.
2014-04-21 16:31:31 +10:00
priseborough 188bea6bab AP_NavEKF : Enable calc of wind velocity when not using airspeed sensing
This patch also cleans up the logic associated with use of the synthetic
sideslip measurement so that it can never be used for a non fly-forward
vehicle type

This patch adds functionality that initialises the wind-speed vector to the
reciprocal of the ground speed vector, and scaled to 6 m/s. On average this gives
a better initial wind velocity estimate on launch by assuming:

a) launch will be into wind
b) wind speed is equal to global average

It also helps prevent a headwind causing initial underestimation of airspeed
causing high autopilot gains and limit cycles on climb-out, until first
turn when the EKF is able to estimate the wind.
2014-04-13 19:37:19 +10:00
Emile Castelnuovo 25f1c5774f AP_NavEKF: added #defines for VRBRAIN board 2014-04-08 16:19:19 +10:00
Andrew Tridgell 07d621c4be AP_NavEKF: used state structure in more places
makes the code a bit easier to read

Pair-Programmed-With: Paul Riseborough <p_riseborough@live.com.au>
2014-04-04 21:30:16 +11:00
Andrew Tridgell cd3038fabd AP_NavEKF: fixed return of offset in getVariances() 2014-04-03 07:49:06 +11:00
priseborough 04036d7777 AP_NavEKF : Updated GPS glitch protection logic
This adds new functionality to the detection and compensation of GPS
glitches:

1) A maximum allowable innovation is calculated using the GPS noise
parameter multiplied by the gate, with an additional component allowing
for growth in position uncertainty due to acceleration error since
the last valid measurement
2) Includes per vehicle type values for the acceleration error limit
3) If the innovation length exceeds the maximum allowable, no fusion occurs
4) If no fusion has occurred for long enough such that the position uncertainty
exceeds the maximum set by a per vehicle parameter or a maximum time, an offset
is applied to the GPS data to so that it matches the value predicted by the filter
5) The offset is never allowed to be bigger than 100m
6) The offset is decayed to zero at a rate of 1.0 m/s to allow GPS jumps to
be accommodated gradually
7) The default velocity innovation gate has been tightened up for copter and rover
8) The variance data logging output has been updated to make it more useful
2014-04-01 21:22:14 +11:00
priseborough 17cdac7bc8 AP_NavEKF : Clean up angle and mag field initialisation
This path reduces duplicated code, eliminates unused variables and
causes the earth magnetic field states to be reset when exiting static mode
which will occur every time copter is armed. This enables copters to be
powered on and initialised inside vehicles or houses, without bad earth
field values affecting flight.
2014-03-24 19:54:48 +11:00
Paul Riseborough f7007569d1 AP_NavEKF : Fix bug that limits copter sensor delay compensation to 125
msec
2014-03-21 21:52:20 +11:00
Paul Riseborough 35811758d7 AP_NavEKF : Update comments and remove un-used function declarations 2014-03-14 06:07:57 +11:00
Paul Riseborough 7b3130cfcc AP_NaVEKF : Enable operation without airspeed and compass 2014-03-10 21:53:09 +11:00
Paul Riseborough 3a5acb9cea AP_NavEKF : improved on-ground, in-air check and GPS yaw alignment 2014-03-10 14:07:34 +11:00
Paul Riseborough b47a11edf6 AP_NavEKF : improved static and on-ground mode selection logic 2014-03-10 04:39:59 +11:00
Paul Riseborough 2019708056 AP_NavEKF : Make all compass use autodetect 2014-03-09 19:59:19 +11:00
Paul Riseborough e485b246e7 AP_NavEKF : update comments 2014-03-09 19:59:18 +11:00
Paul Riseborough c8bd415b00 AP_NavEKF : Add sideslip constraint to allow plane flight without magnetometer 2014-03-09 19:59:17 +11:00
Paul Riseborough 52fabc822f AP_NavEKF : Add low speed magnetometer calibration option 2014-03-09 19:59:16 +11:00
Andrew Tridgell 449d09051e AP_NavEKF: cope with compass going offline while in flight 2014-03-02 14:32:10 +11:00
Paul Riseborough bd152d332c AP_NavEKF : Add accel aliasing protection 2014-03-02 08:10:04 +11:00
Paul Riseborough 5db9a87d31 AP_NavEKF : fixed bug in velocity rate of change filter
This bug meant the velocity rate of change used to scale the GPS measurement variances was noisy and too small
2014-02-23 19:50:37 +11:00
Paul Riseborough 89e0b48320 AP_NavEKF : Bug fix for height drift due to timer wrap-around 2014-02-23 19:50:35 +11:00
Andrew Tridgell 4e56196655 AP_NavEKF: allow states to be accessed using names as well as a Vector22 2014-02-21 20:24:47 +11:00
Andrew Tridgell c9d0c1face AP_NavEKF: use ahrs->get_armed() for static mode demanded 2014-02-19 10:52:57 +11:00
Andrew Tridgell 536160a3fb AP_NavEKF: use AHRS get_correct_centrifugal() 2014-02-19 10:28:45 +11:00
Andrew Tridgell 869e41fd03 AP_NavEKF: fixed detection of airspeed sensor
the get_airspeed() AHRS call can change as the user enables/disables
the airspeed sensor, plus it only gets enabled after the NavEKF
constructor runs.
2014-02-19 09:22:45 +11:00
Paul Riseborough 1ade39977a AP_NavEKF : covariance prediction cleanup 2014-02-19 09:22:45 +11:00
Paul Riseborough 8daca145d0 AP_NavEKF : useAirspeed set automatically 2014-02-19 09:22:45 +11:00
Paul Riseborough 6fbada26d3 AP_NavEKF : Improvements to staticMode robustness 2014-02-19 09:22:45 +11:00
Paul Riseborough b22dc706b2 AP_NavEKF : staticMode bugfix and robustness improvements 2014-02-16 21:04:55 +11:00
Paul Riseborough b56c8211c9 AP_NavEKF: Reduced number of Mavlink tuneable parameters 2014-02-15 05:48:23 +11:00
Paul Riseborough c20fac1269 AP_NavEKF: Updated comments for private functions 2014-02-15 05:48:23 +11:00
Paul Riseborough deb64c4cbd AP_NavEKF: Pos Vel reset after long GPS timeout 2014-02-15 05:48:23 +11:00
Paul Riseborough 80f6dba694 AP_NavEKF: Improved control of fusion update intervals 2014-02-15 05:48:23 +11:00
Paul Riseborough 13b9daeff5 AP_NavEKF: Added constraints to Mavlink tuneable parameters 2014-02-15 05:48:23 +11:00
Paul Riseborough b123e1bb16 AP_NavEKF: Improved in-air reset behaviour 2014-02-15 05:48:22 +11:00
Paul Riseborough 1651980b9f AP_NavEKF: Improved behaviour following loss and regaining of GPS 2014-02-15 05:48:22 +11:00
Paul Riseborough 14eb63e7c9 AP_NavEKF: Made most tuning parameters Mavlink adustable 2014-02-15 05:48:22 +11:00
Andrew Tridgell f800f5592d AP_NavEKF: fixup parameter handling 2014-02-15 05:48:22 +11:00
Paul Riseborough f0f76920fa AP_NavEKF : Mavlink tunable parameter - first attempt 2014-02-15 05:48:22 +11:00
Paul Riseborough 128f71157d AP_NavEKF: Fixed bug in pre GPS fix updates 2014-02-15 05:48:22 +11:00
Paul Riseborough 5219869389 AP_NavEKF : Added Z accel bias state and bootstrap initialisation method 2014-02-15 05:48:21 +11:00
Randy Mackay 7c73020015 AP_NavEKF: make params public so they can be tuned 2014-02-15 05:48:20 +11:00
Paul Riseborough 5c3dea28dc AP_NavEKF : Enable staticMode to be set externally 2014-02-15 05:48:20 +11:00
Paul Riseborough 2f3b2a7111 AP_NavEKF: second attempt at higher rate baro fusion 2014-02-15 05:48:19 +11:00
Paul Riseborough da2c341914 Revert "AP_NavEKF: Modifed Vel Pos fusion to fuse height data whenever baro reading has changed"
This reverts commit d1e1be192a0e7ab0771edc9f2c03547da25697cf.
2014-02-15 05:48:19 +11:00
Paul Riseborough 32cc427ff4 AP_NavEKF: Modifed Vel Pos fusion to fuse height data whenever baro reading has changed 2014-02-15 05:48:19 +11:00
Paul Riseborough 2998aa1a6a AP_NavEKF: Amended tuning parameter list, and changed from variance to noise definitions 2014-02-15 05:48:19 +11:00
Paul Riseborough 619fffec3e AP_NavEKF: added static mode for pre-arm and bench testing 2014-02-15 05:48:18 +11:00
Paul Riseborough d0831c708d AP_NavEKF : Added position and height reset public method 2014-02-15 05:48:18 +11:00
Andrew Tridgell 4c42f53636 AP_NavEKF: use INS delta_time 2014-02-15 05:48:17 +11:00
Paul Riseborough 6e6e3d923e AP_NavEKF: improved covariance matrix numerical stability protection 2014-02-15 05:48:16 +11:00
Andrew Tridgell 66dbaa6657 AP_NavEKF: make health() API const 2014-02-15 05:48:16 +11:00
Paul Riseborough 4a56ea84b5 AP_NavEKF: Removed accel bias states 2014-02-15 05:48:15 +11:00
Andrew Tridgell 2acf1e7ce5 AP_NavEKF: allow filter to run as single or double precision
useful for checking if there are numerical precision issues
2014-02-15 05:29:48 +11:00
Paul Riseborough efd444b02e AP_NavEKF: covariance protection (not enabled) and tuning changes for stability 2014-02-15 05:29:48 +11:00
Andrew Tridgell ee774f69d0 AP_NavEKF: fixed some time handling bugs
use get_delta_time() and removed broken time wrap code
2014-02-15 05:29:48 +11:00
Andrew Tridgell 95c5aeaa43 AP_NavEKF: removed more unused variables 2014-02-15 05:29:47 +11:00
Andrew Tridgell 91cbad52a1 AP_NavEKF: handle conversion of AHRS to handle altitude
fixed accuracy of position for cm level lat/lng
2014-02-15 05:29:47 +11:00
Andrew Tridgell 9ef71a9dec AP_NavEKF: added healthy() API 2014-02-15 05:29:46 +11:00
Andrew Tridgell 2c86a490ed AP_NavEKF: make it possible for NavEKF to be a AHRS member
ready for AHRS integration
2014-02-15 05:28:09 +11:00
Paul Riseborough 6f31961fb5 AP_NavEKF: Added height rate adaptive wind speed process noise 2014-02-15 05:28:09 +11:00
Paul Riseborough de884dabab AP_NavEKF: brought some tuning parameters out to header 2014-02-15 05:28:09 +11:00
Paul Riseborough 2f95685bfc Plane : EKF data logging fixes 2014-02-15 05:28:09 +11:00
Paul Riseborough 6b9733c013 AP_NavEKF : Additional flash logging 2014-02-15 05:28:09 +11:00
Paul Riseborough c28e89e4b7 AP_NavEKF: bug fixes for height fusion and covariance initialisation 2014-02-15 05:28:08 +11:00
Paul Riseborough 2c567cd721 AP_NavEKF: Added tuning parameter for onGround yaw gyro variance 2014-02-15 05:28:08 +11:00
Paul Riseborough 63d8b1bb0b AP_NavEKF: Scheduler Improvements 2014-02-15 05:28:07 +11:00
Andrew Tridgell df42dd691c AP_NavEKF: added perf counters on PX4 2014-02-15 05:28:07 +11:00
Andrew Tridgell 3d6cb9eade AP_NavEKF: use float arrays when not doing bounds checking
g++ is doing a lousy job of inlining VectorN, so avoid it when we
don't need bounds checking for production code
2014-02-15 05:28:07 +11:00
Paul Riseborough 406fb31a57 AP_NavEKF: Load levelling scheduler - first attempt 2014-02-15 05:28:07 +11:00
Andrew Tridgell 163cfd839d AP_NavEKF: enable airspeed and fix getLLH() 2014-02-15 05:28:07 +11:00
Andrew Tridgell 0b71618f4f AP_NavEKF: use vectorN to make indexes safe 2014-02-15 05:27:53 +11:00
Paul Riseborough fca1090694 AP_NavEKF: debug updates 2014-02-15 05:27:53 +11:00
Andrew Tridgell ffce1f64cc AP_NavEKF: added euler angle functions 2014-02-15 05:27:52 +11:00
Paul Riseborough 361bb5b18f AP_NavEKF: Updated comments in header file 2014-02-15 05:27:52 +11:00
Andrew Tridgell eb505eef91 AP_NavEKF: fixed build for APM environment 2014-02-15 05:27:52 +11:00
Paul Riseborough 0dd5463e77 AP_NavEKF : Changed file and variable names 2014-02-15 05:27:52 +11:00