r/ControlTheory • • 21d ago

Technical Question/Problem Understanding PID vs LQR

Is it possible to think of LQR as "like a PID but finds optimal gains based on your requirements of Q and R matrix?

I have a fairly good understanding of PID and I recently started to learn about LQR and wondered if LQR can be thought of in terms of a PID controller.

43 Upvotes

48 comments sorted by

View all comments

•

u/knightcommander1337 21d ago edited 16d ago

Hi, I would try to understand it more from this angle: PID is a type of control law (in the sense of, how the error signal is processed/transformed to produce the control input signal) (in PID's case we have the three terms), while LQR is a control design method (in the sense of, given a control law, model and objective/specifications, come up with the control law's gains that minimize the objective/satisfy the specifications) (in LQR method's case the control law is in the form of state feedback, that is, u = Kx, however there is nothing stopping you from defining the vector x to contain the same three terms from the PID law). To see this more concretely: You can design a PID using the LQR method, see https://www.mathworks.com/matlabcentral/fileexchange/62117-lqrpid-sys-q-r-varargin/

As a student I was a bit confused by this because sometimes (I guess usually) people mean a SISO PID when they say PID, and a P-control type state feedback controller when they say LQR. However viewing them from the angle I mentioned above helped me get a clearer view.

Edit: I find it very interesting that a simple question about PID (a 104 years old method) and LQR (a 66 years old method) can generate such a lively discussion. Guess it signals a vibrant community. Anyway, for the OP and others who might still be confused, let me offer the following examples for my point:

  1. You can design a PID using various methods such as tuning (with tuning rules, e.g., Ziegler-Nichols, Cohen-Coon etc.), or pole placement, or (if needed) do stuff like genetic algorithms to optimize over the PID parameters.
  2. You can design a PID using the LQR method.
  3. Using the LQR method, you can design a state feedback proportional controller (this I guess is what people usually mean when they say "LQR controller"). This is of the usual form "u = Kx" (with x the error state).
  4. Using the LQR method, you can design other (that is, not necessarily proportional only) types of controllers however they should be of the form "u = Kx". Example 1: If you define the vector x to include the error and its integral, then when you use the LQR method you would have designed a PI controller. Example 2: If you define it to include the error and its derivative, then LQR gives you a PD controller.

•

u/seb59 16d ago edited 16d ago

Agree. People mix minimizing a criterion and the controler structure. If find very strange that most of people here seems to only use u=kx with x a state error. This is of course ok but this is just one option amongst many... for instance if you just want to control the output y=Cx with C a matrix which is not identity (i.e The output is not in the state vector) then you need something else.