# LQR vs. Numerical Optimal Control

I'm a little confused by the differences between LQR control and numerical optimal control (such as direct multiple shooting, direct collocation and pseudospectral optimal control). It seems that LQR uses linear system dynamics to minimize a quadratic cost function and can find a solution rapidly, so it's suitable for on-board control. Whereas numerical optimal control uses full non-linear system dynamics to minimize a cost function (not necessarily quadratic), but requires a fairly good initial guess to achieve convergence to the desired solution, and can take a relatively long time to find a solution, so it isn't generally suitable for on-board control.

Having had some experience implementing numerical optimal control algorithms, I'm hoping to try and implement an LQR controller in similar simulated problems to see how each differs. If, for example, we consider the problem of minimizing the fuel used when vertically landing the first-stage of a rocket back on Earth, using 3-DOF dynamics in a Cartesian coordinate system, we get the following output for the system's states, $s = (x,y,v_{x},v_{y},m)^{T}$, and controls, $u=(u_{x},u_{y})^{T}$, versus time (the weird jagged control inputs that occur for most of the control profiles are due to the rocket's engines being turned off (coasting) and so control input is arbitrary since it has no effect on the rocket's trajectory).

Our required final state is zero x- and y-velocity $(v_{x}(t_{f}),v_{y}(t_{f}))=(0,0)$, and, if we consider our landing site to be at the origin of our coordinate system, a final x- and y-position of $(x(t_{f}),y(t_{f})) = (0,0)$. As can be seen, given our initial conditions, numerical optimal control produces a trajectory made up of a series of "waypoints" every few seconds, giving the control profile required to achieve the desired final state (a two-point boundary value problem), and simultaneously tries to minimize the fuel used to achieve such a trajectory.

Now, does an LQR controller act in a similar way, where I only have to give it my system's initial conditions, and it'll work out the series of control input values to use in order to meet the desired final conditions whilst minimizing fuel use? It seems almost too good to be true! I feel like I'm missing something fundamental to my understanding of their differences.

• Did you use any constraints on the allowed inputs, because if so then LQR won't be able to incorporate those. Also I assume your model also has atmospheric drag. This nonlinear dynamics can't be approximated well by a linear system over the specified velocity range. – fibonatic Sep 13 '17 at 3:50