Skip to content

Commit

Permalink
Removed unnecessary units.
Browse files Browse the repository at this point in the history
Signed-off-by: thenetworkgrinch <thenetworkgrinch@users.noreply.github.com>
  • Loading branch information
thenetworkgrinch committed Jan 10, 2025
1 parent 7fd1702 commit f3f59ca
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/main/java/swervelib/SwerveModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

/**
Expand Down Expand Up @@ -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.
Expand All @@ -519,7 +519,7 @@ private LinearVelocity getCosineCompensatedVelocity(SwerveModuleState desiredSta
cosineScalar = 1;
}

return MetersPerSecond.of(desiredState.speedMetersPerSecond).times(cosineScalar);
return desiredState.speedMetersPerSecond * cosineScalar;
}

/**
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit f3f59ca

Please sign in to comment.