Playing with Kalman folding à la Brian Beckman 1 2 3.
Warning: this is a work in progress.
NB: I am extending this technique to control systems in general, and nonlinear model predictive control in particular. Check back soon for repositories exhibiting that research.
(To download Dr. Beckman's papers, and see others in the series, click here.)
Programs herein are written as unit-tests (using Catch2).
Each of the programs in /src
correspond to Dr. Beckman's papers, and the filenames in that directory indicate which papers they correspond to.
NB: This code is not DRY. There is a bit of repeat code for the sake of self-containedness.
In 1, Dr. Beckman introduces the static Kalman filter in a series of four preludes, the fourth being an implementation of a static Kalman filter. (Static meaning that model states do not vary with the independent variable). Those preludes are reproduced in /src/Kalman-Folding-1-Presldes.cpp
.
In 2, Dr. Beckman generalizes to the non-static case where the model includes a control input term in addition to the drift term. Beckman's exhibition centres on a textbook example from Zarchan and Musoff4. This is reproduced in /src/Kalman-Folding-2-falling_object.cpp
. The illustrative output from that program (with -DWITH_PLOT=on
) as follows:
Finally, in 3 Dr. Beckman extends the method to streams and observables. Since a key advantage of these lines of abstractions is that the Kalman filtering behaviour is decoupled from the data structures used to organize input and output of the filter, I didn't take care to reproduce this paper faithfully. Instead, I am most interested in the push-based (observable) case. I use Sodium, a library implementing Conal Elliott's Functional Reactive Programming (FRP). That work is found in Kalman-Folding-4-frp.cpp
. Because of pressures from upstream research, I have also used RxCpp as a compromise in the reactive case. That is in Kalman-Folding-4-RxCpp.cpp
. Those programs should produce images (with -DWITH_PLOT=on
) as follows:
These files are meant to be self-documenting, but I'm certain to have been less than perfect in that effort. If I've been unclear anywhere and you feel something deserves explanation, even when read alongside Beckman's papers, please file an issue or otherwise let me know. I'm @timtro on Twitter.
- CMake
- Catch2
- Eigen3 (Debian/Ubuntu:
sudo apt install libeigen3-dev
) - Boost.Hana (only for Currying, I'll probably eliminate this dependency if anyone asks.)
- Range-v3
- Sodium-C++ (for the functional reactive programming implementation)
- RxCpp (Alternative to FRP.)
- Gnuplot (if you use
cmake -DWITH_PLOT=on
)