�
�g�Uc @` s� d Z d d l m Z m Z m Z m Z d d l Z d d l j Z d d l m
Z
m Z m Z m
Z
d d l m Z m Z m Z d e f d � � YZ d S( u4 Copyright 2015 Roger R Labbe Jr.
FilterPy library.
http://github.com/rlabbe/filterpy
Documentation at:
https://filterpy.readthedocs.org
Supporting book at:
https://github.com/rlabbe/Kalman-and-Bayesian-Filters-in-Python
This is licensed under an MIT license. See the readme.MD file
for more information.
i ( t absolute_importt divisiont print_functiont unicode_literalsN( t dott zerost eyet asarray( t settert
setter_scalart dot3t FadingKalmanFilterc B` s� e Z d d � Z d d � Z d d � Z d e d � Z d d � Z d � Z d � Z
e d � � Z e j
d � � Z e d
� � Z e j
d � � Z e d � � Z e j
d
� � Z e d � � Z e j
d � � Z e d � � Z e j
d � � Z e d � � Z e j
d � � Z e d � � Z e j
d � � Z e d � � Z e j
d � � Z e d � � Z e d � � Z e d � � Z RS( i c C` s
| d k s t � | d k s$ t � | d k s6 t � | d k sH t � | d | _ | | _ | | _ | | _ t | d f � | _ t | � | _ t | � | _ d | _
d | _ d | _ t | � | _
d | _ t | d f � | _ d | _ t j | � | _ d S( u Create a Kalman filter. You are responsible for setting the
various state variables to reasonable values; the defaults below will
not give you a functional filter.
**Parameters**
alpha : float, >= 1
alpha controls how much you want the filter to forget past
measurements. alpha==1 yields identical performance to the
Kalman filter. A typical application might use 1.01
dim_x : int
Number of state variables for the Kalman filter. For example, if
you are tracking the position and velocity of an object in two
dimensions, dim_x would be 4.
This is used to set the default size of P, Q, and u
dim_z : int
Number of of measurement inputs. For example, if the sensor
provides you with position in (x,y), dim_z would be 2.
dim_u : int (optional)
size of the control input, if it is being used.
Default value of 0 indicates it is not used.
**Instance Variables**
You will have to assign reasonable values to all of these before
running the filter. All must have dtype of float
X : ndarray (dim_x, 1), default = [0,0,0...0]
state of the filter
P : ndarray (dim_x, dim_x), default identity matrix
covariance matrix
Q : ndarray (dim_x, dim_x), default identity matrix
Process uncertainty matrix
R : ndarray (dim_z, dim_z), default identity matrix
measurement uncertainty
H : ndarray (dim_z, dim_x)
measurement function
F : ndarray (dim_x, dim_x)
state transistion matrix
B : ndarray (dim_x, dim_u), default 0
control transition matrix
i i i N( t AssertionErrort alpha_sqt dim_xt dim_zt dim_uR t _XR t _Pt _Qt _Bt _Ft _Ht _Rt _Kt _yt _St npt _I( t selft alphaR R R ( ( s"