equals the accelerometer angle θa at low frequency (removes gyro drift),
equals the integrated gyro at high frequency (removes accel noise).
Take the simplest first-order low-pass Hlp(s)=1+τs1. Then the complement is forced:
Hhp(s)=1−1+τs1=1+τsτs.
Notice Hhp contains a factor s (a derivative). The gyro already gives us θ˙=sθ, so applying Hhp to the angle is like applying 1+τsτ to the rate — no explicit differentiation needed. Combine:
θ^(s)=accel1+τs1θa(s)+gyro1+τsτsθg(s)
Discretize. Replace sθ→θ˙=ωgyro (the measured rate), sample at Δt. Doing the bilinear/Euler discretization gives the famous update:
Why this step? The term θ^k−1+ωkΔt is the gyro prediction (integrate rate). Multiplying by α<1bleeds away the drift a little each step; (1−α)θa,k gently pulls the estimate back toward the absolute accel reading. That gentle pull is exactly the low-pass filtering of accel noise.
Model a 1-D state x (e.g. angle) with process and measurement:
xk=xk−1+w,w∼N(0,Q)(process noise, variance Q)zk=xk+v,v∼N(0,R)(measurement noise, variance R)
Step 1 — Predict. With no new measurement, our best guess stays, but uncertainty grows:
x^k−=x^k−1,Pk−=Pk−1+Q.Why? Adding independent process noise adds variances.
Step 2 — Fuse two Gaussians. We have a prior N(x^k−,Pk−) and a measurement N(zk,R). The product of two Gaussians is a Gaussian; minimizing the combined variance gives the fused mean. Derive by writing the posterior mean as a weighted average and choosing the weight to minimize the posterior variance.
Let the estimate be x^=x^−+K(z−x^−). Its error variance:
P=(1−K)2P−+K2R.
Minimize over K: dKdP=−2(1−K)P−+2KR=0⇒K=P−+RP−.
Recall Feynman: explain to a 12-year-old
You have two friends guessing a temperature. One friend, "Gyro-Guy," reacts super fast to changes but slowly starts lying more and more. The other, "Accel-Anne," is honest on average but jumpy and shouts random wrong numbers. If you average them the smart way — believe Gyro-Guy for quick changes but always nudge back toward honest Anne — you get a guess better than either. The complementary filter uses a fixed trust ratio. The Kalman filter is cleverer: it keeps a "how-sure-am-I" number, and each moment picks the perfect trust ratio, listening more to whichever friend is more reliable right now.
What condition must the two transfer functions in a complementary filter satisfy?
They must sum to unity, Hlp(s)+Hhp(s)=1, giving unity DC gain (no steady-state bias).
In the discrete complementary filter θ^k=α(θ^k−1+ωkΔt)+(1−α)θa, what does α control?
The trust split: α→1 trusts the gyro (smooth, drift-prone), α→0 trusts the accelerometer (drift-free, noisy). α=τ/(τ+Δt).
Why does a gyroscope need help from an accelerometer?
Integrating gyro rate accumulates bias → unbounded slow drift; the accelerometer gives an absolute (drift-free) angle at low frequency to correct it.
Write the scalar Kalman gain formula and its meaning.
K=P−+RP−; ratio of prior uncertainty to total uncertainty — more prior doubt or less measurement noise ⇒ larger gain (trust measurement more).
Derive the optimal Kalman gain.
Minimize P=(1−K)2P−+K2R over K: dP/dK=−2(1−K)P−+2KR=0⇒K=P−/(P−+R).
What is the "precisions add" identity in the Kalman update?
1/Pk=1/Pk−+1/R — fusing two Gaussian sources adds their inverse variances (information).
How does the Kalman filter relate to the complementary filter?
The complementary filter is a Kalman filter with a fixed gain; at steady state P converges and K becomes constant, so Kalman reduces to a complementary filter.
What happens if you drop +Q in the predict step?
P shrinks to 0, gain K→0, filter stops trusting new measurements → divergence.
Does larger R make the filter trust the sensor more or less?
Less — R is measurement-noise variance; larger R ⇒ smaller K.
Why do gyro (high-frequency) and accel (low-frequency) fuse well?
Their dominant errors sit in different frequency bands; complementary filtering keeps each sensor only where it is accurate.
Socho tumhare paas do sensor hain jo dono thode "galat" hain. Gyroscope rate deta hai — usko integrate karke angle nikalta hai; ye short-term me bahut smooth hota hai par dheere-dheere drift kar jaata hai (chhoti si bias jud-jud ke bigaad deti hai). Accelerometer gravity se absolute angle deta hai — drift nahi hoti, par har vibration se noise aa jaata hai. Trick ye hai: dono ke error alag frequency me baithte hain, isliye gyro ko fast changes ke liye believe karo aur accel se dheere-dheere wapas kheech lo. Yehi complementary filter hai: θ^k=α(θ^k−1+ωkΔt)+(1−α)θa, jahan α aur (1−α) ka sum hamesha 1 hota hai.
Complementary filter ka αfixed hota hai — simple, par optimal nahi. Kalman filter ismein upgrade hai: wo ek "main kitna sure hoon" number rakhta hai jise variance P kehte hain, aur har step pe best trust ratio (Kalman gain K=P−/(P−+R)) khud calculate karta hai. Jab tum kam confident ho, K bada hota hai (measurement pe zyada bharosa); jaise-jaise confident hote ho, K chhota ho jaata hai. Iski jaan ek line me: precisions add — 1/P=1/P−+1/R, matlab do source ki information jud jaati hai aur uncertainty dono se kam ho jaati hai.
Do galtiyan jo sab karte hain: (1) socho R bada matlab sensor pe zyada bharosa — galat! R noise variance hai, bada R matlab sensor gandaa, isliye K chhota, bharosa kam. (2) predict step me +Q bhool jaana — tab P zero ho jaayega, filter sochega main perfect hoon aur naye readings sunna band kar dega (divergence). Yaad rakho loop PUG: Predict, Update-gain, Get estimate.
Real GNC me — drone AHRS, aircraft INS — yehi fusion critical hai, kyunki akela gyro udd ke drift kar jaayega aur akela accel har jhatke pe naach uthega. Steady state pe Kalman ka gain constant ho jaata hai — aur tab wo bilkul complementary filter ban jaata hai. Toh dono ek hi family ke hain, bas ek simple aur ek optimal.