FILTER_KALMAN(9)
π filter_kalman β HAL Component, section 9 π
okay bestie, sit down, hydrate, because we're doing a Kalman filter today and it's honestly iconic. this is FILTER_KALMAN(9) from the LinuxCNC docs and we're gonna make it make sense π«Ά
β¨ NAME β¨
filter_kalman β a Unidimensional Kalman filter, which also goes by the fancier government name linear quadratic estimation (LQE for the girlies in a hurry π ).
β¨ SYNOPSIS β¨
loadrt filter_kalman [count=N|names=name1[,name2...]]
that's it. that's the whole load line. she's simple, she's effective πΈ
β¨ DESCRIPTION β¨
so like, what is she FOR? reducing input signal noise β think voltage sensors, temperature sensors, all those lil guys who be actin' up with jittery readings π. she smooths them out. main character energy fr fr.
more info lives here: https://en.wikipedia.org/wiki/Kalman_filter
π adjusting Qr and Qk covariances π
okay here's the tea. the default values of Rk and Qk are given for informational purpose only. like, they are NOT the vibe you should just trust. the nature of the filter literally requires the parameters to be individually computed. no shortcuts, bestie β the filter wants bespoke numbers π
one of the possible and quite practical methods (and, ngl, probably far from being the best) of estimating the Rk covariance is this:
- collect the raw data from the sensor β either by asserting the
debugpin or by usinghalscopeπ - then compute the covariance using the
cov()function from the Octave package
and because we're nice, there's a ready-to-use script right here: https://github.com/dwrobel/TrivialKalmanFilter/blob/master/examples/DS18B20Test/covariance.m
adjusting Qk covariance mostly depends on the required response time of the filter. there's a whole relationship between Qk and response time, and it goes like this: the lower the Qk covariance is, the slower the response of the filter is. the way that math justβ¦ does that π
common practice is also to conservatively set Rk and Qk slightly larger then computed ones to get robustness. (yes, "then". that's what the doc says. we're keeping it. π)
β¨ FUNCTIONS β¨
filter-kalman.Nβ needs a floating-point thread to live her truth. she updatesxk-outbased on thezkinput. that's her whole job and she does it flawlessly β¨
β¨ PINS β¨
all of these are per-instance, so N is your instance number β like filter-kalman.0, filter-kalman.1, etc. count them, name them, love them π
filter-kalman.N.debugβ bit, in. default:FALSE. when you assert this bad boy, she prints out measured and estimated values. like a lil live commentary π£οΈfilter-kalman.N.passthroughβ bit, in. default:FALSE. when asserted, she copies the measured value straight into the estimated value. no filtering, just vibes. instant β¨filter-kalman.N.resetβ bit, in. default:FALSE. when asserted, she resets the filter to its initial state and returns0as an estimated value. and FYI β the reset pin has higher priority than the passthrough pin, so if both get asserted, reset wins πfilter-kalman.N.zkβ float, in. the measured value. the raw, unfiltered, messy truth πfilter-kalman.N.xk-outβ float, out. the estimated value. the glow-up version π
β¨ PARAMETERS β¨
these are read-write, so you can go in and tweak them whenever, bestie π§
filter-kalman.N.Rkβ float,rw. default:1.17549e-38. this is your estimation of the noise covariances (process). yes girl, process noise. that's the one πfilter-kalman.N.Qkβ float,rw. default:1.17549e-38. this is your estimation of the noise covariances (observation). observation noise, the other half of the duo π
β¨ AUTHOR β¨
Dmian Wrobel <dwrobel@ertelnet.rybnik.pl> β thank you for this gift, we are obsessed π«Ά
β¨ LICENSE β¨
GPL-2.0-or-later β free as in freedom, periodt π
and that's the whole page, bestie!! no cap, you now know a Kalman filter π
signing off: this was LinuxCNC Documentation, dated 2026-03-17, filed under FILTER_KALMAN(9) β go smooth out some sensor noise, you got this π¦β¨
π¦ where this page comes from
- ubuntu resolute: linuxcnc-uspace 1:2.9.4-2ubuntu4 Β· GFDL-1.1-or-later
- ubuntu stonking: linuxcnc-uspace 1:2.9.4-2ubuntu4 Β· GFDL-1.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms