Commit Graph

286 Commits

Author SHA1 Message Date
Paul Riseborough 38d61f5281 AP_NavEKF2: Update status reporting to handle no-magnetometer startup 2016-05-21 15:13:53 +10:00
Paul Riseborough 9aa3cdfaae AP_NavEKF2: Update GPS yaw re-alignment function
Updates to support initial alignment without magnetometer
2016-05-21 15:13:53 +10:00
Paul Riseborough e3c966661b AP_NavEKF2: Remove unnecessary variance reset
This reset is unnecessary give that a synthetic yaw angle is fused at a low rate to prevent variances from becoming badly conditioned.
2016-05-21 15:13:53 +10:00
Paul Riseborough 1179c08473 AP_NavEKF2: Handle case where we are in-flight and haven't yet aligned the yaw
This happens if planes are flown without a compass
2016-05-21 15:13:53 +10:00
Paul Riseborough 581c1aa0d4 AP_NavEKF2: Adjust attitude variance values used after a heading reset
Because these errors are in body frame, a spherical error should be used to accommodate different orientations
2016-05-21 15:13:53 +10:00
Paul Riseborough 5ec8d523f6 AP_NavEKF: remove unwanted co-variance reset
The co-variance resets required following a velocity and position state reset is now performed in the stte reset function
2016-05-21 15:13:53 +10:00
Paul Riseborough 66e4d9d6e8 AP_NavEKF2: Reset co-variance values when doing a pos,vel,hgt reset
Ensures consistent behaviour after resets and reduces attitude disturbances
2016-05-21 15:13:52 +10:00
Paul Riseborough cf8175a073 AP_NavEKF2: Allow immediate use of GPS in-flight for plane without compass
Planes operating without a compass must align the yaw to the GPS heading immediately after launch or takeoff and cannot wait for GPS accuracy checks.
2016-05-21 15:13:52 +10:00
Paul Riseborough 08de4e6d95 AP_NavEKF: Do not perform start-up yaw alignment if no compass
Yaw cannot be aligned until in-flight when there is sufficient GPS velocity.
2016-05-21 15:13:52 +10:00
Paul Riseborough d2694fe5dc AP_NavEKF2: Remove duplicate transition into GPS aiding
This decision is made in one place in setAidingMode()
2016-05-21 15:13:52 +10:00
Paul Riseborough 7201f7d2fd AP_NavEKF2: fix comment 2016-05-21 15:13:52 +10:00
Paul Riseborough 64a8153b68 AP_NavEKF2: update function name
The primary purpose of this function is re-alignment
2016-05-21 15:13:52 +10:00
Paul Riseborough addd213af0 AP_NavEKF2: reduce effect of acceleration on non-GPS mode attitude 2016-05-21 15:13:52 +10:00
Paul Riseborough a3b78e6231 AP_NavEKF2: update tuning defaults 2016-05-21 15:13:51 +10:00
Paul Riseborough 65f63341d7 AP_NavEKF2: Improve numerical error protection in optical flow fusion
Abort fusion of data if variances will become negative and publish the fault
2016-05-21 15:13:51 +10:00
Paul Riseborough 42da33593d AP_NavEKF2: fix yaw fusion numerical health reporting 2016-05-21 15:13:51 +10:00
Paul Riseborough 6eb9d43507 AP_NavEKF2: add numerical error checking and isolation to mag decl fusion 2016-05-21 15:13:51 +10:00
Paul Riseborough b325c5faeb AP_NavEKF2: add error checking and isolation to mag heading fusion 2016-05-21 15:13:51 +10:00
Paul Riseborough a0b1dc5325 AP_NavEKF2: add error checking and isolation to 3D amg fusion 2016-05-21 15:13:51 +10:00
Paul Riseborough 51a3df0319 AP_NavEKF2: Add error checking and isolation to pos vel fusion 2016-05-21 15:13:51 +10:00
Paul Riseborough 71b589c89c AP_NavEKF2: extend fusion fault reporting coverage 2016-05-21 15:13:50 +10:00
Paul Riseborough 0982bd0b2b AP_NavEKF2: update parameter documentation 2016-05-21 15:13:50 +10:00
Paul Riseborough 46a2993a0d AP_NavEKF: use intuitive units for imu bias process noise parameters 2016-05-21 15:13:50 +10:00
Paul Riseborough 8c374fd679 AP_NavEKF2: correct comments 2016-05-21 15:13:50 +10:00
Paul Riseborough 6be9eaa524 AP_NavEKF2: use receiver estimated accuracy
Adjust the GPS observation noise based on receiver accuracy output if available.
2016-05-21 15:13:50 +10:00
Paul Riseborough dddc213836 AP_NavEKF2: Open up tuning limits
Done to assist tuning assessments
2016-05-21 15:13:50 +10:00
Paul Riseborough cf05e110fc AP_NavEKF2: fix scaling error in use of IMU noise parameters
Also remove process noise from state transition matrix where it was mistakenly left in after the derivation
2016-05-21 15:13:50 +10:00
Andrew Tridgell 4080c6091d AP_NavEKF2: fixed an assumption that _ahrs->get_compass() always works
if MAG_ENABLE=0 in plane there is no compass
2016-05-19 14:16:40 +10:00
Tom Pittenger d67b1edf10 AP_NavEKF2: (potential) compiler warning of float to double promotion 2016-05-17 20:30:51 -07:00
Ricardo de Almeida Gonzaga 64d14356b9 AP_NavEKF2: Fix typos 2016-05-13 19:20:06 -03:00
dgrat 41661f815f AP_Math: Replace the pythagorous* functions with a variadic template
The new function can deal with a variable number of function parameters.
Additionally, I renamed the functions to norm(), because this is the
standard name used in several other projects.
2016-05-10 11:41:26 -03:00
Andrew Tridgell ea508f1b80 AP_NavEKF2: use LOG_REPLAY and EK2_LOG_MASK parameters 2016-05-09 12:26:57 +10:00
Andrew Tridgell 32af886ba9 AP_NavEKF2: use consistent logging timestamps for sensors 2016-05-07 18:27:22 +10:00
Andrew Tridgell 4e4c575f16 AP_NavEKF2: added have_ekf_logging() 2016-05-07 18:27:20 +10:00
Andrew Tridgell b7ba0fa458 AP_NavEKF2: added ad-hoc logging example to EKF2 2016-05-07 18:27:20 +10:00
Andrew Tridgell 223c512188 AP_NavEKF2: added logging of sensor data in EKF2 2016-05-07 18:27:18 +10:00
Andrew Tridgell f92279f436 AP_NavEKF2: allow logging of IMT data from inside EKF2 2016-05-07 18:27:17 +10:00
Andrew Tridgell 9c4dd024bf AP_NavEKF2: auto change EK2_GPS_TYPE for NMEA
this fixes a problem where users of NMEA GPS receivers could not arm
with default EK2 parameters.
2016-05-05 19:46:33 +10:00
Andrew Tridgell ac60901b0c AP_NavEKF2: use vector comparison for new mag vector 2016-04-21 09:56:22 +10:00
Jonathan Challinger 97112ccd44 AP_NavEKF2: check mag instance id when returning mag offsets 2016-04-21 09:51:41 +10:00
Jonathan Challinger 1185cd1be7 AP_NavEKF2: move getMagOffsets into outputs 2016-04-21 09:51:41 +10:00
Jonathan Challinger acfaafe276 AP_NavEKF2: detect changes to magnetometer offset parameters and reset states 2016-04-21 09:51:41 +10:00
Paul Riseborough 1ecc206eee AP_NavEKF2: Allow use in planes without a magnetometer
Implements the following techniques to enable planes to operate without magnetometers.

1) When on ground with mag use inhibited, a synthetic heading equal to current heading is fused to prevent uncontrolled covariance growth.
2) When transitioning to in-flight, the delta between inertial and GPS velocity vector is used to align the yaw.
3) The yaw gyro bias state variance is reset following an in-flight heading reset to enable the yaw gyro bias to be learned faster.
2016-04-15 08:31:47 +10:00
Paul Riseborough 6d9ba8c527 AP_NavEKF2: Improve protection against ground based mag interference
Reset the mag field states and yaw earlier than the normal 5m height threshold if toilet bowling is detected.
2016-03-17 10:55:11 +11:00
Lucas De Marchi e40b87cd0e AP_NavEKF2: replace header guard with pragma once 2016-03-16 18:40:42 +11:00
Paul Riseborough 38b3625ed8 AP_NavEKF2: Fix bug in initial alignment calculation
The bug caused the initial roll angle to be incorrect if the vehicle was powered up when inverted, causing long alignment times.
2016-03-02 09:10:09 +09:00
Paul Riseborough 2888bdd6d5 AP_NavEKF: Protect against possible div by 0 2016-03-01 10:08:47 -03:00
Paul Riseborough 7d6b926749 AP_NavEKF2: Improved magnetic heading fusion
Use an Euler yaw heading that switches between a 321 and 312 rotation
sequence to avoid areas of singularity.  Using Euler yaw decouples the
observation from the roll and pitch states and prevents magnetic
disturbances from affecting roll and pitch via the magnetometer fusion
process.
2016-03-01 10:08:47 -03:00
Paul Riseborough bb74371c58 AP_NavEKF2: Do not use GPS height if GPS accuracy is poor
If we are using GPS height, revert back to using Baro height if the GPS accuracy is poor.
2016-03-01 15:13:13 +09:00
dgrat 5148e41c1a AP_Math: Cleaned macro definitions
Moved Definitions into a separate header. Replaced PI with M_PI and
removed the M_PI_*_F macros.
2016-02-27 02:51:33 -03:00
Paul Riseborough 7459bfb96b AP_NavEKF2: Eliminate simple compass fusion singularities near +-90 deg pitch
The use of yaw angle fusion during startup and ground operation causes problems with tail-sitter vehicle types.
Instead of observing an Euler yaw angle, we now observe the yaw angle obtained by projecting the measured magnetic field onto the the horizontal plain.
This avoids the singularities associated with the observation of Euler yaw angle.
2016-02-22 16:29:36 +11:00
Paul Riseborough 4aefe1caee AP_NavEKF2: Fix sign error in magnetic heading innovation calculation 2016-02-20 08:55:48 +11:00
Peter Barker 475a2040a1 AP_NavEKF2: avoid use of undefined #defines
Ensure EKF_DISABLE_INTERRUPTS is defined

Do not define MATH_CHECK_INDEXES, assume it is defined
2016-02-19 12:34:24 -02:00
Paul Riseborough 047e9fabaf AP_NavEKF2: Fix bug in simple heading fusion
The innovation calculation should have been updated when the heading fusion maths was updated.

We now use a direct heading or yaw angle measurement in the derivation, not the difference between observed and published declination.
2016-02-19 15:35:11 +09:00
Paul Riseborough d3c9a0aef1 AP_NavEKF: Limit heading innovations after the consistency check 2016-02-18 08:53:47 +09:00
Paul Riseborough 6a34e4c384 AP_NavEKF2: Fix bug in magnetic heading and declination fusion equations.
The derivation incorrectly used a tan instead of an atan function. This applies the corrected auto-code.
2016-02-18 08:53:45 +09:00
Paul Riseborough 59bf29198d AP_NavEKF2: Remove unnecessary logic preventing constant position
This removes a legacy design concept that is no longer required in this filter implementation. Planes will not be armed without EKF aiding and the proposed copter throw mode also requires EKF aiding to be operating.
The other problem with interrupting fusion during the launch is it doesn't reduce the corrections, it just delays them as wen the launch completes, the EKF inertial position estimate is still moving still moved and the corrections are therefore just delayed by the short launch interval.

Thank you to OXINARF for picking up the inconsistency with the previous logic
2016-02-18 08:53:43 +09:00
Paul Riseborough 7e05646316 AP_NavEKF2: Improvements to non-GPS performance
Change to user adjustable fusion of constant position (as per legacy EKF) instead of constant velocity.
Enable user to specify use of 3-axis magnetometer fusion when operating without aiding.
Don't allow gyro scale factor learning without external aiding data as it can be unreliable
2016-02-18 08:53:41 +09:00
Paul Riseborough 8630874ef3 AP_NavEKF2: Send correct data over mavlink status message 2016-02-01 10:02:22 +09:00
Andrew Tridgell acb4885989 AP_NavEKF2: use get_delta_angle_dt() API 2016-01-19 09:50:22 +11:00
Paul Riseborough 287ebe8e6a AP_NavEKF2: Fix bug in application of sensor bias corrections
Sensor bias corrections were being applied to the incoming IMU data using the wrong delta time.
This was what was driving the different tuning between plane and copter for gyro bias process noise so the same gyro bias process noise default tuning value can now be used for all platform types.
Sensor bias corrections were being applied a a second time to the output observer inertial data.
2016-01-13 08:05:39 +11:00
Paul Riseborough 20923da23a AP_NavEKF2: Allow tuning of non-GPS mode
Eliminate the use of horizontal position states during non-aiding operation to make it easier to tune.
Explicitly set the horizontal position associated Kalman gains to zero and the coresponding covariance entries to zero after avery fusion operation.
Make the horizontal velocity observation noise used during non-aiding operation adjustable.
Use a fixed value of velocity noise during initial alignment so that the flight peformance can be tuned without affecting the initial alignment.
2016-01-13 08:05:39 +11:00
Paul Riseborough 23038e7243 AP_NavEKF2: Use measurement uncertainties to initialise covariance 2016-01-13 08:05:39 +11:00
Paul Riseborough e80fb8b3fa AP_NavEKF2: Improve non-GPS in-flight attitude accuracy
The non-GPS mode was not being activated for small height gains - eg indoor flight.
The incorrect innovation consistency check was being applied to the synthetic velocity observations.
2016-01-06 20:49:21 +11:00
Andrew Tridgell c34626ec4e AP_NavEKF2: automatically cut back EK2_IMU_MASK to suit number of IMUs 2016-01-05 16:40:43 +11:00
Andrew Tridgell 0831661b3c AP_NavEKF2: mark EK2_ENABLE as an ENABLE parameter 2016-01-04 11:14:42 +11:00
Andrew Tridgell 23cef70846 AP_NavEKF2: use get_loop_delta_t() from INS 2015-12-27 14:57:17 +09:00
Don Gagne 8573245963 AP_NavEKF2: fix invalid Range meta data 2015-12-27 16:10:44 +11:00
Lucas De Marchi 2591261af6 Global: rename min and max macros to uppercase
The problem with using min() and max() is that they conflict with some
C++ headers. Name the macros in uppercase instead. We may go case by
case later converting them to be typesafe.

Changes generated with:

	git ls-files '*.cpp' '*.h' -z | xargs -0 sed -i 's/\([^_[:alnum:]]\)max(/\1MAX(/g'
	git ls-files '*.cpp' '*.h' -z | xargs -0 sed -i 's/\([^_[:alnum:]]\)min(/\1MIN(/g'
2015-12-01 16:28:09 -02:00
Paul Riseborough ddb7d92fc8 AP_NavEKF2: Fix timing jitter in airspeed fusion
The airspeed observation buffer was only being checked when new data arrived instead of every frame which introduced some timing jitter. The buffer is now checked every filer update step.
The duplication and inconsistent naming of booleans used to indicate availability f data has been fixed.
2015-11-26 09:22:03 +11:00
Siddharth Purohit and Paul Riseborough 3014eb4001 AP_NavEKF2: Rework measurement buffer refactor
These changes were pair coded an tested by Siddharth Purohit and Paul Riseborough

Fix indexing errors
Move buffer code into a separate file
Split observer and IMU/output buffers and remove duplicate sample time
Optimise observation buffer search
Reduce maximum allowed fusion age to 100 msec
2015-11-23 19:42:06 +11:00
Siddharth Bharat Purohit b3c8dcee34 AP_NavEKF2: measurement buffer refactor 2015-11-23 19:34:50 +11:00
Caio Marcelo de Oliveira Filho 8d882b06dd AP_NavEKF2: use millis/micros/panic functions 2015-11-20 12:32:41 +09:00
Paul Riseborough ff2782b790 AP_NavEKF2: Parameter changes to reduce noise on gyro bias estimates 2015-11-18 20:17:03 +09:00
Paul Riseborough 2193103586 AP_NavEKF: Reduce time to switch after an IMU fault
This revised threshold value is still double the maximum that has been observed in flight logs so far with healthy sensors
The previous value was too slow to switch for sudden IMU gyro faults
We can afford an ocasional false trigger becasue the front end will only select another instance if it is healthy and has lower errors
2015-11-18 20:17:00 +09:00
Paul Riseborough 20798316e1 AP_NavEKF2: fix bug in performance timer 2015-11-18 20:16:58 +09:00
Paul Riseborough 2fb5a4489b AP_NavEKF2: Prevent airspeed faults from causing excessive loss of accuracy 2015-11-18 11:39:54 +11:00
Paul Riseborough fc6978e4d9 AP_NavEKF2: Fix error in parameter documentations 2015-11-18 11:39:54 +11:00
Paul Riseborough f9cadaf15c AP_NavEKF2: Increase resolution of innovation consistency gate parameters
Also adds protection against setting the gate to a number that would casue numerical errors.
2015-11-18 11:39:53 +11:00
Andrew Tridgell 08ef00b431 AP_NavEKF2: fixed build with IMU_BUFFER_LENGTH change 2015-11-18 11:33:51 +11:00
Paul Riseborough af3507ef3c AP_NavEKF2: Stop bad INS velocity spoiling height reset
We should reset the velocity as well as the height if a reasonable reset value is available.
2015-11-18 11:18:50 +11:00
Paul Riseborough 97799ef0b3 AP_NavEKF2: Ensure that GPS origin is set before using data for height 2015-11-18 11:18:50 +11:00
Paul Riseborough b8427e5d95 AP_NavEKF2: Only allow rangefinder height option during optical flow nav 2015-11-18 11:18:50 +11:00
Paul Riseborough c9eea98142 AP_NavEKF2: Improve terrain height estimation
The ad-hoc scaling of error growth has been replaced with a consistent method that uses the main nav filters published vertical velocity uncertainty and the terrain gradient assumption.
2015-11-18 11:18:46 +11:00
Paul Riseborough d820a538d5 AP_NavEKF2: Make magnetometer data available status global
This assists with debugging and makes it consistent with other measurements that are buffered
2015-11-18 11:18:46 +11:00
Paul Riseborough 04228e0b3b AP_NavEKF2: Rework selection of height measurements for fusion
GPS height has been added as a measurement option along with range finder and baro
Selection of the height measurement source has been moved into a separate function
Each height source is assigned its own measurement noise
If GPS or baro alt is not able to be used, it reverts to baro
When baro is not being used, an offset is continually calculated which enables a switch to baro without a height step.
2015-11-18 11:18:42 +11:00
Paul Riseborough 80bc64ee7a AP_NavEKF2: Update parameter documentation with GPS height source option 2015-11-18 11:18:18 +11:00
Paul Riseborough 4c72a14e22 AP_NavEKF2: Add function to LPF and spike filter baro data 2015-11-18 11:18:17 +11:00
Paul Riseborough 34311bedfa AP_NavEKF2: Add data buffers for range finder data 2015-11-18 11:18:17 +11:00
Andrew Tridgell 99da195e37 AP_NavEKF2: make IMU buffer length depend on main loop rate
this fixes a problem with Replay and baro data
2015-11-18 10:20:39 +11:00
Paul Riseborough 9b82b2200c AP_NavEKF2: Fix plane in-flight yaw reset
The copter method was being used for plane and the plane method was not being run due to the change in flight status not being detected.
The plane reset method did not trigger if the EKF had already dragged the velocity states along with the GPS or could align to an incorrect heading.
The method has been reworked so that it resets to the GPS course, but only if there are inconsistent angles and large innovations.
To stop a failed magnetometer causing a loss of yaw reference later in flight, if all available sensors have been tried in flight and timed out, then no further magnetoemter data will be used
2015-11-16 09:05:42 +11:00
Paul Riseborough e8706db382 AP_NavEKF2: Update IMU tuning parameter limits 2015-11-16 09:05:42 +11:00
Paul Riseborough 0562529729 AP_NavEKF2: Tuning changes to make attitude less sensitive to GPS and compass errors 2015-11-16 09:05:42 +11:00
Paul Riseborough 6522fb2621 AP_NavEKF2: Allow user to relax pre-flight GPS checks 2015-11-12 20:39:15 +11:00
Paul Riseborough 0b653bb82b AP_NavEKF2: Update MAVLnk parameter documentation 2015-11-11 15:16:36 +11:00
Paul Riseborough ca31ced2b4 AP_NavEKF2: Fix bug preventing use of optical flow with multiple IMU's 2015-11-10 18:17:16 +11:00
Paul Riseborough 577670ccee AP_NavEKF2: Reduce memory required by 6KB when running at 400Hz
Down-sample the IMU and output observer state data to 100Hz for storage in the buffer.
This reduces storage requirements for Copter by 75% or 6KB
It does not affect memory required by plane which already uses short buffers due to its 50Hz execution rate.
This means that the EKF filter operations operate at a maximum rate of 100Hz.
The output observer continues to operate at 400Hz and coning and sculling corrections are applied during the down-sampling so there is no loss of accuracy.
2015-11-10 15:51:18 +11:00
Paul Riseborough e33aa7898a AP_NavEKF2: Prevent return of uninitialised variable 2015-11-09 22:30:38 +11:00
Paul Riseborough 3d8e74df26 AP_NavEKF2: Don't switch magnetometers when on the ground or just started
Large magnetometer innovations on the ground could be caused by factors that will disappear when flying, eg:

a) Bad initial gyro bias
b) External magnetic field disturbances (adjacent metal structures, placement of hatches with magnets, etc)

To avoid unnecessary switches, we inhibit switching until off-ground and when sufficient time has lapsed from power on to learn gyro bias offsets.
2015-11-09 22:07:10 +11:00
Paul Riseborough 3099d94e78 AP_NavEKF2: Retrieve correct time-stamp for active compass 2015-11-09 22:07:10 +11:00