mirror of
https://github.com/BroncBotz3481/YAGSL
synced 2026-06-19 06:21:40 +00:00
Updated 2024.4.8.1
This commit is contained in:
@@ -248,6 +248,14 @@ public class SwerveModule
|
|||||||
public void setDesiredState(SwerveModuleState desiredState, boolean isOpenLoop, boolean force)
|
public void setDesiredState(SwerveModuleState desiredState, boolean isOpenLoop, boolean force)
|
||||||
{
|
{
|
||||||
desiredState = SwerveModuleState.optimize(desiredState, Rotation2d.fromDegrees(getAbsolutePosition()));
|
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.
|
// Cosine compensation.
|
||||||
double velocity = configuration.useCosineCompensator
|
double velocity = configuration.useCosineCompensator
|
||||||
? getCosineCompensatedVelocity(desiredState)
|
? getCosineCompensatedVelocity(desiredState)
|
||||||
@@ -263,13 +271,6 @@ public class SwerveModule
|
|||||||
desiredState.speedMetersPerSecond = velocity;
|
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.
|
// 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.
|
// Synchronize encoders if queued and send in the current position as the value from the absolute encoder.
|
||||||
if (absoluteEncoder != null && synchronizeEncoderQueued)
|
if (absoluteEncoder != null && synchronizeEncoderQueued)
|
||||||
|
|||||||
Reference in New Issue
Block a user