I'm are going to create a LQR to control a system. The problem is to choose the Q and R weighting matrices for the cost function. The Q and R matrices are going to minimize the cost function so the system are going to be optimal.
I'm using Scilab and Scilab have a good library for optimal control. Scilab have a built function named
lqr() to compute the gain matrix K, which is the LQ regulator.
But the problem is still to choose those weighting matrices. I don't know here to start. I just might start with the identity matrix as Q and just a constant as R. But the gain matrix K does not make my model go smooth. No one can say that this is the real Q and R weighting matrices for the system. As a developer, I choose the weighting matrices. But why should I do that when I can choose the K gain matrix directly?
So I just made up my own numbers for the gain matrix K and now my model is very smooth. All I did just do was to guess some numbers for the gain matrix K and simulate and look at the result. Was it still bad, I might change the first element for the gain matrix to increase the position, or change the second element in the gain matrix K, to speed up the velocity for the position.
This works great for me! Guessing and simulate and look at the results. I choosing the LQ-technique for two main reasons: It gives multivariable action and can reduce noise by using a kalman filter. A PID cannot do that.
But here is my question:
Will this method give me an optimal control just by guessing the gain matrix K and changing the values depending how the simulation results looks like?
I'm I happy with the results, I might quit there and accept the gain matrix K as the optimal LQR for the system.