mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[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:
committed by
Peter Johnson
parent
72716f51ce
commit
9359431bad
@@ -13,19 +13,14 @@
|
||||
namespace frc {
|
||||
|
||||
TEST(LinearPlantInversionFeedforwardTest, Calculate) {
|
||||
Eigen::Matrix<double, 2, 2> A;
|
||||
A << 1, 0, 0, 1;
|
||||
|
||||
Eigen::Matrix<double, 2, 1> B;
|
||||
B << 0, 1;
|
||||
Eigen::Matrix<double, 2, 2> A{{1, 0}, {0, 1}};
|
||||
Eigen::Matrix<double, 2, 1> B{0, 1};
|
||||
|
||||
frc::LinearPlantInversionFeedforward<2, 1> feedforward{A, B,
|
||||
units::second_t(0.02)};
|
||||
|
||||
Eigen::Matrix<double, 2, 1> r;
|
||||
r << 2, 2;
|
||||
Eigen::Matrix<double, 2, 1> nextR;
|
||||
nextR << 3, 3;
|
||||
Eigen::Vector<double, 2> r{2, 2};
|
||||
Eigen::Vector<double, 2> nextR{3, 3};
|
||||
|
||||
EXPECT_NEAR(47.502599, feedforward.Calculate(r, nextR)(0, 0), 0.002);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user