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
@@ -6,16 +6,16 @@
|
||||
|
||||
namespace frc {
|
||||
|
||||
Eigen::Matrix<double, 3, 1> PoseTo3dVector(const Pose2d& pose) {
|
||||
return frc::MakeMatrix<3, 1>(pose.Translation().X().to<double>(),
|
||||
pose.Translation().Y().to<double>(),
|
||||
pose.Rotation().Radians().to<double>());
|
||||
Eigen::Vector<double, 3> PoseTo3dVector(const Pose2d& pose) {
|
||||
return Eigen::Vector<double, 3>{pose.Translation().X().to<double>(),
|
||||
pose.Translation().Y().to<double>(),
|
||||
pose.Rotation().Radians().to<double>()};
|
||||
}
|
||||
|
||||
Eigen::Matrix<double, 4, 1> PoseTo4dVector(const Pose2d& pose) {
|
||||
return frc::MakeMatrix<4, 1>(pose.Translation().X().to<double>(),
|
||||
pose.Translation().Y().to<double>(),
|
||||
pose.Rotation().Cos(), pose.Rotation().Sin());
|
||||
Eigen::Vector<double, 4> PoseTo4dVector(const Pose2d& pose) {
|
||||
return Eigen::Vector<double, 4>{pose.Translation().X().to<double>(),
|
||||
pose.Translation().Y().to<double>(),
|
||||
pose.Rotation().Cos(), pose.Rotation().Sin()};
|
||||
}
|
||||
|
||||
template <>
|
||||
@@ -30,9 +30,9 @@ bool IsStabilizable<2, 1>(const Eigen::Matrix<double, 2, 2>& A,
|
||||
return detail::IsStabilizableImpl<2, 1>(A, B);
|
||||
}
|
||||
|
||||
Eigen::Matrix<double, 3, 1> PoseToVector(const Pose2d& pose) {
|
||||
return frc::MakeMatrix<3, 1>(pose.X().to<double>(), pose.Y().to<double>(),
|
||||
pose.Rotation().Radians().to<double>());
|
||||
Eigen::Vector<double, 3> PoseToVector(const Pose2d& pose) {
|
||||
return Eigen::Vector<double, 3>{pose.X().to<double>(), pose.Y().to<double>(),
|
||||
pose.Rotation().Radians().to<double>()};
|
||||
}
|
||||
|
||||
} // namespace frc
|
||||
|
||||
Reference in New Issue
Block a user