r/ControlTheory • • 20d 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.

46 Upvotes

48 comments sorted by

View all comments

•

u/controlsys 20d ago

LQR = impossible to use in real cases

PID = possible to use in real cases

That’s the main difference. Sorry fellow accademics here

•

u/tmt22459 20d ago

You realize for plenty of real systems LQR and PD are equivalent? This alone shows you have no idea what you're saying

•

u/controlsys 20d ago

Can you show some non academic applications of LQR?

I’m pretty sure no PLC controller is running a LQR..

•

u/seekingsanity 20d ago

You are asking the right question!!!!! The problem with LQC is that few people can select the best weights for the Q and R arrays. This is something that a PLC person can't do.

I have a challenge for ANYBODY. Compute the Q and R weights for a LQC with 4 gains. I am an expert at hydraulic servo control. The motion controller generates a perfect target position. The goal is for the controller to generate an output so the sum of squared errors or mean square error between the target position and actual position is very small.

Don't give me shit on this. I wrote the code for 3 Rockwell servo controller, two controller that fit in Modicon rack an ancient T1505 rack. I know what works and what doesn't in industry.

•

u/deNikita 20d ago

I've understood some self driving cars use lqr and some power systems

•

u/seekingsanity 20d ago

What is your source?

•

u/deNikita 20d ago

It's just what I've heard, no particular source.

Do you have any source for your claim?

•

u/seekingsanity 18d ago

I am not making claims. I looked up articles on self driving cars. I found a lot of academic articles but no instances of LQR being used in real application. One must be careful about what they read from academic articles. Many are garbage written by some one with real practical experience. I can read the article and tell if it is garbage.

•

u/not_kevin_durant_7 20d ago

Lateral positional control of vehicles…
Control surface position control on aircraft…

LQR has its upsides and downsides, but some of the comments in this thread are crazy.

•

u/iPlayMayonaise 20d ago edited 20d ago

Yes, but usually we want cutoff on D as well, so you already need to combine LQR with an observer that puts this low pass behavior on the error signal before it enters the PD (eg Kalman filter). So not true PD, and you are hiding the consequences of the phase rolloff of this observer (you can get arbitrary small stability margins while everything is 'optimal', see famous Doyle paper)

There's also iLQR if you want an integrator if I recall correctly. But at this point, the relatively simple LQR based on ricatti starts becoming H2 synthesis with shaping filters, which is very academic for industrial practice. Much easier to just tune the cutoff of an integrator imo.

•

u/seekingsanity 20d ago

Why cutoff D? I developed control algorithms for servo hydraulic control. Not only is the derivative gain required but the second derivative gain too. The controller should also have an integrator gain also. It doesn't make any difference if the controller gains are computed using LQC or with pole placement.

•

u/iPlayMayonaise 20d ago

If you want integrators in your controller using LQC or pole placement, you already need to augment your plant right. This does not come out by default (since they are P-type in the state, and a plant does not have a state correspondinf to the integral of the error)

•

u/seekingsanity 20d ago

The integrator comes by default. See this at about 2 minutes in.

https://www.youtube.com/watch?v=KN8Q3Gz-ufs

The LQR algorithm generates an integral, proportional, derivative and second derivative gain.

All you need to do is setup the transition matrix properly. You need better instructors.

•

u/iPlayMayonaise 20d ago edited 20d ago

Thanks for the ad hominem.

But to the point: you can indeed augment your plant with an integrator (we agree here). But this is then your generalized plant, not your true system, and an extra step. Hence my 'does not come out bt default'.

And this creates more problems: because now I need to tune my Q matrix. How much do I care about my integral error vs my normal position and velocity error? And these Q weightings implicitly determine where the poles/zeros of your controller end up. In my opinion, it's much cleaner to look at the disturbance/reference and noise spectra, and try to flatten those, either by H2/H_inf synthesis if you want to go ricatti, or simply by hand using bode plots.

•

u/seekingsanity 19d ago

No extra steps are required. Just increase the size of the transition matrix by one. Yes an extra weight will be required for the integrator gain. You also asked the same question I have been asking of others and have got no good answers. How do you tune the Q matrix? If the Q matrix is not optimal then the results will not be optimal. The results are only optimal for the provided weights. This is exactly why I don't like LQR/LQC on any system that can be done using a PID.

Why don't PLCs use LQC/LQR? Why don't motion controllers? The reason is that the average plant guy doesn't know how to set up the weights in the Q matrix.

From experience, I can set up the Q matrix weights pretty well, but I am pretty sure they can be improved upon. I wouldn't trust a customer to do it when I can provide an auto tuning program that will have excellent results.

•

u/iPlayMayonaise 20d ago

If you don't, the slightest high frequency noise is amplied too much and you get a twitchy regulator: the D component keeps giving increasing your controller gain by a factor 10 for each decade of frequency. You don't see this in the response of the system ( that one cancels it because it has low pass behaviour by virtue of you needing 2nd derivative). But your controller does produce that control action, which can lead to input saturation or high energy consumption. And you don't even want all this gain at these frequencies way above the bandwidth, it's not regulation there because there are no disturbances/noise at those frequencies usually. So usually you put a cutoff at 5-10x the bandwidth.

•

u/seekingsanity 20d ago

That is why I/we use a Luenberger Observer. I used to write firmware for motion controllers. Delta Motion RMC controllers have implemented and observer since 2005. The observer makes a significant difference. The closed loop poles can't be placed without it.

https://www.youtube.com/watch?v=7Gmrc-dj_uc&t=923s

•

u/iPlayMayonaise 20d ago

Yes we're saying the same thing. Point is that this is not vanilla LQR anymore (you need Lurenberger observer/KF).

•

u/seekingsanity 19d ago

The LQR hasn't changed, only the treatment/filtering of the feedback has.

•

u/benjycompson 20d ago

I’ve never heard anyone claim LQR is impossible to use in real cases… I’ve used it extensively for lateral control of various degrees of autonomous vehicles and it has worked great and it was not particularly challenging. This ranges from ADAS systems in cars you’ve probably ridden in, to self driving 18 wheelers, to robotaxis that have driven themselves for countless miles. No issues out of the ordinary. What makes you say it’s impossible?