diff --git a/apriltag/src/main/native/include/frc/apriltag/AprilTagDetection.h b/apriltag/src/main/native/include/frc/apriltag/AprilTagDetection.h index 5225f2176b..babcbd8309 100644 --- a/apriltag/src/main/native/include/frc/apriltag/AprilTagDetection.h +++ b/apriltag/src/main/native/include/frc/apriltag/AprilTagDetection.h @@ -9,10 +9,9 @@ #include #include +#include #include -#include "frc/EigenCore.h" - namespace frc { /** diff --git a/wpilibc/src/main/native/cpp/simulation/DifferentialDrivetrainSim.cpp b/wpilibc/src/main/native/cpp/simulation/DifferentialDrivetrainSim.cpp index b6c95dc0ab..8c27cdf15b 100644 --- a/wpilibc/src/main/native/cpp/simulation/DifferentialDrivetrainSim.cpp +++ b/wpilibc/src/main/native/cpp/simulation/DifferentialDrivetrainSim.cpp @@ -41,7 +41,8 @@ DifferentialDrivetrainSim::DifferentialDrivetrainSim( driveMotor, mass, wheelRadius, trackWidth / 2.0, J, gearing), trackWidth, driveMotor, gearing, wheelRadius, measurementStdDevs) {} -Vectord<2> DifferentialDrivetrainSim::ClampInput(const Vectord<2>& u) { +Eigen::Vector2d DifferentialDrivetrainSim::ClampInput( + const Eigen::Vector2d& u) { return frc::DesaturateInputVector<2>(u, frc::RobotController::GetInputVoltage()); } @@ -128,7 +129,7 @@ void DifferentialDrivetrainSim::SetPose(const frc::Pose2d& pose) { } Vectord<7> DifferentialDrivetrainSim::Dynamics(const Vectord<7>& x, - const Vectord<2>& u) { + const Eigen::Vector2d& u) { // Because G² can be factored out of A, we can divide by the old ratio // squared and multiply by the new ratio squared to get a new drivetrain // model. diff --git a/wpilibc/src/main/native/include/frc/simulation/DifferentialDrivetrainSim.h b/wpilibc/src/main/native/include/frc/simulation/DifferentialDrivetrainSim.h index 812943a2c9..78310d78c7 100644 --- a/wpilibc/src/main/native/include/frc/simulation/DifferentialDrivetrainSim.h +++ b/wpilibc/src/main/native/include/frc/simulation/DifferentialDrivetrainSim.h @@ -80,7 +80,7 @@ class DifferentialDrivetrainSim { * @param u The input vector. * @return The normalized input. */ - Vectord<2> ClampInput(const Vectord<2>& u); + Eigen::Vector2d ClampInput(const Eigen::Vector2d& u); /** * Sets the applied voltage to the drivetrain. Note that positive voltage must @@ -187,7 +187,7 @@ class DifferentialDrivetrainSim { */ void SetPose(const frc::Pose2d& pose); - Vectord<7> Dynamics(const Vectord<7>& x, const Vectord<2>& u); + Vectord<7> Dynamics(const Vectord<7>& x, const Eigen::Vector2d& u); class State { public: @@ -325,7 +325,7 @@ class DifferentialDrivetrainSim { double m_currentGearing; Vectord<7> m_x; - Vectord<2> m_u; + Eigen::Vector2d m_u; Vectord<7> m_y; std::array m_measurementStdDevs; }; diff --git a/wpimath/src/main/native/cpp/StateSpaceUtil.cpp b/wpimath/src/main/native/cpp/StateSpaceUtil.cpp index 4e606189b4..758d2e772a 100644 --- a/wpimath/src/main/native/cpp/StateSpaceUtil.cpp +++ b/wpimath/src/main/native/cpp/StateSpaceUtil.cpp @@ -6,16 +6,16 @@ namespace frc { -Vectord<3> PoseTo3dVector(const Pose2d& pose) { - return Vectord<3>{pose.Translation().X().value(), - pose.Translation().Y().value(), - pose.Rotation().Radians().value()}; +Eigen::Vector3d PoseTo3dVector(const Pose2d& pose) { + return Eigen::Vector3d{pose.Translation().X().value(), + pose.Translation().Y().value(), + pose.Rotation().Radians().value()}; } -Vectord<4> PoseTo4dVector(const Pose2d& pose) { - return Vectord<4>{pose.Translation().X().value(), - pose.Translation().Y().value(), pose.Rotation().Cos(), - pose.Rotation().Sin()}; +Eigen::Vector4d PoseTo4dVector(const Pose2d& pose) { + return Eigen::Vector4d{pose.Translation().X().value(), + pose.Translation().Y().value(), pose.Rotation().Cos(), + pose.Rotation().Sin()}; } template <> @@ -34,9 +34,9 @@ bool IsStabilizable(const Eigen::MatrixXd& A, return detail::IsStabilizableImpl(A, B); } -Vectord<3> PoseToVector(const Pose2d& pose) { - return Vectord<3>{pose.X().value(), pose.Y().value(), - pose.Rotation().Radians().value()}; +Eigen::Vector3d PoseToVector(const Pose2d& pose) { + return Eigen::Vector3d{pose.X().value(), pose.Y().value(), + pose.Rotation().Radians().value()}; } } // namespace frc diff --git a/wpimath/src/main/native/cpp/controller/DifferentialDriveFeedforward.cpp b/wpimath/src/main/native/cpp/controller/DifferentialDriveFeedforward.cpp index e1b2732642..257d7e1efc 100644 --- a/wpimath/src/main/native/cpp/controller/DifferentialDriveFeedforward.cpp +++ b/wpimath/src/main/native/cpp/controller/DifferentialDriveFeedforward.cpp @@ -4,7 +4,8 @@ #include "frc/controller/DifferentialDriveFeedforward.h" -#include "frc/EigenCore.h" +#include + #include "frc/controller/LinearPlantInversionFeedforward.h" #include "frc/system/plant/LinearSystemId.h" @@ -30,8 +31,8 @@ DifferentialDriveWheelVoltages DifferentialDriveFeedforward::Calculate( units::meters_per_second_t nextRightVelocity, units::second_t dt) { frc::LinearPlantInversionFeedforward<2, 2> feedforward{m_plant, dt}; - frc::Vectord<2> r{currentLeftVelocity, currentRightVelocity}; - frc::Vectord<2> nextR{nextLeftVelocity, nextRightVelocity}; + Eigen::Vector2d r{currentLeftVelocity, currentRightVelocity}; + Eigen::Vector2d nextR{nextLeftVelocity, nextRightVelocity}; auto u = feedforward.Calculate(r, nextR); return {units::volt_t{u(0)}, units::volt_t{u(1)}}; } diff --git a/wpimath/src/main/native/cpp/geometry/CoordinateSystem.cpp b/wpimath/src/main/native/cpp/geometry/CoordinateSystem.cpp index 400a5e5617..2a8c9db154 100644 --- a/wpimath/src/main/native/cpp/geometry/CoordinateSystem.cpp +++ b/wpimath/src/main/native/cpp/geometry/CoordinateSystem.cpp @@ -8,6 +8,7 @@ #include #include +#include #include using namespace frc; @@ -18,7 +19,7 @@ CoordinateSystem::CoordinateSystem(const CoordinateAxis& positiveX, // Construct a change of basis matrix from the source coordinate system to the // NWU coordinate system. Each column vector in the change of basis matrix is // one of the old basis vectors mapped to its representation in the new basis. - Matrixd<3, 3> R; + Eigen::Matrix3d R; R.block<3, 1>(0, 0) = positiveX.m_axis; R.block<3, 1>(0, 1) = positiveY.m_axis; R.block<3, 1>(0, 2) = positiveZ.m_axis; diff --git a/wpimath/src/main/native/cpp/geometry/Pose3d.cpp b/wpimath/src/main/native/cpp/geometry/Pose3d.cpp index 845ea7d0e4..f479b0d705 100644 --- a/wpimath/src/main/native/cpp/geometry/Pose3d.cpp +++ b/wpimath/src/main/native/cpp/geometry/Pose3d.cpp @@ -6,6 +6,7 @@ #include +#include #include using namespace frc; @@ -21,14 +22,14 @@ namespace { * @param rotation The rotation vector. * @return The rotation vector as a 3x3 rotation matrix. */ -Matrixd<3, 3> RotationVectorToMatrix(const Vectord<3>& rotation) { +Eigen::Matrix3d RotationVectorToMatrix(const Eigen::Vector3d& rotation) { // Given a rotation vector , // [ 0 -c b] // Omega = [ c 0 -a] // [-b a 0] - return Matrixd<3, 3>{{0.0, -rotation(2), rotation(1)}, - {rotation(2), 0.0, -rotation(0)}, - {-rotation(1), rotation(0), 0.0}}; + return Eigen::Matrix3d{{0.0, -rotation(2), rotation(1)}, + {rotation(2), 0.0, -rotation(0)}, + {-rotation(1), rotation(0), 0.0}}; } } // namespace diff --git a/wpimath/src/main/native/cpp/geometry/Rotation3d.cpp b/wpimath/src/main/native/cpp/geometry/Rotation3d.cpp index a898d0d577..d1f18464a1 100644 --- a/wpimath/src/main/native/cpp/geometry/Rotation3d.cpp +++ b/wpimath/src/main/native/cpp/geometry/Rotation3d.cpp @@ -41,23 +41,23 @@ Rotation3d::Rotation3d(units::radian_t roll, units::radian_t pitch, Rotation3d::Rotation3d(const Eigen::Vector3d& rvec) : Rotation3d{rvec, units::radian_t{rvec.norm()}} {} -Rotation3d::Rotation3d(const Vectord<3>& axis, units::radian_t angle) { +Rotation3d::Rotation3d(const Eigen::Vector3d& axis, units::radian_t angle) { double norm = axis.norm(); if (norm == 0.0) { return; } // https://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles#Definition - Vectord<3> v = axis / norm * units::math::sin(angle / 2.0); + Eigen::Vector3d v = axis / norm * units::math::sin(angle / 2.0); m_q = Quaternion{units::math::cos(angle / 2.0), v(0), v(1), v(2)}; } -Rotation3d::Rotation3d(const Matrixd<3, 3>& rotationMatrix) { +Rotation3d::Rotation3d(const Eigen::Matrix3d& rotationMatrix) { const auto& R = rotationMatrix; // Require that the rotation matrix is special orthogonal. This is true if the // matrix is orthogonal (RRᵀ = I) and normalized (determinant is 1). - if ((R * R.transpose() - Matrixd<3, 3>::Identity()).norm() > 1e-9) { + if ((R * R.transpose() - Eigen::Matrix3d::Identity()).norm() > 1e-9) { std::string msg = fmt::format("Rotation matrix isn't orthogonal\n\nR =\n{}\n", R); @@ -112,7 +112,8 @@ Rotation3d::Rotation3d(const Matrixd<3, 3>& rotationMatrix) { m_q = Quaternion{w, x, y, z}; } -Rotation3d::Rotation3d(const Vectord<3>& initial, const Vectord<3>& final) { +Rotation3d::Rotation3d(const Eigen::Vector3d& initial, + const Eigen::Vector3d& final) { double dot = initial.dot(final); double normProduct = initial.norm() * final.norm(); double dotNorm = dot / normProduct; @@ -230,7 +231,7 @@ units::radian_t Rotation3d::Z() const { } } -Vectord<3> Rotation3d::Axis() const { +Eigen::Vector3d Rotation3d::Axis() const { double norm = std::hypot(m_q.X(), m_q.Y(), m_q.Z()); if (norm == 0.0) { return {0.0, 0.0, 0.0}; diff --git a/wpimath/src/main/native/cpp/kinematics/MecanumDriveKinematics.cpp b/wpimath/src/main/native/cpp/kinematics/MecanumDriveKinematics.cpp index c7618d545b..c21a7b2034 100644 --- a/wpimath/src/main/native/cpp/kinematics/MecanumDriveKinematics.cpp +++ b/wpimath/src/main/native/cpp/kinematics/MecanumDriveKinematics.cpp @@ -25,7 +25,7 @@ MecanumDriveWheelSpeeds MecanumDriveKinematics::ToWheelSpeeds( chassisSpeeds.vy.value(), chassisSpeeds.omega.value()}; - Vectord<4> wheelsVector = m_inverseKinematics * chassisSpeedsVector; + Eigen::Vector4d wheelsVector = m_inverseKinematics * chassisSpeedsVector; MecanumDriveWheelSpeeds wheelSpeeds; wheelSpeeds.frontLeft = units::meters_per_second_t{wheelsVector(0)}; @@ -37,7 +37,7 @@ MecanumDriveWheelSpeeds MecanumDriveKinematics::ToWheelSpeeds( ChassisSpeeds MecanumDriveKinematics::ToChassisSpeeds( const MecanumDriveWheelSpeeds& wheelSpeeds) const { - Vectord<4> wheelSpeedsVector{ + Eigen::Vector4d wheelSpeedsVector{ wheelSpeeds.frontLeft.value(), wheelSpeeds.frontRight.value(), wheelSpeeds.rearLeft.value(), wheelSpeeds.rearRight.value()}; @@ -52,7 +52,7 @@ ChassisSpeeds MecanumDriveKinematics::ToChassisSpeeds( Twist2d MecanumDriveKinematics::ToTwist2d( const MecanumDriveWheelPositions& start, const MecanumDriveWheelPositions& end) const { - Vectord<4> wheelDeltasVector{ + Eigen::Vector4d wheelDeltasVector{ end.frontLeft.value() - start.frontLeft.value(), end.frontRight.value() - start.frontRight.value(), end.rearLeft.value() - start.rearLeft.value(), @@ -66,7 +66,7 @@ Twist2d MecanumDriveKinematics::ToTwist2d( Twist2d MecanumDriveKinematics::ToTwist2d( const MecanumDriveWheelPositions& wheelDeltas) const { - Vectord<4> wheelDeltasVector{ + Eigen::Vector4d wheelDeltasVector{ wheelDeltas.frontLeft.value(), wheelDeltas.frontRight.value(), wheelDeltas.rearLeft.value(), wheelDeltas.rearRight.value()}; diff --git a/wpimath/src/main/native/include/frc/StateSpaceUtil.h b/wpimath/src/main/native/include/frc/StateSpaceUtil.h index aefc2f12f7..8c2ac65481 100644 --- a/wpimath/src/main/native/include/frc/StateSpaceUtil.h +++ b/wpimath/src/main/native/include/frc/StateSpaceUtil.h @@ -226,7 +226,7 @@ Vectord MakeWhiteNoiseVector(const std::array& stdDevs) { * @return The vector. */ WPILIB_DLLEXPORT -Vectord<3> PoseTo3dVector(const Pose2d& pose); +Eigen::Vector3d PoseTo3dVector(const Pose2d& pose); /** * Converts a Pose2d into a vector of [x, y, std::cos(theta), std::sin(theta)]. @@ -236,7 +236,7 @@ Vectord<3> PoseTo3dVector(const Pose2d& pose); * @return The vector. */ WPILIB_DLLEXPORT -Vectord<4> PoseTo4dVector(const Pose2d& pose); +Eigen::Vector4d PoseTo4dVector(const Pose2d& pose); /** * Returns true if (A, B) is a stabilizable pair. @@ -301,7 +301,7 @@ WPILIB_DLLEXPORT bool IsStabilizable( * @return The vector. */ WPILIB_DLLEXPORT -Vectord<3> PoseToVector(const Pose2d& pose); +Eigen::Vector3d PoseToVector(const Pose2d& pose); /** * Clamps input vector between system's minimum and maximum allowable input. diff --git a/wpimath/src/main/native/include/frc/estimator/MecanumDrivePoseEstimator.h b/wpimath/src/main/native/include/frc/estimator/MecanumDrivePoseEstimator.h index 52794fb844..d748164f47 100644 --- a/wpimath/src/main/native/include/frc/estimator/MecanumDrivePoseEstimator.h +++ b/wpimath/src/main/native/include/frc/estimator/MecanumDrivePoseEstimator.h @@ -9,7 +9,6 @@ #include #include -#include "frc/EigenCore.h" #include "frc/estimator/PoseEstimator.h" #include "frc/geometry/Pose2d.h" #include "frc/geometry/Rotation2d.h" diff --git a/wpimath/src/main/native/include/frc/estimator/PoseEstimator.h b/wpimath/src/main/native/include/frc/estimator/PoseEstimator.h index 542ab2e315..eb437a40f7 100644 --- a/wpimath/src/main/native/include/frc/estimator/PoseEstimator.h +++ b/wpimath/src/main/native/include/frc/estimator/PoseEstimator.h @@ -4,10 +4,10 @@ #pragma once +#include #include #include -#include "frc/EigenCore.h" #include "frc/geometry/Pose2d.h" #include "frc/geometry/Rotation2d.h" #include "frc/interpolation/TimeInterpolatableBuffer.h" diff --git a/wpimath/src/main/native/include/frc/estimator/PoseEstimator.inc b/wpimath/src/main/native/include/frc/estimator/PoseEstimator.inc index 1bd6e3d0a0..79d71bcc56 100644 --- a/wpimath/src/main/native/include/frc/estimator/PoseEstimator.inc +++ b/wpimath/src/main/native/include/frc/estimator/PoseEstimator.inc @@ -81,9 +81,9 @@ void PoseEstimator::AddVisionMeasurement( // Step 3: We should not trust the twist entirely, so instead we scale this // twist by a Kalman gain matrix representing how much we trust vision // measurements compared to our current pose. - Vectord<3> k_times_twist = + Eigen::Vector3d k_times_twist = m_visionK * - Vectord<3>{twist.dx.value(), twist.dy.value(), twist.dtheta.value()}; + Eigen::Vector3d{twist.dx.value(), twist.dy.value(), twist.dtheta.value()}; // Step 4: Convert back to Twist2d Twist2d scaledTwist{units::meter_t{k_times_twist(0)}, diff --git a/wpimath/src/main/native/include/frc/geometry/CoordinateAxis.h b/wpimath/src/main/native/include/frc/geometry/CoordinateAxis.h index 58b966ab07..2b471b7d5d 100644 --- a/wpimath/src/main/native/include/frc/geometry/CoordinateAxis.h +++ b/wpimath/src/main/native/include/frc/geometry/CoordinateAxis.h @@ -4,9 +4,9 @@ #pragma once +#include #include -#include "frc/EigenCore.h" #include "frc/geometry/Pose3d.h" #include "frc/geometry/Rotation3d.h" @@ -67,7 +67,7 @@ class WPILIB_DLLEXPORT CoordinateAxis { private: friend class CoordinateSystem; - Vectord<3> m_axis; + Eigen::Vector3d m_axis; }; } // namespace frc diff --git a/wpimath/src/main/native/include/frc/geometry/CoordinateSystem.h b/wpimath/src/main/native/include/frc/geometry/CoordinateSystem.h index 232455ff86..f5e71f2b28 100644 --- a/wpimath/src/main/native/include/frc/geometry/CoordinateSystem.h +++ b/wpimath/src/main/native/include/frc/geometry/CoordinateSystem.h @@ -6,7 +6,6 @@ #include -#include "frc/EigenCore.h" #include "frc/geometry/CoordinateAxis.h" #include "frc/geometry/Pose3d.h" #include "frc/geometry/Rotation3d.h" diff --git a/wpimath/src/main/native/include/frc/geometry/Quaternion.h b/wpimath/src/main/native/include/frc/geometry/Quaternion.h index 44b7991cdf..a41e5b80bf 100644 --- a/wpimath/src/main/native/include/frc/geometry/Quaternion.h +++ b/wpimath/src/main/native/include/frc/geometry/Quaternion.h @@ -4,10 +4,9 @@ #pragma once +#include #include -#include "frc/EigenCore.h" - namespace wpi { class json; } // namespace wpi diff --git a/wpimath/src/main/native/include/frc/geometry/Rotation3d.h b/wpimath/src/main/native/include/frc/geometry/Rotation3d.h index e49787073a..887f01a970 100644 --- a/wpimath/src/main/native/include/frc/geometry/Rotation3d.h +++ b/wpimath/src/main/native/include/frc/geometry/Rotation3d.h @@ -4,9 +4,9 @@ #pragma once +#include #include -#include "frc/EigenCore.h" #include "frc/geometry/Quaternion.h" #include "frc/geometry/Rotation2d.h" #include "units/angle.h" @@ -57,7 +57,7 @@ class WPILIB_DLLEXPORT Rotation3d { * @param axis The rotation axis. * @param angle The rotation around the axis. */ - Rotation3d(const Vectord<3>& axis, units::radian_t angle); + Rotation3d(const Eigen::Vector3d& axis, units::radian_t angle); /** * Constructs a Rotation3d with the given rotation vector representation. This @@ -86,7 +86,7 @@ class WPILIB_DLLEXPORT Rotation3d { * @param initial The initial vector. * @param final The final vector. */ - Rotation3d(const Vectord<3>& initial, const Vectord<3>& final); + Rotation3d(const Eigen::Vector3d& initial, const Eigen::Vector3d& final); /** * Adds two rotations together. @@ -173,7 +173,7 @@ class WPILIB_DLLEXPORT Rotation3d { /** * Returns the axis in the axis-angle representation of this rotation. */ - Vectord<3> Axis() const; + Eigen::Vector3d Axis() const; /** * Returns the angle in the axis-angle representation of this rotation. diff --git a/wpimath/src/main/native/include/frc/spline/CubicHermiteSpline.h b/wpimath/src/main/native/include/frc/spline/CubicHermiteSpline.h index 0636707958..1d6aaeb60e 100644 --- a/wpimath/src/main/native/include/frc/spline/CubicHermiteSpline.h +++ b/wpimath/src/main/native/include/frc/spline/CubicHermiteSpline.h @@ -49,7 +49,7 @@ class WPILIB_DLLEXPORT CubicHermiteSpline : public Spline<3> { * Returns the hermite basis matrix for cubic hermite spline interpolation. * @return The hermite basis matrix for cubic hermite spline interpolation. */ - static Matrixd<4, 4> MakeHermiteBasis() { + static Eigen::Matrix4d MakeHermiteBasis() { // Given P(i), P'(i), P(i+1), P'(i+1), the control vectors, we want to find // the coefficients of the spline P(t) = a₃t³ + a₂t² + a₁t + a₀. // @@ -71,10 +71,10 @@ class WPILIB_DLLEXPORT CubicHermiteSpline : public Spline<3> { // [a₁] = [ 0 1 0 0][P(i+1) ] // [a₀] = [ 1 0 0 0][P'(i+1)] - static const Matrixd<4, 4> basis{{+2.0, +1.0, -2.0, +1.0}, - {-3.0, -2.0, +3.0, -1.0}, - {+0.0, +1.0, +0.0, +0.0}, - {+1.0, +0.0, +0.0, +0.0}}; + static const Eigen::Matrix4d basis{{+2.0, +1.0, -2.0, +1.0}, + {-3.0, -2.0, +3.0, -1.0}, + {+0.0, +1.0, +0.0, +0.0}, + {+1.0, +0.0, +0.0, +0.0}}; return basis; } diff --git a/wpimath/src/main/native/include/frc/system/NumericalIntegration.h b/wpimath/src/main/native/include/frc/system/NumericalIntegration.h index 4f7ba319ea..98b6cc3044 100644 --- a/wpimath/src/main/native/include/frc/system/NumericalIntegration.h +++ b/wpimath/src/main/native/include/frc/system/NumericalIntegration.h @@ -4,12 +4,9 @@ #pragma once -#include - #include #include - -#include +#include #include "units/time.h" diff --git a/wpimath/src/test/native/cpp/EigenTest.cpp b/wpimath/src/test/native/cpp/EigenTest.cpp index 20f708778a..74c8577aaa 100644 --- a/wpimath/src/test/native/cpp/EigenTest.cpp +++ b/wpimath/src/test/native/cpp/EigenTest.cpp @@ -30,17 +30,17 @@ TEST(EigenTest, Multiplication) { } TEST(EigenTest, Transpose) { - frc::Vectord<3> vec{1, 2, 3}; + Eigen::Vector3d vec{1, 2, 3}; const auto transpose = vec.transpose(); - Eigen::RowVector expectedTranspose{1, 2, 3}; + Eigen::RowVector3d expectedTranspose{1, 2, 3}; EXPECT_TRUE(expectedTranspose.isApprox(transpose)); } TEST(EigenTest, Inverse) { - frc::Matrixd<3, 3> mat{{1.0, 3.0, 2.0}, {5.0, 2.0, 1.5}, {0.0, 1.3, 2.5}}; + Eigen::Matrix3d mat{{1.0, 3.0, 2.0}, {5.0, 2.0, 1.5}, {0.0, 1.3, 2.5}}; const auto inverse = mat.inverse(); const auto identity = Eigen::MatrixXd::Identity(3, 3); diff --git a/wpimath/src/test/native/cpp/controller/DifferentialDriveFeedforwardTest.cpp b/wpimath/src/test/native/cpp/controller/DifferentialDriveFeedforwardTest.cpp index 0ae246bb4e..5428d843ca 100644 --- a/wpimath/src/test/native/cpp/controller/DifferentialDriveFeedforwardTest.cpp +++ b/wpimath/src/test/native/cpp/controller/DifferentialDriveFeedforwardTest.cpp @@ -4,9 +4,9 @@ #include +#include #include -#include "frc/EigenCore.h" #include "frc/controller/DifferentialDriveFeedforward.h" #include "frc/controller/LinearPlantInversionFeedforward.h" #include "frc/system/plant/LinearSystemId.h" @@ -38,9 +38,9 @@ TEST(DifferentialDriveFeedforwardTest, CalculateWithTrackwidth) { auto [left, right] = differentialDriveFeedforward.Calculate( currentLeftVelocity, nextLeftVelocity, currentRightVelocity, nextRightVelocity, dt); - frc::Matrixd<2, 1> nextX = plant.CalculateX( - frc::Vectord<2>{currentLeftVelocity, currentRightVelocity}, - frc::Vectord<2>{left, right}, dt); + Eigen::Vector2d nextX = plant.CalculateX( + Eigen::Vector2d{currentLeftVelocity, currentRightVelocity}, + Eigen::Vector2d{left, right}, dt); EXPECT_NEAR(nextX(0), nextLeftVelocity.value(), 1e-6); EXPECT_NEAR(nextX(1), nextRightVelocity.value(), 1e-6); } @@ -72,9 +72,9 @@ TEST(DifferentialDriveFeedforwardTest, CalculateWithoutTrackwidth) { auto [left, right] = differentialDriveFeedforward.Calculate( currentLeftVelocity, nextLeftVelocity, currentRightVelocity, nextRightVelocity, dt); - frc::Matrixd<2, 1> nextX = plant.CalculateX( - frc::Vectord<2>{currentLeftVelocity, currentRightVelocity}, - frc::Vectord<2>{left, right}, dt); + Eigen::Vector2d nextX = plant.CalculateX( + Eigen::Vector2d{currentLeftVelocity, currentRightVelocity}, + Eigen::Vector2d{left, right}, dt); EXPECT_NEAR(nextX(0), nextLeftVelocity.value(), 1e-6); EXPECT_NEAR(nextX(1), nextRightVelocity.value(), 1e-6); } diff --git a/wpimath/src/test/native/cpp/geometry/Rotation3dTest.cpp b/wpimath/src/test/native/cpp/geometry/Rotation3dTest.cpp index aa2ea1176f..01b37e5b10 100644 --- a/wpimath/src/test/native/cpp/geometry/Rotation3dTest.cpp +++ b/wpimath/src/test/native/cpp/geometry/Rotation3dTest.cpp @@ -5,10 +5,10 @@ #include #include +#include #include #include -#include "frc/EigenCore.h" #include "frc/geometry/Rotation3d.h" using namespace frc; @@ -73,25 +73,25 @@ TEST(Rotation3dTest, InitAxisAngleAndRollPitchYaw) { TEST(Rotation3dTest, InitRotationMatrix) { // No rotation - const Matrixd<3, 3> R1 = Matrixd<3, 3>::Identity(); + const Eigen::Matrix3d R1 = Eigen::Matrix3d::Identity(); const Rotation3d rot1{R1}; EXPECT_EQ(Rotation3d{}, rot1); // 90 degree CCW rotation around z-axis - Matrixd<3, 3> R2; - R2.block<3, 1>(0, 0) = Vectord<3>{0.0, 1.0, 0.0}; - R2.block<3, 1>(0, 1) = Vectord<3>{-1.0, 0.0, 0.0}; - R2.block<3, 1>(0, 2) = Vectord<3>{0.0, 0.0, 1.0}; + Eigen::Matrix3d R2; + R2.block<3, 1>(0, 0) = Eigen::Vector3d{0.0, 1.0, 0.0}; + R2.block<3, 1>(0, 1) = Eigen::Vector3d{-1.0, 0.0, 0.0}; + R2.block<3, 1>(0, 2) = Eigen::Vector3d{0.0, 0.0, 1.0}; const Rotation3d rot2{R2}; const Rotation3d expected2{0_deg, 0_deg, 90_deg}; EXPECT_EQ(expected2, rot2); // Matrix that isn't orthogonal - const Matrixd<3, 3> R3{{1.0, 0.0, 0.0}, {1.0, 0.0, 0.0}, {1.0, 0.0, 0.0}}; + const Eigen::Matrix3d R3{{1.0, 0.0, 0.0}, {1.0, 0.0, 0.0}, {1.0, 0.0, 0.0}}; EXPECT_THROW(Rotation3d{R3}, std::domain_error); // Matrix that's orthogonal but not special orthogonal - const Matrixd<3, 3> R4 = Matrixd<3, 3>::Identity() * 2.0; + const Eigen::Matrix3d R4 = Eigen::Matrix3d::Identity() * 2.0; EXPECT_THROW(Rotation3d{R4}, std::domain_error); } diff --git a/wpimath/src/test/native/cpp/system/NumericalIntegrationTest.cpp b/wpimath/src/test/native/cpp/system/NumericalIntegrationTest.cpp index 45acb77829..1c73195ca7 100644 --- a/wpimath/src/test/native/cpp/system/NumericalIntegrationTest.cpp +++ b/wpimath/src/test/native/cpp/system/NumericalIntegrationTest.cpp @@ -6,6 +6,7 @@ #include +#include "frc/EigenCore.h" #include "frc/system/NumericalIntegration.h" // Tests that integrating dx/dt = e^x works. diff --git a/wpimath/src/test/native/cpp/system/RungeKuttaTimeVaryingTest.cpp b/wpimath/src/test/native/cpp/system/RungeKuttaTimeVaryingTest.cpp index d88908c339..e502e95f28 100644 --- a/wpimath/src/test/native/cpp/system/RungeKuttaTimeVaryingTest.cpp +++ b/wpimath/src/test/native/cpp/system/RungeKuttaTimeVaryingTest.cpp @@ -6,6 +6,7 @@ #include +#include "frc/EigenCore.h" #include "frc/system/RungeKuttaTimeVarying.h" namespace { diff --git a/wpimath/src/test/native/include/frc/system/RungeKuttaTimeVarying.h b/wpimath/src/test/native/include/frc/system/RungeKuttaTimeVarying.h index 5e7b165708..6273532b65 100644 --- a/wpimath/src/test/native/include/frc/system/RungeKuttaTimeVarying.h +++ b/wpimath/src/test/native/include/frc/system/RungeKuttaTimeVarying.h @@ -6,7 +6,6 @@ #include -#include "frc/EigenCore.h" #include "units/time.h" namespace frc {