Kalman - MapleSim Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


ControlDesign

  

Kalman

  

design Kalman estimator for a given state-space system

 

Calling Sequence

Parameters

Options

Solvability Conditions

Description

Examples

References

Calling Sequence

Kalman(sys, G, H, Q, R, opts)

Parameters

sys

-

System; system object

G

-

Matrix; process noise matrix in the state equations

H

-

Matrix: process noise matrix in the output equations

Q

-

Matrix; process noise covariance matrix

R

-

Matrix; measurement noise covariance matrix

opts

-

(optional) equation(s) of the form option = value; specify options for the Kalman command

Options

• 

N = Matrix or Vector

  

The cross-correlation matrix between process and measurement noises. If omitted, a zero matrix with appropriate dimensions will be considered.

• 

output = gain or filter

  

Specifies whether the Kalman gains or the Kalman filter object must be returned. The default value is gain.

  

If gain, the Kalman gains and steady state estimation error covariance matrices are returned as follows:

– 

In the continuous-time domain, the gain matrix and steady state error covariance are returned as a sequence of L,P where L and P are as defined before.

– 

In the discrete-time domain, the gain matrix, the innovation gain, and the steady state error covariance matrices are returned as a sequence of L,M,P,Z where L, P, and M are as defined before and

  

Z=limnEen|nen|nT=IMCP,en|n=xnxˆn|n.

  

If filter, the Kalman filter is returned as a state-space DynamicSystems object. The structure of the filter depends on the time-domain and the value of option filtertype (for the discrete Kalman filter).

• 

filtertype =  current or delayed

  

Specifies the type of the discrete Kalman filter. The default value is current.

• 

parameters = {list, set}(name = complexcons)

  

Specifies numeric values for the parameters of sys. These values override any parameters previously specified for sys. The numeric value on the right-hand side of each equation is substituted for the name on the left-hand side in the sys equations. The default is the value of sys given by DynamicSystems:-SystemOptions(parameters).

Solvability Conditions

• 

The pair A,C must be detectable.

• 

The pair AN_R_1C,Q_N_R_1N_T must have no uncontrollable modes on the imaginary axis in continuous-time domain or on the unit circle in discrete-time domain

where Q_=GQGT, R_, and N_ are as defined before.

• 

R_>0 (positive definite) and Q_N_R_1N_T0 (positive semidefinite)

where Q_, R_, and N_ are as defined before.

Description

• 

The Kalman command designs the Kalman estimator for a given system and process and measurement noise covariance matrices.

• 

The system sys is a continuous or discrete-time linear system object created using the DynamicSystems package. The system object must be in state-space (SS) form.

• 

If sys contains structural uncontrollable or unobservable states, they are removed using ReduceSystem before computing the Kalman gains.  The resulting Kalman gains are then filled with zeros at positions corresponding to the removed states.

 

• 

Continuous-Time Kalman Estimator (Filter)

Given the continuous-time system

 

x=Ax+Bu+Gw

y=Cx+Du+Hw+v

 

with known (deterministic) inputs u, white process noise w, and white measurement noise v, satisfying

 

Ew=0    (process noise has zero mean value)

Ev=0    (measurement noise has zero mean value)

EwwT=Q

EvvT=R

EwvT=N

 

where Ea is the mathematical expectation of a, the Kalman filter provides an optimal state estimation that minimizes the steady state error covariance

 

P=limtExxˆxxˆT.

 

The Kalman filter equations are given as

 

xˆ=Axˆ+Bu+LyCxˆDu

x^y^=ICx^+00D0uy.

 

The gain matrix L is calculated as

 

L=PCT+N_R_1

 

where P is the solution of the corresponding algebraic Riccati equation and

 

R_=R+HN+HNT+HQHT

N_=GQHT+N.

 

• 

Discrete-Time Kalman Estimator (Filter)

Given the discrete-time system

 

xn+1=Axn+Bun+Gwn

yn=Cxn+Dun+Hwn+vn

 

and the noise covariance data

 

Ewn=0

Evn=0

EwnwnT=Q

EvnvnT=R

EwnvnT=N

 

the Kalman filter provides an optimal state estimation that minimizes the steady state error covariance

 

P=limnEen|n1en|n1T,en|n1=xnxˆn|n1.

 

The discrete Kalman filter state equation is given as

 

xˆn+1|n=Axˆn|n1+Bun+LynCxˆn|n1Dun

 

The gain matrix L is calculated as

 

L=APCT+N_CPCT+R_1

 

where  P is the solution of the corresponding algebraic Riccati equation and R_ and N_ are as defined before.

 

– 

The output equation structure depends on the type of the filter specified in the option filtertype:

 

– 

The current estimator uses all available measurements up to yn and generates state estimates xˆn|n and output estimates yˆn|n. The updated estimates are obtained from the prediction xˆn|n1 using the latest measurement yn as

 

xˆn|n=xˆn|n1+MynCxˆn|n1Dun.

 

ynCxˆn|n1Dun is called the innovation signal which (under Kalman optimality conditions) is white.

 

The innovation gain, M, is given as

 

M=PCTCPCT+R_1.

 

The output equation is given as

 

x^n|ny^n|n=IMCICMCx^n|n1+MDMICMDCMunyn.

 

– 

The delayed estimator uses measurements up to yn-1 and generates state estimates xˆn|n-1 and output estimates yˆn|n-1.

The output equation is given as

 

x^n|n1y^n|n1=ICx^n|n1+00D0unyn.

Examples

withControlDesign:

withDynamicSystems:

Design a Kalman filter for a continuous system

csysNewSystemMatrix1s+1,ss2+3s+2,3s+1s+4,ss2+1:

sysStateSpacecsys:

PrintSystemsys

State Spacecontinuous2 output(s); 2 input(s); 6 state(s)inputvariable=u1t,u2toutputvariable=y1t,y2tstatevariable=x1t,x2t,x3t,x4t,x5t,x6ta=010000−4−5000000010000001000000100−2−3−3−3b=001000000001c=410101300231d=0000

(1)

GLinearAlgebra:-IdentityMatrix6:

Q23LinearAlgebra:-IdentityMatrix6:

HMatrix1,0,0,1,2,2,0,3,5,7,1,2:

R2LinearAlgebra:-IdentityMatrix2:

KgcKalmansys,G,H,Q,R:

KgainKgc1

Kgain0.1924334636345310.00614696476597994−0.06430370435773440.0264039604378602−0.0638163203438628−0.06551692814324320.009783679001496630.09634736592923150.1084847890162120.0909526847294459−0.02542235060980900.0116225919671224

(2)

KcovKgc2

Kcov0.28619026502462421249216422557974673288293232592618−0.17093249750486729793964027668869909748546520252115−0.023090085729227154363628640070442235954898979569838−0.19723589554649682144619488632748940798762022313999−0.0638298311281778159941460979160688762820641285952020.22859532762945828671415622539317735625002783932338−0.170932497504867297939640276688699097485465202521150.195825917421821659676124708193883159028608112557980.0577068815387494359655083787553019886927342486749660.12847648642595889565755005263308806727757128935525−0.0016386017918392762807724156621809230998288592598214−0.18026854463676903611658851547851644267659801796258−0.0230900857292271543636286400704422359548989795698380.0577068815387494359655083787553019886927342486749663.3056011882889604243245501383529761632162692350168−0.18269350977652883516212948916949839765570205397822−2.1788360511969896530095223458096966715302998562266−0.37940575725428501692384388757325100457563620518737−0.197235895546496821446194886327489407987620223139990.12847648642595889565755005263308806727757128935525−0.182693509776528835162129489169498397655702053978221.7859473284905272128326231780521898012234023009321−0.050711404623049480966638606781444388971726417683354−1.6431234374313737289058834295224106871103272678818−0.063829831128177815994146097916068876282064128595202−0.0016386017918392762807724156621809230998288592598214−2.1788360511969896530095223458096966715302998562266−0.0507114046230494809666386067814443889717264176833542.1915085811133627110745889007046547886549312829194−0.0248273744455952922909230340420171377409204652576070.22859532762945828671415622539317735625002783932338−0.18026854463676903611658851547851644267659801796258−0.37940575725428501692384388757325100457563620518737−1.6431234374313737289058834295224106871103272678818−0.0248273744455952922909230340420171377409204652576072.0297653609100465020733736810968951891825963803854

(3)

LinearAlgebra:-Eigenvaluessys:-aKgain·sys:-c

−3.93877830228837+0.I−2.47171603376280+0.I−0.229038486136632+0.832844151778282I−0.2290384861366320.832844151778282I−1.15841822127975+0.302560027651278I−1.158418221279750.302560027651278I

(4)

KfilterKalmansys,G,H,Q,R,output=filter:

PrintSystemKfilter

Design a Kalman filter for a discrete system:

dsysToDiscretecsys,1,method=bilinear:

sysStateSpacedsys:

KgcKalmansys,G,H,Q,R:

LKgc1

L0.102357348091063−0.000270311689505002−0.00002258727566445280.03163016967101120.0324778264960475−0.03040936849120180.0704309874351989−0.03205255326543810.129070756561783−0.0489238268444825−0.1755064755984780.0836901687155676

(5)

MKgc2

M0.02536859137783490.005807363508801060.02746972472866040.000676794860821479−0.02184462737542450.001782258655321430.0372133592476799−0.08205088025607220.00217310992508201−0.103403563185930−0.0216515967133475−0.0367013113908555

(6)

PKgc3

P1.1900369256390078377586184628370039668475331991448−0.00233200860903450492498599386981059277220386411805310.00619988274226182212944558278729207805258749728971370.014704192484813023622580936656881320686092202865071−0.26910475791320750804979073203338265728777922953550−0.17883726222393262145311402911160312135949479177824−0.00233200860903450492498599386981059277220386411805310.616706923971668092542179906886994108688428463131170.0629575750005459404632246547383052228031914171539720.0338084410601545143597413676619777791279345794979190.076819002446584818836921297831759174977385306740545−0.154624466180982615441681742775226727756383255029780.00619988274226182212944558278729207805258749728971370.06295757500054594046322465473830522280319141715397214.0258493338218098567909220214505625082836294568597.4346881925078578276089838791018867254508860879170−3.5696824762744547720904033319872007356676381302352−11.1131081577137651463161600355227588485285617257550.0147041924848130236225809366568813206860922028650710.0338084410601545143597413676619777791279345794979197.434688192507857827608983879101886725450886087917013.4267277192343655429414968630716207084601983311507.5154613955186568085059467231836511906099352421786−3.4406863305018803177987802662013206227436745305880−0.269104757913207508049790732033382657287779229535500.076819002446584818836921297831759174977385306740545−3.56968247627445477209040333198720073566763813023527.515461395518656808505946723183651190609935242178612.8669729877196992095723399102792834467189508494397.6916211935162691687987582863169769663886962498825−0.17883726222393262145311402911160312135949479177824−0.15462446618098261544168174277522672775638325502978−11.113108157713765146316160035522758848528561725755−3.44068633050188031779878026620132062274367453058807.691621193516269168798758286316976966388696249882512.493137943161183557844150615741546706412859530872

(7)

ZKgc4

Z1.18188087156736−0.008941293640510630.01053680607990540.0386074205259520−0.228656565276868−0.159304648350176−0.008941293640510630.6099216408521560.06819982175613770.03010774994236510.0831297099445528−0.1468824838076860.01053680607990540.068199821756137714.02145473592717.44986437129508−3.55919924152385−11.11372020487410.03860742052595200.03010774994236517.4498643712950812.98431517133096.96975114659318−3.62844349992178−0.2286565652768680.0831297099445528−3.559199241523856.9697511465931812.17633524070157.44503056330966−0.159304648350176−0.146882483807686−11.1137202048741−3.628443499921787.4450305633096612.4006152930078

(8)

LinearAlgebra:-Eigenvaluessys:-aL·sys:-c

0.557923700713317+0.764621079517396I0.5579237007133170.764621079517396I−0.329933413527070+0.I0.313799486006446+0.I0.178331258920456+0.146122594396005I0.1783312589204560.146122594396005I

(9)

KfilterKalmansys,G,H,Q,R,output=filter,filtertype=current:

PrintSystemKfilter

KfilterKalmansys,G,H,Q,R,output=filter,filtertype=delayed:

PrintSystemKfilter

References

  

[1] F. Lewis, Optimal Estimation, John Wiley & Sons, 1986.

  

[2] G. F. Franklin, J. D. Powell and M. L. Workman, Digital Control of Dynamic Systems, 2nd Ed., Addison-Wesley, 1990.

See Also

ControlDesign

ControlDesign[LQR]

ControlDesign[StateFeedback][Ackermann]

ControlDesign[StateFeedback][PolePlacement]

ControlDesign[StateObserver][Ackermann]

ControlDesign[StateObserver][Observer]

ControlDesign[StateObserver][PolePlacement]