LQR

From Bike Wiki
Revision as of 18:09, 14 September 2019 by Daniel (talk | contribs) (.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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:


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!).