Clear Filters
Clear Filters

LQR issues and converting minreal gains to full-state feedback

7 views (last 30 days)
I have a 7th order system that I am trying to obtain full-state feedback gains for using LQR.
When I use LQR on the system, I get the following error:
------------------------------------begin error-------------------------------------------------------
The "lqr" command failed to stabilize the plant or find an optimal feedback gain. To remedy this problem:
1. Make sure that all unstable poles of A are controllable through B (use MINREAL to check)
2. Modify the weights Q and R to make [Q N;N' R] positive definite (use EIG to check positivity).
------------------------------------end error-------------------------------------------------------
The unstable poles of the system are controllable and condition 2 is met because I am using Q = I and R = I (of correct size).
If I use minreal on my system with C = I, I am able to use LQR to get a set of gains for the reduced system.
Two questions
  1. Why isn't the LQR command working with the full system?
  2. Is there a way to convert the set of gains from the reduced system into full state feedback gains?
I have attached a file containing the full system and reduced system.

Answers (2)

Sebastian Castro
Sebastian Castro on 20 Aug 2015
Edited: Sebastian Castro on 20 Aug 2015
For your first question, the full system is not controllable so LQR isn't expected to work. For the system to be controllable, the rank must be 7 (the total number of states), and it isn't.
>> rank(ctrb(sys))
ans = 4
For your second question, it's a little involved. You can look at the controllability staircase form using
[Abar,Bbar,Cbar,T,k] = ctrbf(sys.A,sys.B,sys.C);
Then, you can find an LQR controller on the controllable portion (in this case, states 4:7).
K = lqr(Abar(4:7,4:7),Bbar(4:7,:),eye(4),eye(3))
You can pad the resulting K matrix with a bunch of zeros and then use the transformation matrix to get something that will work on the full system.
Kaug = [zeros(3,3) K];
Ktrans = Kaug*T;
Then, you can string this together as follows:
X = ss((Ap-Bp*Ktrans),zeros(7,3),eye(7),Dp);
(If you want this to be a LQR servo, the B matrix could instead be Bp*Ktrans)
Two of the poles of this system above were basically zero, but slightly positive. I was hoping this was a numerical issue, so I tried to simulate this with an initial condition of 1 for the first state and was happy to see a stable response.
t = (0:0.01:100)';
lsim(X,zeros(3,length(t)),t,[1 0 0 0 0 0 0])
- Sebastian
  1 Comment
caidan007
caidan007 on 13 Mar 2019
I used this method for a higher order(n=64) MIMO system dx=Ax+Bu,y=Cx. I have attached a file with matrix A,B,C,D data.
sys=ss(A,B,C,D);
>> rank(ctrb(sys))
ans =
8
so,there are 56 uncontrollable states and 8 controllable states. Then
[Abar,Bbar,Cbar,T,k] = ctrbf(sys.A,sys.B,sys.C);
K = lqr(Abar(57:64,57:64),Bbar(57:64,:),eye(8),eye(4));
Kaug = [zeros(4,56) K];
but I found (A-B*Ktrans) has many eigenvalues with positive real part, that means the full system with feedback gain Ktrans is unstable.
So,for a not fully controllable system,how can I get feedback gain Ktrans.
Thanks for your reply!

Sign in to comment.


Layne
Layne on 21 Aug 2015
Sebastian,
Thanks for the answer. I am confused about the first statement in the error from the LQR command. It reads
"Make sure that all unstable poles of A are controllable through B (use MINREAL to check)"
Not that A and B have to be controllable. This statement implies that as long as the system is stabilizable, which my system is, the LQR command will work. Could you expand on this please?

Community Treasure Hunt

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

Start Hunting!