-
Notifications
You must be signed in to change notification settings - Fork 13.6k
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: constrain max variance by zero innovation update #24214
Conversation
Clipping the variance of the covariance matrix has a destabilizing effect as it increases the correlation between the states.
🔎 FLASH Analysispx4_fmu-v5x [Total VM Diff: -64 byte (-0 %)]
px4_fmu-v6x [Total VM Diff: -64 byte (-0 %)]
Updated: 2025-01-14T15:34:06 |
So if I understand correctly, the filter would artificially decrease the correlation when we enforce the minimal variance? I guess this would not happen since we've chosen those limits rand the measurement uncertainty reasonably. |
It could still occur in the accel bias case for example where a maximum condition number between the accel bias states is enforced and that all 3 axes are not observable at the same time. But it's not really harmful, just sub-optimal |
Zero innovation heading update? |
Good point, I think there is room for improvement in general in the yaw fusion code as the measurement jacobian is now trivial and can be considered as a "direct state measurement" (correct in the context of the error state formulation). |
Solved Problem
We cannot let the covariance of a temporarily unobservable state grow for ever due to numerical issues that will arise when the the matrix is getting ill-conditioned but the current method of clipping the variance has a destabilizing effect as it increases the correlation between the states. (recall:
correlation = cov_xy / (sqrt(var_x) * sqrt(var_y)
so ifcov_xy
grows butvar_x
orvar_y
increases,correlation
increases)This can be observed on the position state when flying without GNSS (e.g.: navigating with optical flow or airspeed data). When the position variance reaches the limit of 1e6, clipping it causes the correlation with the velocity state to increase and when a single position observation is fused (here sent via a manual position update), the velocity variance collapses (over-correction).
In reality, the calculated velocity variance is negative but artificially clipped to a minimum value of 1e-6.
Note that there is no problem in artificially limiting the minimum value of a state variance as this is similar to having a higher process noise and reduces the correlation with other states without causing instabilities.
Solution
Run a "zero innovation update" to keep the variance of a state below the "numerical stability threshold".
We can see that after the manual position update, the velocity variance is updated to a reasonable value.
Alternatives
The UDU formulation should avoid the need for an upper variance limit.
Test coverage
SITL tests