Difference between revisions of "LQR"

From Bike Wiki
Jump to navigation Jump to search
(+nte)
(+ see also)
Line 20: Line 20:
  
 
What's good about LQR? So you can tune the cost matrices (Q and R) instead of tuning the gains directly. The cost matrices have easier intuition (we just want to avoid this!).
 
What's good about LQR? So you can tune the cost matrices (Q and R) instead of tuning the gains directly. The cost matrices have easier intuition (we just want to avoid this!).
 +
 +
== See also ==
 +
* [[Matlab code]], where the LQR controllers and everything else get tested

Revision as of 23:59, 17 September 2019

When we use LQR, we penalize any deviations from an upright riding position. Q penalizes errors in the state. The state matrix has lean, lean rate, and delta as x1, x2, and x3 respectively. So, . Thus, our total error function is:

where (when we use it) is and is . Also, is: Your mileage may vary. Try changing these weights and seeing what happens.


Ryan thinks we really have to ensure that each state must have a nonzero cost, because LQR will eventually minimize cost. If we can possibly get negative cost somehow, then LQR would just give us that state, which sucks.

So. What LQR does is it says we must use the control law , where you get using matlab using the code:

[K, S, e] = lqr(A, B, Q, R);

where the system is defined as

On the bike, it is possible that we can use the control law


What's good about LQR? So you can tune the cost matrices (Q and R) instead of tuning the gains directly. The cost matrices have easier intuition (we just want to avoid this!).

See also

  • Matlab code, where the LQR controllers and everything else get tested