kalman-filter
Advanced tools
Comparing version 1.12.0 to 1.13.0
@@ -14,2 +14,3 @@ const matMul = require('../lib/linalgebra/mat-mul.js'); | ||
* @param {Number} opts.previousCorrected | ||
* @returns {Array.Array.<Number>>} | ||
*/ | ||
@@ -23,2 +24,3 @@ | ||
* @param {Observation} opts.observation | ||
* @returns {Array.Array.<Number>>} | ||
*/ | ||
@@ -37,2 +39,3 @@ | ||
* @property {Number} dimension dimension of the state vector | ||
* @property {PreviousCorrectedCallback} [constant=null] a function that returns the control parameter B_k*u_k of the kalman filter | ||
* @property {PreviousCorrectedCallback} [fn=null] for extended kalman filter only, the non-linear state-transition model | ||
@@ -111,3 +114,15 @@ * @property {Array.Array.<Number>> | PredictedCallback} transition the state-transition model (or for EKF the jacobian of the fn) | ||
predictMean({opts, transition}) { | ||
predictMean(o) { | ||
const mean = this.predictMeanWithoutControl(o); | ||
if (!this.dynamic.constant) { | ||
return mean; | ||
} | ||
const {opts} = o; | ||
const control = this.dynamic.constant(opts); | ||
checkMatrix(control, [this.dynamic.dimension, 1], 'dynamic.constant'); | ||
return add(mean, control); | ||
} | ||
predictMeanWithoutControl({opts, transition}) { | ||
if (this.dynamic.fn) { | ||
@@ -148,2 +163,5 @@ return this.dynamic.fn(opts); | ||
this.logger.debug('Prediction done', predicted); | ||
if (Number.isNaN(predicted.mean[0][0])) { | ||
throw (new TypeError('nan')); | ||
} | ||
@@ -150,0 +168,0 @@ return predicted; |
{ | ||
"name": "kalman-filter", | ||
"version": "1.12.0", | ||
"version": "1.13.0", | ||
"description": "Kalman filter (and Extended Kalman Filter) Multi-dimensional implementation in Javascript", | ||
@@ -9,3 +9,3 @@ "main": "index.js", | ||
"semantic-release": "semantic-release", | ||
"build-demo": "build && browserify -d -r ./demo/src/main.js:main > docs/demo.js && cp dist/kalman-filter.js docs/dist/kalman-filter.js", | ||
"build-demo": "npm run build && browserify -d -r ./demo/bike/main.js:bike > docs/dist/bike.js && browserify -d -r ./demo/bouncing-ball/main.js:bouncing-ball > docs/dist/bouncing-ball.js && cp dist/kalman-filter.js docs/dist/kalman-filter.js", | ||
"serve-demo": "http-server docs/", | ||
@@ -87,3 +87,2 @@ "build": "NODE_OPTIONS=--openssl-legacy-provider webpack" | ||
"devDependencies": { | ||
"@semantic-release/git": "^9.0.0", | ||
"ava": "^3.8.2", | ||
@@ -100,2 +99,3 @@ "browserify": "^16.5.2", | ||
"@rayyamhk/matrix": "^1.0.5", | ||
"http-server": "^14.1.1", | ||
"matrix-inverse": "^2.0.0" | ||
@@ -102,0 +102,0 @@ }, |
@@ -15,5 +15,6 @@ ![Kalman Filter Gif](./demo/demo.gif) | ||
## 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) | ||
@@ -140,2 +141,3 @@ * [Partial Observation](https://github.com/piercus/kalman-filter/issues/34) | ||
| $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` | | ||
@@ -155,2 +157,3 @@ |$\mathbf{x}_{0\mid 0}$| `dynamic.init.mean` | | ||
This will automatically configure the `dynamic.transition` matrix. | ||
##### constant-position | ||
@@ -376,2 +379,3 @@ | ||
* `dynamic.covariance` | ||
* `dynamic.constant` | ||
@@ -461,4 +465,11 @@ In this situation this `function` will return the value of the matrix at each step of the kalman-filter. | ||
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 | ||
@@ -465,0 +476,0 @@ |
71350
8
1338
692
3
+ Addedhttp-server@^14.1.1
+ Addedansi-styles@4.3.0(transitive)
+ Addedasync@2.6.4(transitive)
+ Addedbasic-auth@2.0.1(transitive)
+ Addedcall-bind@1.0.7(transitive)
+ Addedchalk@4.1.2(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedcorser@2.0.1(transitive)
+ Addeddebug@3.2.7(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addedes-define-property@1.0.0(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedeventemitter3@4.0.7(transitive)
+ Addedfollow-redirects@1.15.6(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-intrinsic@1.2.4(transitive)
+ Addedgopd@1.0.1(transitive)
+ Addedhas-flag@4.0.0(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-proto@1.0.3(transitive)
+ Addedhas-symbols@1.0.3(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedhe@1.2.0(transitive)
+ Addedhtml-encoding-sniffer@3.0.0(transitive)
+ Addedhttp-proxy@1.18.1(transitive)
+ Addedhttp-server@14.1.1(transitive)
+ Addediconv-lite@0.6.3(transitive)
+ Addedlodash@4.17.21(transitive)
+ Addedmime@1.6.0(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedmkdirp@0.5.6(transitive)
+ Addedms@2.1.3(transitive)
+ Addedobject-inspect@1.13.1(transitive)
+ Addedopener@1.5.2(transitive)
+ Addedportfinder@1.0.32(transitive)
+ Addedqs@6.12.1(transitive)
+ Addedrequires-port@1.0.0(transitive)
+ Addedsafe-buffer@5.1.2(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsecure-compare@3.0.1(transitive)
+ Addedset-function-length@1.2.2(transitive)
+ Addedside-channel@1.0.6(transitive)
+ Addedsupports-color@7.2.0(transitive)
+ Addedunion@0.5.0(transitive)
+ Addedurl-join@4.0.1(transitive)
+ Addedwhatwg-encoding@2.0.0(transitive)