[wpimath] Fix LQR matrix constructor overload for Q, R, and N (#3884)

It was using the continuous B matrix to compute the feedback gain
instead of the discrete B matrix.

Tests were added for the matrix constructor overloads.
This commit is contained in:
Tyler Veness
2022-01-08 23:23:53 -08:00
committed by GitHub
parent 8ac45f20bb
commit db0fbb6448
4 changed files with 216 additions and 29 deletions

View File

@@ -135,7 +135,7 @@ class LinearQuadraticRegulatorImpl {
drake::math::DiscreteAlgebraicRiccatiEquation(discA, discB, Q, R, N);
// K = (BᵀSB + R)⁻¹(BᵀSA + Nᵀ)
m_K = (B.transpose() * S * B + R)
m_K = (discB.transpose() * S * discB + R)
.llt()
.solve(discB.transpose() * S * discA + N.transpose());