58 Commits

Author SHA1 Message Date
Daniel Agar
6f484b652f [WIP] ekf2: EKF init immediately on first IMU sample
- tilt init use filtered accel/gyro on delayed time horizon
 - publish estimator_status on every EKF update (even if !_filter_initialised)
2024-11-27 17:22:51 -05:00
bresch
93c690f133 ekf2: do not inline getPosition 2024-11-22 15:13:47 +01:00
Daniel Agar
1cd7d54170
ekf2: consolidate GNSS yaw in gnss_yaw_control.cpp and fix naming (GPS->GNSS)
Co-authored-by: Mathieu Bresciani <brescianimathieu@gmail.com>
2024-07-15 12:50:51 -04:00
Daniel Agar
9124a7b471 ekf2: add IMU delta_ang_dt/delta_vel_dt safety constrain before pushing into buffer 2024-07-10 21:20:47 -04:00
Daniel Agar
c29b4ff87e ekf2: apply astyle formatting and enforce 2024-07-10 10:43:55 -04:00
Daniel Agar
24fdd696cb ekf2: move range finder files to aid_sources/range_finder 2024-05-02 17:40:58 -04:00
bresch
a8a67fbf8f ekf2: set horizon using specific parameter
Some sensors can have their delay included in the timestamp. In this
case, the buffer cannot be sized using the _DELAY parameter.
2024-04-17 09:16:16 -04:00
Daniel Agar
d45c3d3407
ekf2: verbose (DEBUG_BUILD) print status with Matrix improved print
* ekf2: verbose print status
 * matrix/Matrix improve print output
 * bold diagonal elements, print ring buffer entry size
 * print in scientific notation when >= 10 to respect max size

---------

Co-authored-by: bresch <brescianimathieu@gmail.com>
2024-01-10 09:46:04 -05:00
bresch
a653073d4f ekf2: perform GNSS checks at delayed-time horizon
- never fuse a measurement that is not passing the checks
- cleanup and simplify GNSS vel/pos control logic
2023-12-18 18:11:20 +01:00
bresch
6bd1145006 ekf2: scope RngCtrl enum 2023-12-05 11:22:59 -05:00
bresch
fe7988672f ekf2: auxiliary position fusion
Co-authored-by: Daniel Agar <daniel@agar.ca>
2023-12-01 11:50:22 +01:00
Daniel Agar
6eae9fb371 ekf2: fix barometer kconfig 2023-10-18 09:43:27 -04:00
Daniel Agar
d2b3e7fe16
ekf2: new kconfig to enable/disable GNSS (enabled by default) 2023-10-11 14:02:34 -04:00
Daniel Agar
28d58a947f ekf2: cleanup more optional mag (CONFIG_EKF2_MAGNETOMETER) 2023-10-09 10:18:02 -04:00
Daniel Agar
153f7bbced ekf2: update all copyright headers 2023-09-15 10:02:09 -04:00
Daniel Agar
1e9f0ad2c6 ekf2: add kconfig for barometer support (enabled by default) 2023-09-15 10:02:09 -04:00
Daniel Agar
845b01a00d ekf2: add kconfig for magnetometer support (enabled by default) 2023-09-15 10:02:09 -04:00
Daniel Agar
2c76109a94 ekf2: drag fusion don't use any accel samples that are clipping 2023-08-28 14:35:13 -04:00
Daniel Agar
d75bb62a65
ekf2: separate mag and mag heading control logic (#21212)
- split mag_3d into new standalone mag fusion and mag fusion allowed to update all states (full mag_3d)
 - new dedicated control logic for mag/mag_3d fusion and standalone mag heading fusion
 - if WMM available use for mag_I and mag_B init
 - mag states reset if external yaw reset (yaw estimator, GPS yaw, etc)
 - mag reset if declination changed (eliminate _mag_yaw_reset_req)
 - mag fusion (but not mag_hdg or mag_3d) can be active during gps_yaw or ev_yaw (if yaw aligned north)

Co-authored-by: bresch <brescianimathieu@gmail.com>
2023-08-04 10:39:16 -04:00
bresch
2a2e43b620 ekf2: move flow fusion activation from AID_MASK to OF_CTRL 2023-04-28 22:31:17 -04:00
bresch
39c2f95669 ekf2: move drag fusion activation from AID_MASK to DRAG_CTRL 2023-04-28 22:31:17 -04:00
bresch
fb3b4a3151 ekf2: remove duplicate buffer push of system flags 2023-04-04 15:56:09 -04:00
Daniel Agar
32a5bd32ad ekf2: add kconfig option to enable/disable range finder fusion (and terrain estimator) 2023-03-21 11:25:34 -04:00
Daniel Agar
0784901a66 ekf2: add kconfig option to enable/disable optical flow fusion 2023-03-21 11:25:34 -04:00
Daniel Agar
4363b09421 ekf2: add kconfig option to enable/disable external vision fusion 2023-03-20 10:12:17 -04:00
Daniel Agar
d47f96f1a5 ekf2: add kconfig option to enable/disable AUX velocity fusion 2023-03-20 10:12:17 -04:00
Daniel Agar
4270a303ab ekf2: add kconfig option to enable/disable airspeed and sideslip fusion 2023-03-20 10:12:17 -04:00
Daniel Agar
98ff1afc19 ekf2: add kconfig option to enable/disable GNSS yaw 2023-03-20 10:12:17 -04:00
Daniel Agar
fe0e3acf09 ekf2: add kconfig option to enable/disable drag fusion 2023-03-20 10:12:17 -04:00
Daniel Agar
95300d5637
ekf2: refactor output predictor to class
- refactor all EKF backend output predictor pieces into new OutputPredictor class
 - output states are now calculated immediately with new high rate IMU rather than after EKF update
 - IMU delayed sample is passed as around as control data to avoid storing an extra copy and make the requirement clear
2023-01-18 10:59:34 -05:00
bresch
0509f612dd ekf2: fix drag data downsampling
setDragData needs the imu data at full speed to downsample it without
skipping samples.
2023-01-05 12:03:24 -05:00
Daniel Agar
20a1c73cf0 ekf2: reinit baro height on sensor or calibration change
- handle reset on delayed time horizon
2022-12-29 16:37:34 -05:00
Daniel Agar
54a32eb2f7
ekf2: EV overhaul yaw and position fusion (#20501)
- move EV yaw and EV position to new state machines
 - EV yaw and EV pos now configured via EKF2_EV_CTRL (migrated from EKF2_AID_MASK)
 - new EV position offset estimator to enable EV position while GPS position is active (no more EV pos delta fusion)
 - yaw_align now strictly means north (no more rotate external vision aid mask)
 - automatic switching between EV yaw, and yaw align north based on GPS quality
2022-12-20 10:23:56 -05:00
Daniel Agar
696eeb9a49
ekf2: update EV height state machine (small piece of EV overhaul)
- respect new EKF2_EV_CTRL parameter for VPOS usage
  - EV hgt rotate EV position before usage (there's often a small offset in frames)
  - EV hgt reset use proper EV velocity body frame
  - try to keep EV hgt and EV vel state machines consistent
  - small incremental piece of https://github.com/PX4/PX4-Autopilot/pull/19128
2022-12-13 13:29:18 -05:00
bresch
5155346d60 ekf2: do not use gnss data when no lock 2022-11-30 08:50:34 -05:00
bresch
5d7faefa84 ekf2: don't add invalid GNSS samples to the buffer 2022-11-30 00:22:15 -05:00
bresch
60c448ce3a ekf2: GNSS yaw, use reported yaw accuracy when available 2022-11-22 09:59:31 -05:00
Daniel Agar
639d1ddca2
ekf2: update flags (in_air, at_rest, etc) on delayed time horizon (#20576)
- in a lot of cases this won't really matter, although you can see it in logs (especially with things like vehicle_at_rest), but it's something we might as well do properly

Co-authored-by: Mathieu Bresciani <brescianimathieu@gmail.com>
2022-11-14 11:35:40 -05:00
Daniel Agar
84d1435880 ekf2: ensure minimum output buffer sizing
- buffer at least 2 samples for the IMU output predictor buffers
 - dropping below 2 becomes problematic for the minimum observation
interval calculation and the vertical output buffer trapezoidal
integration
2022-11-09 09:49:35 -05:00
Daniel Agar
5239993c88 ekf2: move EV vel to new state machine, introduce EKF2_EV_CTRL param 2022-11-08 11:46:41 -05:00
Daniel Agar
fb3adc3faa
ekf2: move baro compensation to delayed time horizon and add validity check
- this removes an unnecessary virtual call and simplifies things a bit

Co-authored-by: bresch <brescianimathieu@gmail.com>
2022-10-20 09:17:55 -04:00
bresch
a54fa7b9b1 ekf2: add fake height fusion logic
When there is no vertical aiding, fake height is started to constrain
the vertical channel of the EKF
2022-09-10 12:29:29 -04:00
Daniel Agar
5cb44a521c ekf2: estimator interface handle sample time with signed integers
- this prevents unsigned integer overflow if the timestamp is smaller
than the configured delay (mostly a simulation edge case)
2022-09-01 09:47:29 -04:00
Daniel Agar
1948c5057a ekf2: handle all time on delayed horizon (except for newest sample checks)
- a growing number of samples come into the backend with the time
already delayed (sensor's interrupt setting timestamp sample)
 - if the incoming timestamp is already delayed then the new data checks
(relative to latest IMU) can be slightly wrong
 - handle almost all timestamps and checks on delayed time horizon,
except for explicit checks of new samples
 - isRecent() and isTimedOut() helpers use delayed time
 - add new isNewestSampleRecent() used for checking the incoming
timestamp of the incoming (adjusted) data
2022-08-31 08:52:30 -04:00
bresch
8962cf2d25 ekf2: GPS, baro and range finder control parameters
Also remove the legacy "range aid" than can be achieved by setting the
height reference to range finder and the range finder control parameter
to "conditional".

Conditional range aiding cal also be set when the height reference isn't
the range finder. This prevents the ratchetting effect due to switching
between references.
2022-08-24 09:16:11 -04:00
bresch
f9188b2a14 ekf2: refactor vertical acceleration check for multiple height sources 2022-08-24 09:16:11 -04:00
bresch
8fd79688c0 ekf2: enable multiple height sources fusion
Instead of having a single height source fused into the EKF and the
other ones "waiting" for a failure or the primary sensor, fuse all
sources in EKF2 at the same time. To prevent the sources from fighting against each
other, the "primary" source is set as reference and the other ones are
running a bias estimator in order to make all the secondary height
sources converge to the primary one.

If the reference isn't available, another one is automatically selected
from a priority list. This secondary reference keeps its current bias
estimate but stops updating it in order to be the new reference as close
as possible to the primary one.
2022-08-24 09:16:11 -04:00
mcsauder
ea10eacb99 Replace EKF/common.h #defines with enums. 2022-05-18 09:25:19 -04:00
Daniel Agar
f3e2a197ad
move vehicle at rest detection ekf2 -> land_detector
- move vehicle at reset detection ekf2 -> land_detector
 - ekf_unit: reduce init period
   - Fake fusion is when at rest is quite strong and makes the variance reduce rapidly. Reduce the amount of time we wait before checking if the variances are still large enough.
 - ekf_unit: reduce minimum vel/pos variance required after init
   - Fake pos fusion has a low observation noise, making the vel/pos variances reduce quickly.

Co-authored-by:: bresch <brescianimathieu@gmail.com>
2022-02-01 17:50:19 -05:00
Daniel Agar
ae3070bbf1 ekf2: make filter update period configurable
- introduces new parameter EKF2_PREDICT_US to configure the filter
update period in microseconds
 - actual filter update period will be an integer multiple of IMU
2022-01-26 10:57:09 -05:00