From a5eb6d05e984a6b6527f8104cd874da06c35c4d1 Mon Sep 17 00:00:00 2001 From: thenetworkgrinch Date: Sat, 17 Feb 2024 08:13:53 -0600 Subject: [PATCH] Updated 2024.4.8.1 --- swervelib/SwerveModule.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/swervelib/SwerveModule.java b/swervelib/SwerveModule.java index a74806e..0957211 100644 --- a/swervelib/SwerveModule.java +++ b/swervelib/SwerveModule.java @@ -248,6 +248,14 @@ public class SwerveModule public void setDesiredState(SwerveModuleState desiredState, boolean isOpenLoop, boolean force) { desiredState = SwerveModuleState.optimize(desiredState, Rotation2d.fromDegrees(getAbsolutePosition())); + + // If we are forcing the angle + if (!force) + { + // Prevents module rotation if speed is less than 1% + SwerveMath.antiJitter(desiredState, lastState, Math.min(maxSpeed, 4)); + } + // Cosine compensation. double velocity = configuration.useCosineCompensator ? getCosineCompensatedVelocity(desiredState) @@ -263,13 +271,6 @@ public class SwerveModule desiredState.speedMetersPerSecond = velocity; } - // If we are forcing the angle - if (!force) - { - // Prevents module rotation if speed is less than 1% - SwerveMath.antiJitter(desiredState, lastState, Math.min(maxSpeed, 4)); - } - // Prevent module rotation if angle is the same as the previous angle. // Synchronize encoders if queued and send in the current position as the value from the absolute encoder. if (absoluteEncoder != null && synchronizeEncoderQueued)