Skip to content

filters: specialize three-state Kalman algebra - #871

Open
jordens wants to merge 1 commit into
pendulum-project:mainfrom
quartiq:pr/kalman-core
Open

filters: specialize three-state Kalman algebra#871
jordens wants to merge 1 commit into
pendulum-project:mainfrom
quartiq:pr/kalman-core

Conversation

@jordens

@jordens jordens commented Aug 20, 2026

Copy link
Copy Markdown

The current statime Kalman filter implementation is very much vanilla textbook: three state with dense 3x3 f64 covariance data and calculations.

This implements specialized direct scalar updates instead.

It replaces general matrix operations with the equivalent scalar recurrences for
this fixed three-state model. The public filter behavior (API and quantitatively) is strictly unchanged. That assertion is unit-tested against the old dense algebra (which is kept around but does make the patch rather large): randomized tests cover prediction, every observation, and clock steering.

This has a significant impact on CPU load and code size: on the host, prediction plus all three observations is about 4.3x faster (21-25 ns instead of 93-109 ns here). On embedded STM32F7, the example uses 9.6 KiB less text; the update routine shrinks from about 1.9 KiB to 0.6 KiB.

I know statime is on hold for the big ntpd-rs work. I'm putting this out anyway because it may still become useful wherever the kalman filter ends up living.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants