kf

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 20, 2023 License: Apache-2.0 Imports: 5 Imported by: 3

README

[Linear] Kalman Filter

This package implements Kalman Filter.

Example output

Kalman Filter in action

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KF

type KF struct {
	// contains filtered or unexported fields
}

KF is Kalman Filter

func New

func New(m filter.DiscreteModel, init filter.InitCond, z, wn filter.Noise) (*KF, error)

New creates new KF and returns it. It accepts the following parameters:

  • m: dynamical system model
  • init: initial condition of the filter
  • z: disturbance input a.k.a. process noise corresponding to E disturbance matrix
  • wn: output noise a.k.a. measurement noise
  • c: KF configuration (contains propagation and observation matrices)

It returns error if either of the following conditions is met:

  • invalid model is given: model dimensions must be positive integers
  • invalid state or output noise is given: noise covariance must either be nil or match the model dimensions

func (*KF) Cov

func (k *KF) Cov() mat.Symmetric

Cov returns KF covariance

func (*KF) Gain

func (k *KF) Gain() mat.Matrix

Gain returns Kalman gain

func (*KF) Model

func (k *KF) Model() filter.Model

Model returns KF models

func (*KF) OutputNoise

func (k *KF) OutputNoise() filter.Noise

OutputNoise retruns output noise

func (*KF) Predict

func (k *KF) Predict(x, u mat.Vector) (filter.Estimate, error)

Predict calculates the next system state given the state x and input u and returns its estimate. It first generates new sigma points around x and then attempts to propagate them to the next step. It returns error if it either fails to generate or propagate the sigma points (and x) to the next step.

func (*KF) Run

func (k *KF) Run(x, u, z mat.Vector) (filter.Estimate, error)

Run runs one step of KF for given state x, input u and measurement z. It corrects system state x using measurement z and returns new system estimate. It returns error if it either fails to propagate or correct state x.

func (*KF) SetCov

func (k *KF) SetCov(cov mat.Symmetric) error

SetCov sets KF covariance matrix to cov. It returns error if either cov is nil or its dimensions are not the same as KF covariance dimensions.

func (*KF) StateNoise

func (k *KF) StateNoise() filter.Noise

StateNoise retruns state noise

func (*KF) Update

func (k *KF) Update(x, u, ym mat.Vector) (filter.Estimate, error)

Update corrects state x using the measurement z, given control intput u and returns corrected estimate. It returns error if either invalid state was supplied or if it fails to calculate system output estimate.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL