---
name: "filter_kalman"
section: "9"
platform: "linux"
package: "linuxcnc-uspace"
version: "1:2.9.4-2+deb13u1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/filter_kalman"
---

# filter\_kalman(9)

Unidimensional Kalman filter, also known as linear quadratic estimation (LQE)

## NAME

filter\_kalman - Unidimensional Kalman filter, also known as linear quadratic estimation (LQE)

## SYNOPSIS

**loadrt filter\_kalman \[count=*N*\|names=*name1*\[,*name2...*\]\]**

## DESCRIPTION

Useful for reducing input signal noise (e.g. from the voltage or temperature sensor).

More information can be found at https://en.wikipedia.org/wiki/Kalman\_filter.

Adjusting **Qr** and **Qk** covariances:

Default values of **Rk** and **Qk** are given for informational purpose only. The nature of the filter requires the parameters to be individually computed.

One of the possible and quite practical method (probably far from being the best) of estimating the **Rk** covariance is to collect the raw data from the sensor by either asserting the **debug** pin or using **halscope** and then compute the covariance using **cov()** function from **Octave** package. Ready to use script can be found at 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 is a relationship between **Qk** and response time of the filter that the lower the **Qk** covariance is the slower the response of the filter is.

Common practice is also to conservatively set **Rk** and **Qk** slightly larger then computed ones to get robustness.

## FUNCTIONS

- **filter-kalman.***N* (requires a floating-point thread)

  Update **xk-out** based on **zk** input.

## PINS

- **filter-kalman.*N*.debug bit in (default: *FALSE*)**

  When asserted, prints out measured and estimated values.

- **filter-kalman.*N*.passthrough bit in (default: *FALSE*)**

  When asserted, copies measured value into estimated value.

- **filter-kalman.*N*.reset bit in (default: *FALSE*)**

  When asserted, resets filter to its initial state and returns 0 as an estimated value (**reset** pin has higher priority than **passthrough** pin).

- **filter-kalman.*N*.zk float in**

  Measured value.

- **filter-kalman.*N*.xk-out float out**

  Estimated value.

## PARAMETERS

- **filter-kalman.*N*.Rk float rw (default: *1.17549e-38*)**

  Estimation of the noise covariances (process).

- **filter-kalman.*N*.Qk float rw (default: *1.17549e-38*)**

  Estimation of the noise covariances (observation).

## AUTHOR

Dmian Wrobel \<dwrobel@ertelnet.rybnik.pl\>

## LICENSE

GPL-2.0-or-later
