[Linear] Kalman Filter

This package implements Kalman Filter.

Example output

Kalman Filter in action
Expand ▾ Collapse ▴




This section is empty.


This section is empty.


This section is empty.


type KF

type KF struct {
	// contains filtered or unexported fields

    KF is Kalman Filter

    func New

    func New(m filter.DiscreteModel, init filter.InitCond, q, r 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 - q: state a.k.a. process noise - r: output 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 model

            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, z 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.

                        Source Files