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

Online Help

ControlDesign

  

LQR

  

design linear quadratic state feedback regulator (LQR) for a given state-space system

 

Calling Sequence

Parameters

Options

Solvability Conditions

Description

Examples

Calling Sequence

LQR(sys, Q, R, opts)

Parameters

sys

-

System; system object

Q

-

Matrix; state weighting matrix

R

-

Matrix; input weighting matrix

opts

-

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

Options

• 

N = Matrix or Vector

  

Weighting on the state-input multiplication term in the cost function. If omitted, a zero matrix with appropriate dimensions will be considered.

• 

poles = true or false

  

True means the eigenvalues of A-BK are returned. The default value is false.    

• 

riccati = true or false

  

True means the solution of the associated Riccati equation is returned.

For a continuous system, the infinite horizon solution of the following continuous-time Riccati equation (CARE) is returned.

ATX+XAXB+NR1XB+NT+Q=0

The LQR feedback gain is calculated as

K=R1XB+NT

For a discrete system, the infinite horizon solution of the following discrete-time Riccati equation (DARE) is returned

ATXAXATXB+NBTXB+R1BTXA+NT+Q=0

The LQR feedback gain is calculated as

K=BTXB+R1BTXA+NT

The default value is false.

• 

return_Kr = true or false

  

True means the direct gain Kr is returned. The default value is false.

• 

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,B must be stabilizable.

• 

The pair QNR1NT,ABR1NT must have no unobservable modes on the imaginary axis in continuous-time domain or on the unit circle in discrete-time domain.

• 

R>0 (positive definite) and QNR1NT0 (positive semidefinite).

Description

• 

The LQR command calculates the LQR state feedback gain for a system.

• 

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. The state-space system can be either single-input/single-output (SISO) or multiple-input/multiple-output (MIMO).

• 

In continuous time, the optimal state feedback gain, K, is calculated such that the quadratic cost function

Ju=0xTQx+uTRu+2xTΝuⅆt

is minimized by the feedback law u = -Kx subject to the system dynamics

x·=Ax+Bu

• 

In discrete time, the optimal state feedback gain, K, is calculated such that the quadratic cost function

Ju=n=0xTQx+uTRu+2xTΝu

is minimized by the feedback law u[n] = -Kx[n] subject to the system dynamics

xn+1=Axn+Bun

• 

Q and R are expected to be symmetric. If the input Q and/or R are not symmetric, their symmetric part will be considered since their antisymmetric (skew-symmetric) part has no role in the quadratic cost function.

• 

In addition to the state feedback gain, depending on the corresponding option values, the command also returns the closed-loop eigenvalues and the solution of the associated Riccati equation.

• 

The direct gain Kr is computed as follows:

CD·K·1A+B·K·B+D (continuous time)

CD·K·1A+I+B·K·B+D (discrete time)

• 

If sys contains structured uncontrollable states, they are removed before computing the LQR state feedback. The resulting gain K is then filled with zeros at positions corresponding to the removed states; however, the other outputs are not filled and, consequently, they may have lower dimensions as expected.

Examples

withControlDesign:

withDynamicSystems:

csysNewSystemMatrix2s2+3s+1,1s+2,s1s2+5,7s+1s+4:

csys:-tf

2s2+3s+11s+2s1s2+57s2+5s+4

(1)

sysStateSpacecsys:

sys:-a;sys:-b;sys:-c;sys:-d

010000000100000001000−5−15−6−3000000001000000010000−8−14−7

00000010000001

10020451−1−2211470

0000

(2)

Q13LinearAlgebra:-IdentityMatrix7;R2LinearAlgebra:-IdentityMatrix2

Q13000000013000000013000000013000000013000000013000000013

R2002

(3)

KLQRsys,Q,R

K0.01663898109747050.2994436759550440.8677764521914780.3018509310763290.0.0.0.0.0.0.0.01040989379861050.01954395072894290.0146813589873455

(4)

KprLQRsys,Q,R,poles=true,riccati=true,return_Kr=true:Kpr1;Kpr2;Kpr3;Kpr4

0.01663898109747050.2994436759550440.8677764521914780.3018509310763290.0.0.0.0.0.0.0.01040989379861050.01954395072894290.0146813589873455

−2.62756665299744+0.I−0.145624709217511+2.22784297750641I−0.1456247092175112.22784297750641I−0.383034859643869+0.I−1.00185981437603+0.I−1.98515367555330+0.I−4.02766786905801+0.I

3.50357106780249636427356983347380869701730928710788.90631012705411115311675810756718031049477924614583.12838818122098082686058820294514592760627824361050.0332779621949409374206603236526689213529915396260090.0.0.8.906310127054111153116758107567180310494779246145827.01792983748675985061180093742507824269810008618110.9996867306090944849060693759024372654302363650350.598887351910087243343592782953780547783773573792700.0.0.3.128388181220980826860588202945145927606278243610510.9996867306090944849060693759024372654302363650358.75386079427495244526889789195148694929582021351381.73555290438295551200857175359974385723535498487790.0.0.0.0332779621949409374206603236526689213529915396260090.598887351910087243343592782953780547783773573792701.73555290438295551200857175359974385723535498487790.603701862152658441644654693320879940510941682759390.0.0.0.0.0.0.0.604587138927168509676898420793792313225217218130870.380945919753830599663964618798960532181765706634190.0208197875972210396136451371378709701895903592627870.0.0.0.0.380945919753830599663964618798960532181765706634190.664447437767019541498152361507087810149285907951570.0390879014578858512583266659427122986389872752131640.0.0.0.0.0208197875972210396136451371378709701895903592627870.0390879014578858512583266659427122986389872752131640.029362717974691029572229097828269653238134822396934

0.487728789828921−0.1393510828082630.05562784648471260.556278464847126

(5)

We can also use LQR with discrete models:

dsysToDiscretecsys,1,method=bilinear

dsysTransfer Functiondiscrete; sampletime = 12 output(s); 2 input(s)inputvariable=u1z,u2zoutputvariable=y1z,y2z

(6)

sysStateSpacedsys

sysState Spacediscrete; sampletime = 12 output(s); 2 input(s); 7 state(s)inputvariable=u1q,u2qoutputvariable=y1q,y2qstatevariable=x1q,x2q,x3q,x4q,x5q,x6q,x7q

(7)

KLQRsys,Q,R

K0.04812023135991430.301603484287272−0.4208348953450350.05115143016560900.0.0.0.0.0.0.0.0.0372408140701274−9.76066563662570×10−51

(8)

KprLQRsys,Q,R,poles=true,riccati=true,return_Kr=true:Kpr1;Kpr2;Kpr3;Kpr4

0.04812023135991430.301603484287272−0.4208348953450350.05115143016560900.0.0.0.0.0.0.0.0.0372408140701274−9.76066563662570×10−51

−0.0959924471365448+0.725780367567049I−0.09599244713654480.725780367567049I0.597646681582207+0.I−0.133580894274726+0.I0.+0.I−0.271790906819696+0.I0.271790906819696+0.I

0.342082466307950697771416932718558156273138383885160.054836997143688792408247958303061879045638516173491−0.0765154355180443195172182993354600571032994387984010.00930026003020372286930278584139618378658879868347600.0.0.0.0548369971436887924082479583030618790456385161734911.0190795442103837012531041373825245474117656429532−0.42467264975475382590709073532181913929136909457623−0.0161167278273309432267789914450936841209498377188470.0.0.−0.076515435518044319517218299335460057103299438798401−0.424672649754753825907090735321819139291369094576232.0214621985616492009289490977082087182086468171616−0.509659957051269219426006118369376537440933325477320.0.0.0.0093002600302037228693027858413961837865887986834760−0.016116727827330943226778991445093684120949837718847−0.509659957051269219426006118369376537440933325477322.24919438685146851376566202589753941507655526953060.0.0.0.0.0.0.0.33333333333333333333333333333333333333333333333333−3.8496822040751973138321389112729645857823238931349×10−50−6.1340857535650804575141297226367399037182210044452×10−510.0.0.0.−3.8496822040751973138321389112729645857823238931349×10−500.67494240312586739704767351946529754472265510527072−2.9362773606352192932407413788839969812745930630482×10−500.0.0.0.−6.1340857535650804575141297226367399037182210044452×10−51−2.9362773606352192932407413788839969812745930630482×10−501.0082757364592007303810068527986308780559884386041

0.474104074310421−0.1354583069456280.05788310645187300.578831064350061

(9)

See Also

ControlDesign

ControlDesign[LQRContinuous]

ControlDesign[LQRDiscrete]

ControlDesign[LQROutput]

ControlDesign[StateFeedback][Ackermann]

ControlDesign[StateFeedback][PolePlacement]

 


Download Help Document