In GNC you never observe the true state x (position, velocity, attitude) directly. You have:
A model of how the state evolves ("if I fire the thruster, velocity increases by…") — but the model is imperfect.
Sensors (GPS, IMU, star tracker) — but they are noisy.
Neither alone is trustworthy. The Kalman filter answers: given a shaky prediction AND a shaky measurement, what is the single best estimate? The answer is a precision-weighted average, and the filter tracks not just the estimate but also how confident it is.
Two independent Gaussians multiply. Their exponents add:
−2σa2(x−a)2−2σb2(x−b)2.
Minimise over x (the peak of a Gaussian = its mean). Differentiate, set to zero:
σa2x−a+σb2x−b=0⇒x(σa21+σb21)=σa2a+σb2b.
Solve → the weighted average above. Why this step? The product of Gaussians is Gaussian, so finding its mean = finding where the log-likelihood is maximal.
Rewrite in "correction" form. Let K=σa2+σb2σa2 (the gain):
x^=a+K(b−a),σ2=(1−K)σa2.
This is the seed of the full Kalman update: old estimate + gain × (measurement − prediction).
Mean. Take expectation of xk=Fxk−1+Buk+wk, with E[wk]=0:
x^k−=Fx^k−1+Buk
Covariance. Define the prior error ek−=xk−x^k−. Substitute:
ek−=(Fxk−1+Buk+wk)−(Fx^k−1+Buk)=Fek−1+wk.
Then
Pk−=E[ek−ek−⊤]=E[(Fek−1+wk)(Fek−1+wk)⊤].
Expand. Cross terms vanish because wk is independent of the previous error:
Pk−=FPk−1F⊤+Q
We have a prior (x^k−,Pk−) and a fresh measurement zk. Correct the estimate.
Innovation (surprise): yk=zk−Hx^k− — how far the measurement is from what we predicted.
Corrected estimate: old + gain × surprise:
x^k=x^k−+Kkyk.
Derive the gain Kk. We choose Kk to minimise the posterior error variancetr(Pk).
Posterior error: ek=xk−x^k. Since zk=Hxk+vk:
ek=xk−x^k−−Kk(Hxk+vk−Hx^k−)=(I−KkH)ek−−Kkvk.
Compute covariance (using ek− independent of vk):
Pk=(I−KkH)Pk−(I−KkH)⊤+KkRKk⊤.(⋆)
This is the Joseph form (always valid, numerically stable).
Minimise tr(Pk). Differentiate w.r.t. Kk and set to zero (using ∂tr(KAK⊤)/∂K=2KA):
∂Kk∂tr(Pk)=−2(I−KkH)Pk−H⊤+2KkR=0.
Solve:
KkPk−H⊤H...⇒Kk(HPk−H⊤+R)=Pk−H⊤Kk=Pk−H⊤(HPk−H⊤+R)−1
Simplify covariance. Substitute the optimal Kk into (⋆) — the KRK⊤ term collapses:
Pk=(I−KkH)Pk−
Imagine you're guessing where your friend is walking. Your brain says "he was going that way, so he's probably here now" — but you're not sure. Then you glance and sort of see him — but your eyes are blurry too. So you make a smart guess between the two. If your glimpse was clear, you trust your eyes more; if it was really blurry, you trust your brain-guess more. The Kalman filter is a calculator that does exactly this blending — and it also keeps score of how sure it is, so next time it knows whether to trust its memory or its eyes.
Dekho, Kalman filter ka core idea bahut simple hai: tumhare paas do "guesses" hain ek hidden state (jaise position ya velocity) ke baare mein. Ek guess aata hai tumhare physics model se — "pichli baar yahan tha, itni speed thi, toh ab yahan hoga" — ye hai predict step. Doosra guess aata hai sensor se (GPS, IMU) — lekin dono hi thode galat hain, dono mein noise hai. Kalman filter dono ko uncertainty ke hisaab se weight karke ek best estimate banata hai. Jiski variance chhoti (jo zyada bharosemand), usko zyada weight milta hai.
Predict step mein tum estimate ko aage badhate ho (x^−=Fx^+Bu) aur uncertainty badha dete ho (P−=FPF⊤+Q), kyunki model perfect nahi hai — isliye +Q. Update step mein tum measurement lete ho, innovation nikalte ho (y=z−Hx^− = surprise, matlab kitna galat tha prediction), aur Kalman gainK se estimate ko correct karte ho. Gain ka formula K=P−H⊤/S basically bolta hai "prior uncertainty divided by total uncertainty" — bilkul 1-D wale weighted average jaisa.
Sabse important intuition: agar sensor bahut accha hai (R chhota), K bada ho jaata hai, filter measurement pe zyada bharosa karta hai. Agar model bahut accha hai (P− chhota), K chhota, filter apni prediction pe rehta hai. Aur ek common galti — kabhi Q=0 mat karo, warna filter sochta hai "mera model perfect hai" aur saare measurements ignore karke diverge kar jaata hai.
GNC mein ye filter har jagah use hota hai — rocket, drone, satellite ki position/attitude estimate karne ke liye. Real state kabhi directly nahi dikhta, toh Kalman filter noisy sensors aur imperfect model ko blend karke best estimate deta hai, saath mein confidence bhi track karta hai. Yaad rakho loop: Predict → Update → Predict → Update, chalta rehta hai.