Hi everyone,
I’m trying to build an EKF3 model simulation in Simulink, and I’m currently stuck on the covariance update module—two key parts are unclear to me, especially when cross-referencing the ArduPilot Copter 4.6 source code:
-
For the state transition matrix F in EKF3: I know F is derived from linearizing the nonlinear state transition model (e.g., attitude, velocity, position dynamics). But I can’t figure out how exactly this linearization is implemented in Copter 4.6’s code—for example, which source files (e.g.,
EKF3.cpp,ekf3_core.cpp) define the partial derivatives of the state transition function with respect to each state (to form F’s elements)? Are there specific simplifications or approximations used for inertial sensor (IMU) error propagation here? -
For the PS intermediate terms in the covariance calculation: In the code, I see a series of
PS0toPS33variables used to compute the predicted covariance matrixnextP(e.g.,nextP[0][0]is a combination ofPS0*PS1,-PS11*PS23, etc.). However, I’m struggling to map thesePSterms back to the standard EKF covariance update formula (Pk∣k−1=FPk−1∣k−1FT+GQGT). Specifically, whichPSterms correspond to the FPFT component, and which map to the process noise term GQGT? How do thesePSterms translate to individual elements of thePmatrix (e.g., doesPS14relate toP[0][10]or another element)?
Has anyone worked on EKF3’s covariance logic in Simulink or dug into the Copter 4.6 code for these details? Any pointers to specific code lines, mathematical derivations, or Simulink implementation tips would be really helpful!