Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

EKF: fix covariance and output filter buffer initialization #586

Merged
merged 8 commits into from
Mar 12, 2019

Conversation

CarlOlsson
Copy link
Contributor

This PR fixes several issues that were present in the initialization of the attitude covariances and the output filter buffer.

  • Issue 1: The attitude covariances were initialized before the attitude which does not work properly since the initialization is dependent on the attitude.
  • Issue 2: After the attitude was initialized we rotate the yaw angle. In this function we also rotated all attitude solutions in the output buffer. However, the data in the buffer did not include the tilt rotation. So the "yaw rotation" was applied along a completely different axis.
  • Issue 3: At the end of the initialization we align the output filter to match the state estimate at the delayed time horizon. However, the rotation was applied in the wrong direction.
  • Issue 4: The _output_new quaternion was not initialized to a valid quaternion

This PR changes the EKF initialization to:

  1. init tilt
  2. init yaw
  3. init tilt uncertainty
  4. init yaw uncertainty

This have quite large consequences. Below is a logfile with high temperature gradient replayed with master code and this PR.

On master the delta velocity bias states diverge before takeoff triggering a reset of the covariance matrix while on the PR they are stable

master/PR
image

This is because on the PR the uncertainty in the delta velocity bias aligned with gravity decrease much faster since this axis is more observable than the axes aligned with the horizontal plane.

master/PR
Note that this plot is from a tailsitter with body x axis facing upwards
image

This is a plot comparing the attitude estimate at the current time and at the delayed time horizon right after the EKF initialization. (This is normally not logged since the ekf2_main.cpp only logs the attitude estimate when tilt is aligned. So for testing the attitude estimate at the current time is added to estimator status)

master/PR
image

Signed-off-by: CarlOlsson <carlolsson.co@gmail.com>
Signed-off-by: CarlOlsson <carlolsson.co@gmail.com>
in alignOutputFilter()

Signed-off-by: CarlOlsson <carlolsson.co@gmail.com>
alignOutputFilter()

Signed-off-by: CarlOlsson <carlolsson.co@gmail.com>
Signed-off-by: CarlOlsson <carlolsson.co@gmail.com>
1) init tilt
2) init yaw
3) init tilt uncertainty
4) init yaw uncertainty

Signed-off-by: CarlOlsson <carlolsson.co@gmail.com>
@mrivi
Copy link
Contributor

mrivi commented Mar 11, 2019

I have noticed a big drift in the z position when leaving the simulation running for a couple of minutes with the vehicle on the ground unarmed. This PR fixes this issue.

Current master:
z_drift

This PR:
no_drift

@LorenzMeier LorenzMeier requested a review from RomanBapst March 11, 2019 14:14
Copy link
Collaborator

@priseborough priseborough left a comment

Choose a reason for hiding this comment

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

Good work.

Copy link
Contributor

@RomanBapst RomanBapst left a comment

Choose a reason for hiding this comment

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

@CarlOlsson Nice!

@priseborough priseborough merged commit 1d91785 into PX4:master Mar 12, 2019
dagar pushed a commit to priseborough/PX4-Autopilot that referenced this pull request Mar 13, 2019
Bug Fixes:

PX4/PX4-ECL#586 - EKF: fix covariance and output filter buffer initialization
PX4/PX4-ECL#590 - EKF: Fix innovation in fuseDeclination()

Enhancements:

PX4/PX4-ECL#543 - ekf_helper: add more useful methods to interface with the covariances
PX4/PX4-ECL#588 - Add unit tests for DataValidator

Note:

PX4/PX4-ECL#543  has required a change to how the state variances are accessed .
priseborough added a commit to PX4/PX4-Autopilot that referenced this pull request Mar 14, 2019
Bug Fixes:

PX4/PX4-ECL#586 - EKF: fix covariance and output filter buffer initialization
PX4/PX4-ECL#590 - EKF: Fix innovation in fuseDeclination()

Enhancements:

PX4/PX4-ECL#543 - ekf_helper: add more useful methods to interface with the covariances
PX4/PX4-ECL#588 - Add unit tests for DataValidator

Note:

PX4/PX4-ECL#543  has required a change to how the state variances are accessed .
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants