Situation
I am interested in developing my own version of EKF-based UAV state estimator, and currently analyzing PX4-Autopilot’s implementation, especially the optimization(codegen-ed) part using python symforce.
It seems that covariance prediction part of EKF is substituted with error-state version since this (and this), as well as all codegen-ed H matrices and Kalman gains. (adapted to 23-dim)
The attitude part was mainly corrected (from 4-dim quaternion to 3-dim) while the rest are mostly remained the same (since they are all in Euclidean space). You can see the equivalence inside derivation.py by comparing the two elements: A[3:, 3:] and A_old[4:, 4:] where,
- A (latest version)
= VTangent(state_error_pred.to_storage()).jacobian(state_error).subs(zero_state_error).subs(zero_noise)
- A_old (old version)
= VState(state_pred.to_storage()).jacobian(vstate)
Here, I denote the first argument of predict_covariance() function as vstate, that is before modified to its tangent-space counterpart, (i.e., before state = vstate_to_state(state))
Question
Nonetheless, the state is predicted still in its total-state version as in here (Ekf::predictState(…)).
My questions are:
-
Shouldn’t the state (of EKF of PX4-Autopilot) be defined as error-state for the exactitude?
-
Accordingly, almost all models should be re-written in terms of error-state (perhaps?)
- For instance, the prediction model
[from]: x_{k+1} = f(x_{k}) + w_{k} →
[to]: e_{k+1} = f_error(e_{k};x_{k}^{INS}) + w_{k}
where error-state (=x_k^true - x_k^estimate) is denoted in e_k. I guess f_error() is what “state_error_pred” of derivation.py should produce when codegen-ed. Also, as widely known, f_error() exhibits more linearity than f() as stated in here. I used {INS} for an independent integrator, i.e., dead-reckoning.
- measurement model
[from] y_{k} = h(x_k) + v_{k} →
[to] either (1) y_{k} = h(x_k^{INS} + e_k^{filter_state}) + v_{k} or (2) y_error{k} = h_error(e_k) + v’_{k}
- In summary, I don’t get the reason why state itself is not converted to its error-state form while covariance matrix is presented in error-state form and treated accordingly.
The “mismatch” I wrote in the topic title means this: total-state form implementation of state and its propagation vs. error-state form implementation of covariance and all related uncertainty matrices, gains, etc. Current covariance matrix P seems not (exactly) presenting the uncertainty characteristic of StateSample _state of Ekf:EstimatorInterface, or am I missing something?