Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EKF2 simplify covariance propagation #22344

Merged
merged 2 commits into from
Nov 14, 2023
Merged

EKF2 simplify covariance propagation #22344

merged 2 commits into from
Nov 14, 2023

Conversation

bresch
Copy link
Member

@bresch bresch commented Nov 10, 2023

Solved Problem

Symbolic derivation tools don't automatically simplify for unit vectors and we were still keeping dt^2 terms that are not necessary (see App. C.2 in https://arxiv.org/pdf/1711.02508.pdf)

Solution

Force the simplifications of unit quaternions and dt^2 terms before generating the code. To help extracting the dt^2, the derivation now uses "gyro", "accel" and "dt" inputs instead of "d_ang" and "d_vel".

This reduces the covariance prediction operations by 652.
Also frees 3688 bytes of flash (testes on fmu-v5).

Test coverage

unit, SITL

@bresch bresch added the EKF2 label Nov 10, 2023
@bresch bresch requested a review from dagar November 10, 2023 13:32
@bresch bresch self-assigned this Nov 10, 2023
imu_delayed.delta_ang, imu_delayed.delta_ang_dt, d_ang_var);
imu_delayed.delta_vel / math::max(imu_delayed.delta_vel_dt, FLT_EPSILON), accel_var,
imu_delayed.delta_ang / math::max(imu_delayed.delta_ang_dt, FLT_EPSILON), gyro_var,
0.5f * (imu_delayed.delta_vel_dt + imu_delayed.delta_ang_dt));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dagar The dt here should really by the time between 2 covariance updates. Actually it should be the same for the other process noise integrations below that are currently using _dt_ekf_avg. I think we should use the exact dt in most places, and not the _dt_ekf_avg.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I think we should be using the real dt everywhere (time between delayed IMU samples) and if anything have protections on it upstream.

bresch added 2 commits November 14, 2023 13:53
Slight changes due to simplifications done in the covariance prediction
@dagar dagar merged commit efa12ad into main Nov 14, 2023
84 of 87 checks passed
@dagar dagar deleted the pr-ekf2-cov-pred-simplify branch November 14, 2023 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants