[wpimath] Clean up Eigen usage

* Replace Matrix<> with Vector<> where vectors are explicitly intended.
  I found these via `rg "Eigen::Matrix<double, \w+, 1>"`.
* Pass all Eigen matrices by const reference. I found these via `rg
  "\(Eigen"` on main (the initializer list constructors make more false
  positives).
* Replace MakeMatrix() and operator<< usage with initializer list
  constructors. I found these via `rg MakeMatrix` and `rg "<<"`
  respectively.
* Deprecate MakeMatrix()
This commit is contained in:
Tyler Veness
2021-08-19 00:23:48 -07:00
committed by Peter Johnson
parent 72716f51ce
commit 9359431bad
63 changed files with 821 additions and 955 deletions

View File

@@ -146,7 +146,7 @@ class LinearQuadraticRegulatorImpl {
*
* @return The reference vector.
*/
const Eigen::Matrix<double, States, 1>& R() const { return m_r; }
const Eigen::Vector<double, States>& R() const { return m_r; }
/**
* Returns an element of the reference vector r.
@@ -162,7 +162,7 @@ class LinearQuadraticRegulatorImpl {
*
* @return The control input.
*/
const Eigen::Matrix<double, Inputs, 1>& U() const { return m_u; }
const Eigen::Vector<double, Inputs>& U() const { return m_u; }
/**
* Returns an element of the control input vector u.
@@ -186,8 +186,8 @@ class LinearQuadraticRegulatorImpl {
*
* @param x The current state x.
*/
Eigen::Matrix<double, Inputs, 1> Calculate(
const Eigen::Matrix<double, States, 1>& x) {
Eigen::Vector<double, Inputs> Calculate(
const Eigen::Vector<double, States>& x) {
m_u = m_K * (m_r - x);
return m_u;
}
@@ -198,9 +198,9 @@ class LinearQuadraticRegulatorImpl {
* @param x The current state x.
* @param nextR The next reference vector r.
*/
Eigen::Matrix<double, Inputs, 1> Calculate(
const Eigen::Matrix<double, States, 1>& x,
const Eigen::Matrix<double, States, 1>& nextR) {
Eigen::Vector<double, Inputs> Calculate(
const Eigen::Vector<double, States>& x,
const Eigen::Vector<double, States>& nextR) {
m_r = nextR;
return Calculate(x);
}
@@ -233,10 +233,10 @@ class LinearQuadraticRegulatorImpl {
private:
// Current reference
Eigen::Matrix<double, States, 1> m_r;
Eigen::Vector<double, States> m_r;
// Computed controller output
Eigen::Matrix<double, Inputs, 1> m_u;
Eigen::Vector<double, Inputs> m_u;
// Controller gain
Eigen::Matrix<double, Inputs, States> m_K;