Skip to content

Commit 38ab44d

Browse files
[documentation] expand documentation
1 parent c49d103 commit 38ab44d

File tree

2 files changed

+78
-72
lines changed

2 files changed

+78
-72
lines changed

README.md

+53-43
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,36 @@
22

33
A generic Kalman filter for C++23.
44

5-
A Bayesian filter that uses multivariate Gaussians, a recursive state estimator, and a linear quadratic estimator (LQE). A control theory tool applicable to signal estimation, sensor fusion, or data assimilation problems.
5+
The Kalman filter is a Bayesian filter that uses multivariate Gaussians, a recursive state estimator, a linear quadratic estimator (LQE), and an Infinite Impulse Response (IIR) filter. It is a control theory tool applicable to signal estimation, sensor fusion, or data assimilation problems. The filter is applicable for unimodal and uncorrelated uncertainties. The filter assumes white noise, propagation and measurement functions are differentiable, and that the uncertainty stays centered on the state estimate. The filter is the optimal linear filter under assumptions. The filter updates estimates by multiplying Gaussians and predicts estimates by adding Gaussians. Designing a filter is as much art as science. Design the state $X$, $P$, the process $F$, $Q$, the measurement $Z$, $R$, the measurement function $H$, and if the system has control inputs $U$, $G$.
66

7-
Simple and extended filters are supported. The update equation uses the Joseph form. Control input is supported. Standard and type-erased Eigen3 linear algebra backends are supported.
8-
9-
The Kalman filter is applicable for unimodal and uncorrelated uncertainties. The filter assumes white noise, propagation and measurement functions are differentiable, and that the uncertainty stays centered on the state estimate. The filter is the optimal linear filter under assumptions. The filter updates estimates by multiplying Gaussians and predicts estimates by adding Gaussians.
10-
11-
Designing a filter is as much art as science. Design the state $X$, $P$, the process $F$, $Q$, the measurement $Z$, $R$, the measurement function $H$, and if the system has control inputs $U$, $G$.
12-
13-
Arbitrary parameters can be added to the prediction and update stages to participate in gain-scheduling or linear parameter varying (LPV) systems.
14-
15-
Filters with `state x output x input` dimensions as 1x1x1 and 1x1x0 (no input) are supported through the Standard Templated Library (STL). Higher dimension filters require Eigen 3 support.
16-
17-
Standard formatter specialization provided for representation of the filter states.
7+
This library supports simple and extended filters. The implementation is independent from linear algebra backends. Arbitrary parameters can be added to the prediction and update stages to participate in gain-scheduling or linear parameter varying (LPV) systems. The default filter type is a generalized, customizable, and extended filter. The default type parameters represent a one-state, one-output double-precision floating-point type. The default update equation uses the Joseph form. Examples illustrate various usages and implementation tradeoffs. Standard formatter specialization provided for representation of the filter states. Filters with `state x output x input` dimensions as 1x1x1 and 1x1x0 (no input) are supported through vanilla C++. Higher dimension filters require a linear algebra backend. Customization points and type injections allow for implementation tradeoffs.
188

199
- [Kalman Filter for C++](#kalman-filter-for-c)
2010
- [Examples](#examples)
2111
- [1x1 Constant System Dynamic Model Filter](#1x1-constant-system-dynamic-model-filter)
2212
- [6x2 Constant Acceleration Dynamic Model Filter](#6x2-constant-acceleration-dynamic-model-filter)
23-
- [4x1 Non-Linear Dynamic Model Extended Filter](#4x1-non-linear-dynamic-model-extended-filter)
13+
- [4x1 Nonlinear Dynamic Model Extended Filter](#4x1-nonlinear-dynamic-model-extended-filter)
2414
- [Other Examples](#other-examples)
25-
- [Class kalman](#class-kalman)
26-
- [Declaration](#declaration)
27-
- [Template Parameters](#template-parameters)
28-
- [Member Types](#member-types)
29-
- [Member Functions](#member-functions)
30-
- [Characteristics](#characteristics)
31-
- [Modifiers](#modifiers)
32-
- [Format](#format)
3315
- [Installation](#installation)
16+
- [Reference](#reference)
17+
- [Class kalman](#class-kalman)
18+
- [Declaration](#declaration)
19+
- [Template Parameters](#template-parameters)
20+
- [Member Types](#member-types)
21+
- [Member Functions](#member-functions)
22+
- [Characteristics](#characteristics)
23+
- [Modifiers](#modifiers)
24+
- [Format](#format)
3425
- [Considerations](#considerations)
3526
- [Motivations](#motivations)
3627
- [Selected Tradeoffs](#selected-tradeoffs)
3728
- [Lessons Learned](#lessons-learned)
3829
- [Performance](#performance)
3930
- [Resources](#resources)
40-
- [Continuous Integration & Deployment Actions](#continuous-integration--deployment-actions)
31+
- [Definitions](#definitions)
32+
- [Articles](#articles)
33+
- [Definitions](#definitions-1)
34+
- [Continuous Integration \& Deployment Actions](#continuous-integration--deployment-actions)
4135
- [Third Party Acknowledgement](#third-party-acknowledgement)
4236
- [Sponsors](#sponsors)
4337
- [Corporate Sponsor](#corporate-sponsor)
@@ -100,7 +94,7 @@ filter.update(-375.93, 301.78);
10094
10195
[full sample code](sample/kf_6x2x0_vehicle_location.cpp)
10296
103-
## 4x1 Non-Linear Dynamic Model Extended Filter
97+
## 4x1 Nonlinear Dynamic Model Extended Filter
10498
10599
Example from the [thermal, current of warm air, strength, radius, and location estimation](https://francoiscarouge.github.io/Kalman/ekf_4x1x0_soaring_8cpp-example.xhtml) sample. Four estimated states and one observed output extended filter with two additional prediction arguments and two additional update arguments.
106100
@@ -156,11 +150,24 @@ filter.update(position_x, position_y, variometer);
156150
- 2x1x1 constant acceleration dynamic model filter of the [1-dimension position and velocity of a rocket altitude](sample/kf_2x1x1_rocket_altitude.cpp).
157151
- 8x4 constant velocity dynamic model filter of the [2-dimension position and velocity of the center, aspect ratio, and height of a bounding box](sample/kf_8x4x0_deep_sort_bounding_box.cpp).
158152

159-
# Class kalman
153+
# Installation
154+
155+
```shell
156+
git clone --depth 1 https://github.com/FrancoisCarouge/Kalman.git "kalman"
157+
cmake -S "kalman" -B "build"
158+
cmake --build "build" --parallel
159+
sudo cmake --install "build"
160+
```
161+
162+
[For more, see installation instructions](INSTALL.md).
163+
164+
# Reference
165+
166+
## Class kalman
160167

161168
Also documented in the [fcarouge/kalman.hpp](include/fcarouge/kalman.hpp) header.
162169

163-
## Declaration
170+
### Declaration
164171

165172
```cpp
166173
template <
@@ -173,7 +180,7 @@ template <
173180
class kalman
174181
```
175182
176-
## Template Parameters
183+
### Template Parameters
177184
178185
| Template Parameter | Definition |
179186
| --- | --- |
@@ -184,7 +191,7 @@ class kalman
184191
| `UpdateTypes` | The additional update function parameter types passed in through a tuple-like parameter type, composing zero or more types. Parameters such as delta times, variances, or linearized values. The parameters are propagated to the function objects used to compute the state observation $H$ and the observation noise $R$ matrices. The parameters are also propagated to the state observation function object $H$. Defaults to no parameter types, the empty pack. |
185192
| `PredictionTypes` | The additional prediction function parameter types passed in through a tuple-like parameter type, composing zero or more types. Parameters such as delta times, variances, or linearized values. The parameters are propagated to the function objects used to compute the process noise $Q$, the state transition $F$, and the control transition $G$ matrices. The parameters are also propagated to the state transition function object $F$. Defaults to no parameter types, the empty pack. |
186193
187-
## Member Types
194+
### Member Types
188195
189196
| Member Type | Dimensions | Definition | Also Known As |
190197
| --- | --- | --- | --- |
@@ -201,15 +208,15 @@ class kalman
201208
| `state_transition` | x by x | Type of the state transition matrix `f`. | $F$, $Φ$, $A$ |
202209
| `state` | x by 1 | Type of the state estimate column vector `x`. | $X$ |
203210
204-
## Member Functions
211+
### Member Functions
205212
206213
| Member Function | Definition |
207214
| --- | --- |
208215
| `(constructor)` | Constructs the filter. |
209216
| `(destructor)` | Destructs the filter. |
210217
| `operator=` | Assigns values to the filter. |
211218
212-
### Characteristics
219+
#### Characteristics
213220
214221
| Characteristic | Definition |
215222
| --- | --- |
@@ -228,14 +235,14 @@ class kalman
228235
| `transition` | Manages the state transition function object $f$. Configures the callable object of expression `state(const state &, const input &, const PredictionTypes &...)` to compute the transition state value. The default value is the equivalent to $f(x) = F * X$. The default function is suitable for linear systems. For extended filters `transition` is a linearization of the state transition while $F$ is the Jacobian of the transition function: $F = ∂f/∂X = ∂fj/∂xi$ that is each row $i$ contains the derivatives of the state transition function for every element $j$ in the state column vector $X$. |
229236
| `observation` | Manages the state observation function object $h$. Configures the callable object of expression `output(const state &, const UpdateTypes &...arguments)` to compute the observation state value. The default value is the equivalent to $h(x) = H * X$. The default function is suitable for linear systems. For extended filters `observation` is a linearization of the state observation while $H$ is the Jacobian of the observation function: $H = ∂h/∂X = ∂hj/∂xi$ that is each row $i$ contains the derivatives of the state observation function for every element $j$ in the state vector $X$. |
230237
231-
### Modifiers
238+
#### Modifiers
232239
233240
| Modifier | Definition |
234241
| --- | --- |
235242
| `predict` | Produces estimates of the state variables and uncertainties. |
236243
| `update` | Updates the estimates with the outcome of a measurement. |
237244
238-
# Format
245+
## Format
239246
240247
A specialization of the standard formatter is provided for the filter. Use `std::format` to store a formatted representation of all of the characteristics of the filter in a new string. Standard format parameters to be supported.
241248
@@ -246,17 +253,6 @@ std::print("{}", filter);
246253
// {"f": 1, "h": 1, "k": 1, "p": 1, "q": 0, "r": 0, "s": 1, "x": 0, "y": 0, "z": 0}
247254
```
248255

249-
# Installation
250-
251-
```shell
252-
git clone --depth 1 https://github.com/FrancoisCarouge/Kalman.git "kalman"
253-
cmake -S "kalman" -B "build"
254-
cmake --build "build" --parallel
255-
sudo cmake --install "build"
256-
```
257-
258-
[For more, see installation instructions](INSTALL.md).
259-
260256
# Considerations
261257

262258
## Motivations
@@ -270,7 +266,7 @@ This package explores what could be a Kalman filter implementation a la standard
270266

271267
## Selected Tradeoffs
272268

273-
In theory there is no difference between theory and practice, while in practice there is. The following engineering tradeoffs have been selected for the implementation:
269+
In theory there is no difference between theory and practice, while in practice there is. The following engineering tradeoffs have been selected for this library implementation:
274270

275271
- Update and prediction additional arguments are stored in the filter at the costs of memory and performance for the benefits of consistent data access and records.
276272
- The default floating point data type for the filter is `double` with about 16 significant digits to reduce loss of information compared to `float`.
@@ -293,6 +289,18 @@ The [benchmarks](benchmark) share some performance information. Custom specializ
293289

294290
# Resources
295291

292+
## Definitions
293+
294+
| Term | Definition |
295+
| --- | --- |
296+
| EKF | The Extended Kalman Filter is the nonlinear version of the Kalman filter. Useful for nonlinear dynamics systems. This filter linearizes the model about an estimate working point of the current mean and covariance. |
297+
| ESKF | The Error State Kalman Filter is the error estimation version of the Kalman filter. Useful for linear error state dynamics systems. This filter estimates the errors rather than the states.
298+
| UKF | The Unscented Kalman Filter is the sampled version of the Extended Kalman Filter. Useful for highly nonlinear dynamics systems. This filter samples sigma points about an estimate working point of the current mean using an Unscented Transformation technique. |
299+
300+
Further terms should be defined and demonstrated for completeness: CKF, EnKF, Euler-KF, Forward-Backward, FKF, IEKF, Joseph, KF, MEKF, MRP-EKF, MRP-UKF, MSCKF, SKF, Smoother, USQUE, UDU, UT.
301+
302+
## Articles
303+
296304
Resources to learn about Kalman filters:
297305

298306
- [A New Approach to Linear Filtering and Prediction Problems](https://www.cs.unc.edu/~welch/kalman/kalmanPaper.html) by Kalman, Rudolph Emil in Transactions of the ASME - Journal of Basic Engineering, Volume 82, Series D, pp 35-45, 1960 - Transcription by John Lukesh.
@@ -302,6 +310,8 @@ Resources to learn about Kalman filters:
302310
- [Wikipedia Kalman filter](https://en.wikipedia.org/wiki/Kalman_filter) by Wikipedia, the free encyclopedia.
303311
- [Applications of Kalman Filtering in Aerospace 1960 to the Present](https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=5466132) by Mohinder S. Grewal and Angus P. Andrews. IEEE 2010.
304312

313+
# Definitions
314+
305315
# Continuous Integration & Deployment Actions
306316

307317
[![Code Repository](https://img.shields.io/badge/Repository-GitHub%20%F0%9F%94%97-brightgreen)](https://github.com/FrancoisCarouge/Kalman)

include/fcarouge/kalman.hpp

+25-29
Original file line numberDiff line numberDiff line change
@@ -62,36 +62,32 @@ template <typename... Types> using pack = internal::pack<Types...>;
6262

6363
//! @brief A generic Kalman filter for C++23.
6464
//!
65-
//! @details A Bayesian filter that uses multivariate Gaussians, a recursive
66-
//! state estimator, and a linear quadratic estimator (LQE). A control theory
67-
//! tool applicable to signal estimation, sensor fusion, or data assimilation
68-
//! problems.
65+
//! @details The Kalman filter is a Bayesian filter that uses multivariate
66+
//! Gaussians, a recursive state estimator, a linear quadratic estimator (LQE),
67+
//! and an Infinite Impulse Response (IIR) filter. It is a control theory tool
68+
//! applicable to signal estimation, sensor fusion, or data assimilation
69+
//! problems. The filter is applicable for unimodal and uncorrelated
70+
//! uncertainties. The filter assumes white noise, propagation and measurement
71+
//! functions are differentiable, and that the uncertainty stays centered on the
72+
//! state estimate. The filter is the optimal linear filter under assumptions.
73+
//! The filter updates estimates by multiplying Gaussians and predicts estimates
74+
//! by adding Gaussians. Designing a filter is as much art as science. Design
75+
//! the state $X$, $P$, the process $F$, $Q$, the measurement $Z$, $R$, the
76+
//! measurement function $H$, and if the system has control inputs $U$, $G$.
6977
//!
70-
//! Simple and extended filters are supported. The update equation uses the
71-
//! Joseph form. Control input is supported. Various customization point objects
72-
//! allow for using different linear algebra backends for which standard or
73-
//! Eigen3 implementation is provided.
74-
//!
75-
//! The Kalman filter is applicable for unimodal and uncorrelated uncertainties.
76-
//! The filter assumes white noise, propagation and measurement functions are
77-
//! differentiable, and that the uncertainty stays centered on the state
78-
//! estimate. The filter is the optimal linear filter under assumptions. The
79-
//! filter updates estimates by multiplying Gaussians and predicts estimates by
80-
//! adding Gaussians.
81-
//!
82-
//! Designing a filter is as much art as science. Design the state (X, P), the
83-
//! process (F, Q), the measurement (Z, R), the measurement function H, and if
84-
//! the system has control inputs (U, B).
85-
//!
86-
//! Arbitrary parameters can be added to the prediction and update stages to
87-
//! participate in gain-scheduling or linear parameter varying (LPV) systems.
88-
//!
89-
//! Filters with `state x output x input` dimensions as 1x1x1 and 1x1x0 (no
90-
//! input) are supported through the Standard Templated Library (STL). Higher
91-
//! dimension filters require Eigen 3 support.
92-
//!
93-
//! Standard formatter specialization provided for representation of the filter
94-
//! states.
78+
//! This library supports simple and extended filters. The implementation is
79+
//! independent from linear algebra backends. Arbitrary parameters can be added
80+
//! to the prediction and update stages to participate in gain-scheduling or
81+
//! linear parameter varying (LPV) systems. The default filter type is a
82+
//! generalized, customizable, and extended filter. The default type parameters
83+
//! represent a one-state, one-output double-precision floating-point type. The
84+
//! default update equation uses the Joseph form. Examples illustrate various
85+
//! usages and implementation tradeoffs. Standard formatter specialization
86+
//! provided for representation of the filter states. Filters with `state x
87+
//! output x input` dimensions as 1x1x1 and 1x1x0 (no input) are supported
88+
//! through vanilla C++. Higher dimension filters require a linear algebra
89+
//! backend. Customization points and type injections allow for implementation
90+
//! tradeoffs.
9591
//!
9692
//! @tparam State The type template parameter of the state column vector x.
9793
//! State variables can be observed (measured), or hidden variables (inferred).

0 commit comments

Comments
 (0)