Socket
Socket
Sign inDemoInstall

kalman-filter

Package Overview
Dependencies
49
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.12.0 to 1.13.0

20

lib/core-kalman-filter.js

@@ -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;

6

package.json
{
"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 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc