From f3f59ca44ca911b9feff01de9a67a1ca9b77af85 Mon Sep 17 00:00:00 2001 From: thenetworkgrinch Date: Fri, 10 Jan 2025 16:20:34 -0600 Subject: [PATCH] Removed unnecessary units. Signed-off-by: thenetworkgrinch --- src/main/java/swervelib/SwerveModule.java | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/java/swervelib/SwerveModule.java b/src/main/java/swervelib/SwerveModule.java index 4d9b2a5c..b3acccd1 100644 --- a/src/main/java/swervelib/SwerveModule.java +++ b/src/main/java/swervelib/SwerveModule.java @@ -421,16 +421,16 @@ public void setDesiredState(SwerveModuleState desiredState, boolean isOpenLoop, } // Cosine compensation. - LinearVelocity nextVelocity = configuration.useCosineCompensator - ? getCosineCompensatedVelocity(desiredState) - : MetersPerSecond.of(desiredState.speedMetersPerSecond); - LinearVelocity curVelocity = MetersPerSecond.of(lastState.speedMetersPerSecond); - desiredState.speedMetersPerSecond = nextVelocity.magnitude(); + double nextVelocityMetersPerSecond = configuration.useCosineCompensator + ? getCosineCompensatedVelocity(desiredState) + : desiredState.speedMetersPerSecond; + double curVelocityMetersPerSecond = lastState.speedMetersPerSecond; + desiredState.speedMetersPerSecond = nextVelocityMetersPerSecond; setDesiredState(desiredState, isOpenLoop, - driveMotorFeedforward.calculateWithVelocities(curVelocity.in(MetersPerSecond), - nextVelocity.in(MetersPerSecond))); + driveMotorFeedforward.calculateWithVelocities(curVelocityMetersPerSecond, + nextVelocityMetersPerSecond)); } /** @@ -501,7 +501,7 @@ public void setDesiredState(SwerveModuleState desiredState, boolean isOpenLoop, * @param desiredState Desired {@link SwerveModuleState} to use. * @return Cosine compensated velocity in meters/second. */ - private LinearVelocity getCosineCompensatedVelocity(SwerveModuleState desiredState) + private double getCosineCompensatedVelocity(SwerveModuleState desiredState) { double cosineScalar = 1.0; // Taken from the CTRE SwerveModule class. @@ -519,7 +519,7 @@ private LinearVelocity getCosineCompensatedVelocity(SwerveModuleState desiredSta cosineScalar = 1; } - return MetersPerSecond.of(desiredState.speedMetersPerSecond).times(cosineScalar); + return desiredState.speedMetersPerSecond * cosineScalar; } /** @@ -768,8 +768,8 @@ public LinearVelocity getMaxVelocity() { maxDriveVelocity = InchesPerSecond.of( (driveMotor.getSimMotor().freeSpeedRadPerSec / - configuration.conversionFactors.drive.gearRatio) * - configuration.conversionFactors.drive.diameter / 2.0); + configuration.conversionFactors.drive.gearRatio) * + configuration.conversionFactors.drive.diameter / 2.0); } return maxDriveVelocity; }