Skip to content

Commit

Permalink
update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
piercus committed Mar 27, 2023
2 parents 90b3333 + 97980f6 commit a3c82a4
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 13 deletions.
64 changes: 54 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ This library implements following features:
* Extended Kalman Filter (when using functions for dynamics and observation matrixes)
* Correlation Matrix

## Demos
## Demos/Examples

* [Browser interactive constant acceleration on bikes](http://piercus.github.io/kalman-filter)
* [Sinusoidale Extended Kalman-Filter](https://observablehq.com/d/a033acc0859cc0de)
* [Code pen GPS Data smoothing with constant speed](https://codepen.io/piercus/pen/wvoqPww)
* [Partial Observation](https://github.com/piercus/kalman-filter/issues/34)
* [Smooth 3x3 rotation matrix](https://github.com/piercus/kalman-filter/issues/37)
Expand Down Expand Up @@ -136,6 +137,7 @@ For advanced usage, here is the correspondance table with the matrix name of the
| $H_k$, the observation model | `observation.stateProjection` |
| $Q_k$, the covariance of the process noise | `dynamic.covariance` |
| $R_k$, the covariance of the observation noise | `observation.covariance` |
| $B_k u_k$, the control-input model multiplied by the control vector | `dynamic.constant` |
|$\mathbf{P}_{0\mid 0}$| `dynamic.init.covariance` |
|$\mathbf{x}_{0\mid 0}$| `dynamic.init.mean` |

Expand All @@ -151,11 +153,45 @@ Available default models as :

This will automatically configure the `dynamic.transition` matrix.

| `dynamic.name` | State | Transition Equation | `dynamic.transition` |
|--|--|--|--|
| `constant-position` | $\begin{bmatrix} x_t \end{bmatrix}$ | $x_t \sim x_{t-1}$ | $\begin{bmatrix} 1 \end{bmatrix}$ |
| `constant-speed` | $\begin{bmatrix} x_t \\\\ speed_t \end{bmatrix}$ | $\begin{split}x_t \sim x_{t-1} + speed_{t-1},\\\\ speed_t \sim speed_{t-1}\end{split}$| $\begin{bmatrix} 1 & 1 \\\\ 0 & 1 \end{bmatrix}$ |
| `constant-acceleration` | $\begin{bmatrix} x \\\\ speed_t \\\\ acc_t \end{bmatrix}$ | $\begin{split}x_t \sim x_{t-1} + speed_{t-1} \\\\ speed_t \sim speed_{t-1} + acc_{t-1} \\\\ acc_t \sim acc_{t-1}\end{split}$ | $\begin{bmatrix} 1 & 1 & 0 \\\\ 0 & 1 & 1 \\\\ 0 & 0 & 1\end{bmatrix}$ |
##### constant-position

```math
\begin{align}
State :& \begin{bmatrix} x_t \end{bmatrix}\\
Transition Equation :& x_t \sim x_{t-1} \\
dynamic.transition :& \begin{bmatrix} 1 \end{bmatrix}
\end{align}
```

##### constant-speed

```math
\begin{align}
State :& \begin{bmatrix} x_t \\ speed_t \end{bmatrix} \\
Transition Equation :&
\begin{split}
x_t &\sim x_{t-1} + speed_{t-1},\\
speed_t &\sim speed_{t-1}
\end{split} \\
dynamic.transition :& \begin{bmatrix} 1 & 1 \\ 0 & 1 \end{bmatrix}
\end{align}
```

##### constant-acceleration

```math
\begin{align}
State :& \begin{bmatrix} x_t \\ speed_t \\ acc_t \end{bmatrix} \\
Transition Equation :&
\begin{split}
x_t &\sim x_{t-1} + speed_{t-1} \\
speed_t &\sim speed_{t-1} + acc_{t-1} \\
acc_t &\sim acc_{t-1}
\end{split} \\
dynamic.transition :& \begin{bmatrix} 1 & 1 & 0 \\ 0 & 1 & 1 \\ 0 & 0 & 1\end{bmatrix}
\end{align}
```

#### 'constant-position' on 2D data

Expand Down Expand Up @@ -337,6 +373,7 @@ In order to use the Kalman-Filter with a dynamic or observation model which is n
* `observation.covariance`
* `dynamic.transition`
* `dynamic.covariance`
* `dynamic.constant`

In this situation this `function` will return the value of the matrix at each step of the kalman-filter.

Expand Down Expand Up @@ -421,7 +458,14 @@ You will need to put your non-linear functions in the following parameters
* `observation.fn`
* `dynamic.fn`

See an example in `test/issues/56.js`
See an example in [Sinusoidale Extended Kalman-Filter](https://observablehq.com/d/a033acc0859cc0de)

### Using Control model

If you want to add a constant parameter in the dynamic model (also called `control input`), you can use `dynamic.constant` function

See an example code in `demo/bouncing-ball` or the result in [Bouncing Ball example](https://observablehq.com/d/a033acc0859cc0de)


## Use your kalman filter

Expand Down Expand Up @@ -456,7 +500,7 @@ If you want to use KalmanFilter in more advanced usage, you might want to dissoc
let previousCorrected = null;
const results = [];
observations.forEach(observation => {
const predictedState = kFilter.predict({
const predicted = kFilter.predict({
previousCorrected
});

Expand Down Expand Up @@ -589,7 +633,7 @@ let previousCorrected = null;
const results = [];

observations.forEach(observation => {
const predictedState = kFilter.predict({
const predicted = kFilter.predict({
previousCorrected
});

Expand Down Expand Up @@ -620,7 +664,7 @@ let previousCorrected = null;
const results = [];

observations.forEach(observation => {
const predictedState = kFilter.predict({
const predicted = kFilter.predict({
previousCorrected
});

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kalman-filter",
"version": "1.10.1",
"version": "1.12.0",
"description": "Kalman filter (and Extended Kalman Filter) Multi-dimensional implementation in Javascript",
"main": "index.js",
"scripts": {
Expand All @@ -14,6 +14,10 @@
"type": "git",
"url": "git+https://github.com/piercus/kalman-filter.git"
},
"files": [
"index.js",
"lib"
],
"release": {
"branches": [
"master"
Expand Down

0 comments on commit a3c82a4

Please sign in to comment.