I'm going to describe the problem I'm trying to solve and walk through what I understand so far about the Kalman Filter.
I have an IMU which gives me the following measurements every time interval t: accelerations (Ax, Ay, Az), and gyroscope giving angular velocities (pitch, roll, yaw). I want to use sensor fusion (combining the data) to get a very accurate estimate of absolute position (x,y,z) and angular orientation (theta1, theta2, theta3). Research suggests that a Kalman Filter is the way to go. Data fusion of the sensors can help compliment their respective errors: acc is noisy but doesn't drift; gyro is less noisy but does drift.
The model for this system would be something along the lines of:
$x_t = F_t . x_t-1 + w_t$ (no control inputs)
$z_t = H_t . x_t + v_t$
Where,
$x_t$: State at time t; holds the variables (x,y,z,theta1,theta2,theta3)
$F_t$: state transition matrix (representing differential equations, or time-difference equations in this discrete case)
$H_t$: measurement matrix, turns the state we calculate into what we (should) observe as output
$w_t$: estimate (white) noise, with covariance matrix Q_t
$v_t$: measurement (white) noise, with covariance matrix R_t
The Kalman Filter, which has a lovely derivation here, would then consist of two phases I would want to calculate at every time step: (at this stage, my state variable is an estimate)
Predict:
$x_t|t-1 = F_t . x_t-1|t-1$
$P_t|t-1 = F_t . P_t-1|t-1 . F_tT + Q_t$
Where P is the state variance matrix, = covariance($x_t - x_t|t)$
Update:
$x_t|t = x_t|t-1 + K_t . y_t$, and $y_t = z_t - H_t . x_t|t-1$
$K_t = P_t|t-1 . H_tT . (H_t . P_t|t-1 . H_tT + R_t)-1$
$P_t|t = (I - K_t . H_t) . P_t|t-1$
Where $z_t$ is measured output from the sensors, $K_t$ is the Kalman Gain, $R_t$ is measurement covariance, $I$ is the identity matrix. This much makes sense from the Kalman Filter theory I've learned.
Putting it together:
I need to identify the matrices, namely F, H, P, Q, R. This is where I get stuck. H seems to be about the dynamics of the system: transform the accelerations and angular velocities into position and angle. What would that matrix look like? Then there's F, updating the previous state to the next state. I'm not sure how to do that. From what I understand, P is based on initial conditions of how much you "trust" your initial starting position estimate, i.e. $P_0|0$ = diag(large numbers) if you don't "trust" it.
Not sure about Q and R either. R is the measurement noise, meaning I could probably sit the IMU in a stationary position, see how the numbers jump about (noise), and come up with something yeah? I'm not sure what's a good process for doing that. Finally Q, the "error due to process" - is this like the error that my F matrix produces? How would one measure this?
In summary, I am stuck on the dynamic model, and identifying the matrices, particularly Q and R. I'd be happy to be linked to sources that detail the solution to this or something very similar. Thanks!