diff --git a/wpimath/src/main/native/include/frc/kinematics/SwerveDriveKinematics.h b/wpimath/src/main/native/include/frc/kinematics/SwerveDriveKinematics.h index 97ee2336d1..25ae3f3291 100644 --- a/wpimath/src/main/native/include/frc/kinematics/SwerveDriveKinematics.h +++ b/wpimath/src/main/native/include/frc/kinematics/SwerveDriveKinematics.h @@ -5,6 +5,7 @@ #pragma once #include +#include #include #include @@ -146,7 +147,10 @@ class SwerveDriveKinematics { * @return The resulting chassis speed. */ template - ChassisSpeeds ToChassisSpeeds(ModuleStates&&... wheelStates) const; + requires(std::is_same_v, + SwerveModuleState>&&...) ChassisSpeeds + ToChassisSpeeds(ModuleStates&&... wheelStates) + const; /** * Performs forward kinematics to return the resulting chassis state from the @@ -162,7 +166,7 @@ class SwerveDriveKinematics { * @return The resulting chassis speed. */ ChassisSpeeds ToChassisSpeeds( - wpi::array moduleStates) const; + const wpi::array& moduleStates) const; /** * Performs forward kinematics to return the resulting Twist2d from the diff --git a/wpimath/src/main/native/include/frc/kinematics/SwerveDriveKinematics.inc b/wpimath/src/main/native/include/frc/kinematics/SwerveDriveKinematics.inc index 9a2b5abeeb..8db7f9ce2c 100644 --- a/wpimath/src/main/native/include/frc/kinematics/SwerveDriveKinematics.inc +++ b/wpimath/src/main/native/include/frc/kinematics/SwerveDriveKinematics.inc @@ -66,8 +66,11 @@ SwerveDriveKinematics::ToSwerveModuleStates( template template -ChassisSpeeds SwerveDriveKinematics::ToChassisSpeeds( - ModuleStates&&... wheelStates) const { +requires(std::is_same_v, + SwerveModuleState>&&...) + ChassisSpeeds SwerveDriveKinematics::ToChassisSpeeds( + ModuleStates&&... wheelStates) +const { static_assert(sizeof...(wheelStates) == NumModules, "Number of modules is not consistent with number of wheel " "locations provided in constructor."); @@ -79,7 +82,7 @@ ChassisSpeeds SwerveDriveKinematics::ToChassisSpeeds( template ChassisSpeeds SwerveDriveKinematics::ToChassisSpeeds( - wpi::array moduleStates) const { + const wpi::array& moduleStates) const { Matrixd moduleStateMatrix; for (size_t i = 0; i < NumModules; ++i) {