115 Commits

Author SHA1 Message Date
Daniel Agar
d2b3e7fe16
ekf2: new kconfig to enable/disable GNSS (enabled by default) 2023-10-11 14:02:34 -04:00
Daniel Agar
5f87f3a046 ekf2: drag fusion add aid source status topic 2023-10-09 09:26:28 -04:00
Daniel Agar
153f7bbced ekf2: update all copyright headers 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
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
Mathieu Bresciani
24de623989
EKF2: Zero gyro update (#21691)
When at rest, directly fuse the gyro data as an observation of its bias.
This allows to strongly observe the gyro biases without having to fuse a
constant heading that makes the ekf too confident about its heading.
2023-06-09 21:13:18 -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
fe0e3acf09 ekf2: add kconfig option to enable/disable drag fusion 2023-03-20 10:12:17 -04:00
Daniel Agar
9ec3f30ae1 ekf2: move gps buffer pop to controlGpsFusion()
- controlGpsFusion() now owns yaw estimator update
2023-02-22 09:08:33 -05:00
Daniel Agar
60856ebe62 ekf2: move range buffer pop to controlRangeHeightFusion() 2023-02-22 09:08:33 -05:00
Daniel Agar
241cee2bb7 ekf2: move airspeed buffer pop to controlAirDataFusion 2023-02-22 09:08:33 -05:00
Daniel Agar
0711a34d0e ekf2: move flow buffer pop to controlOpticalFlowFusion 2023-02-22 09:08:33 -05:00
Daniel Agar
ed8cef6cf0 ekf2: move controlAuxVelFusion control.cpp -> auxvel_fusion.cpp 2023-02-22 09:08:33 -05:00
Daniel Agar
b4e845d7c0 ekf2: move controlDragFusion control.cpp -> drag_fusion.cpp 2023-02-22 09:08:33 -05:00
Daniel Agar
c08a387c5a ekf2: move controlBetaFusion control.cpp -> sideslip_fusion.cpp 2023-02-22 09:08:33 -05:00
Daniel Agar
d61b8c21b2 ekf2: move controlAirDataFusion() control.cpp -> airspeed_fusion.cpp 2023-02-22 09:08:33 -05:00
Daniel Agar
d840f7f39f ekf2: move controlGpsYawFusion() control.cpp -> gps_control.cpp 2023-02-22 09:08:33 -05:00
Daniel Sahu
fa6fda6cce
ekf2: new gravity observation (#21038)
Signed-off-by: Daniel M. Sahu <danielmohansahu@gmail.com>
2023-02-07 13:28:58 -05: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
657bd6cf72 ekf2: stop mag fusion when inhibited for too long
Also do not try to run anything if mag is inhibited
2022-12-29 12:56:36 -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
Daniel Agar
8cf13d50a8
ekf2: EKFGSF_yaw minor cleanup (#20510)
- don't store unnecessary IMU copy in class, pass it through where required
 - remove custom pi constants
 - remove unused fields from ahrs_ekf_gsf (vel_NE, fuse_gps, accel_dt)
 - explicitly initialize everything in header
 - apply PX4 code style
 - set GPS velocity before yaw estimator update, not after
2022-12-09 13:24:00 -05:00
bresch
b25bc1b982 ekf2: GNSS yaw, update->fuse pattern 2022-11-22 09:59:31 -05:00
Daniel Agar
da82757bf6
ekf2: accumulate multiple vel/pos/orientation reset deltas per update
- if in a single EKF update there are multiple resets we need to track the accumulated delta so the change consumed by the controllers is correct
2022-11-15 13:20:54 -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
bresch
06702da003 ekf2: add GNSS yaw max interval
yaw data usually comes at lower rate than vel/pos
2022-11-14 10:45:23 -05:00
bresch
9834c7917b ekf2: use yaw emergency estimator more aggressively
During the whole flight, if the difference between the yaw estimate from
EKF2 and the emergency estimator is large and that the GNSS velocity
fusion is failing continuously, immediately reset to the emergency yaw
estimate.
2022-11-14 10:45:23 -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
298cc61e07 ekf2: push fuse beta config into backend 2022-11-02 10:09:26 -04:00
Daniel Agar
f9509b442c
ekf2: height aid source consistency (#20405)
- working towards keeping all height source (baro/ev/gnss/rng) handling as consistent as possible, possibly refactoring these out into separate classes later
2022-10-19 15:35:07 -04:00
Daniel Agar
b71fc63162 ekf2: fix sideslip timeout (typo) 2022-10-18 18:38:25 -04:00
Daniel Agar
535415a537 ekf2: add OF estimator aid src status 2022-10-18 14:19:16 -04:00
Daniel Agar
2de990fd4b estimator_aid_source split GNSS pos (3d) -> pos (2d) + hgt
- per estimator air source status only keep a single set of flags and
timestamp that applies to the entire source
2022-10-13 11:28:50 -04:00
bresch
5f54f6fcda ekf2: migrate sideslip fusion to SymForce
- split fusion into update (compute innov and innov_var) and actual fusion to the state vector
- use estimator_aid_source_1d struct to group the data
2022-10-12 09:55:35 -04:00
bresch
bb790c9bec ekf2: add vertical dead-reckoning timeout check for height validity 2022-09-29 14:16:36 -04:00
bresch
ae1e12a6b5 ekf2: remove baro accumulation from initializeFilter 2022-09-10 12:29:29 -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
bresch
aa716936bf ekf2: move synthetic_position flag to control_status.flags.fake_pos 2022-09-10 12:29:29 -04:00
Daniel Agar
d996af4647 ekf2: pass gpsSample around where required
- this minimizes potential misuse accessing _gps_sample_delayed and
makes the dependency clear
2022-09-05 10:27:19 -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
2d39097f60 ekf2: move rng height to file 2022-08-24 09:16:11 -04:00
bresch
28b4cd0579 ekf2: move GNSS hgt control to file 2022-08-24 09:16:11 -04:00
bresch
b6f76b5eaa ekf2: move ev control to file 2022-08-24 09:16:11 -04:00
bresch
f555281c94 ekf2: move height control-related function to file 2022-08-24 09:16:11 -04:00
bresch
d87feee5b0 ekf2: move baro control logic to file 2022-08-24 09:16:11 -04:00
bresch
12e25eba62 ekf2: add common height fusion timeout parameter 2022-08-24 09:16:11 -04:00