# Designing LQR controller error

23 views (last 30 days)
Deepayan Bhadra on 15 Apr 2021
Commented: Deepayan Bhadra on 16 Apr 2021
I am trying to design LQR for a 7x7 system.
A = 0 -0.628971428568773 0 0 0 0 0.999999999999951
-0.0239070502560970 0 0 0 1.26736762437470 0.404734566388548 0
-9.73903523911518e-06 0 1.95035679041857 -0.951171532106457 0.000516288618732924 0.000164877061884321 0
0 0 1 0 0 0 0
0.383799830372633 0 0 0 0.854813237018843 -0.138991455550305 0
-0.00476707865861458 0 0 0 0.0327470424766583 0.967898772564207 0
0 -0.157242857142201 0 0 0 0 1
B = 0.628971428571398
0
0
0
0
0
0.157242857142857
C = 0 0 1.00834336091157 0.991656639088434 0 0 0
D = 0
The system has poles on right half plane but is controllable,
rank(ctrb(A,B))
= 7.
When I try
K = lqr(A,B,Q,R)
, I get below. I fail to see what's happening here in view of the information above. Could someone clarify?
Error using lqr (line 42)
Cannot compute a stabilizing LQR gain (the Riccati solution S and gain matrix K are infinite).
This could be because:
* A has unstable modes that are not controllable through B,
* Q,R,N values are too large,
* [Q N;N' R] is indefinite,
* The E matrix in the state equation is singular.

Paul on 16 Apr 2021
Edited: Paul on 16 Apr 2021
The system might be controllable in principle, but in reality seems to be problematic for using state feedback. I had trouble even getting pole placement to work numerically. But it can work symbolically. However, converting the symbolic solution to numerical shows great sensitivity for the selected set of closed loop poles:
K = sym('K',[1 7]);
syms s
[c,t]=(coeffs(det(s*eye(7)-(A-B*K)),s,'All')); % characteristic polynomial
[K1,K2,K3,K4,K5,K6,K7]=solve(c==sym(poly(diag(-7:-1))),K); % solve state feedback gains for closed loop poles at -7:-1
eig(A-B*subs(K)) % verify sympolic solution
eig(A-B*double(subs(K))) % compare to numeric solution
ans =
-7
-6
-5
-4
-3
-2
-1
ans =
-1.5887e+01 + 5.1114e+00i
-1.5887e+01 - 5.1114e+00i
-1.4663e+00 + 1.3262e+01i
-1.4663e+00 - 1.3262e+01i
5.6211e+00 + 0.0000e+00i
-1.6455e-02 + 0.0000e+00i
1.1026e+00 + 0.0000e+00i
So the symbolic solution is perfect, but converting to double precision yields a terrible result. The feedback gain matrix is
>> vpa(subs(K)).'
ans =
-52271855.708258191568879324847032
23249.37317998977835990526684776
-2733390131189.6388535741683213926
2711961625327.6659529554924801665
386661508.02580444722226705634626
44938181476.829118288777618682236
209087631.25628197842813619653929
which shows very high gains needed to move all those unstable poles into the LHP. I'm not sure what one could specifically conclude abuout this problem from these results, but it certainly suggests that any state feedback approach could be tricky.
Deepayan Bhadra on 16 Apr 2021
Thanks for the analysis, @Paul

R2020b

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!