Update add function

This commit is contained in:
thenetworkgrinch
2023-03-30 23:28:07 -05:00
parent 3a65fdfc24
commit b1689f3ec2
112 changed files with 291 additions and 247 deletions

View File

@@ -174,6 +174,9 @@ public class SwerveModule
{
// Prevents module rotation if speed is less than 1%
SwerveMath.antiJitter(desiredState, lastState, configuration.maxSpeed);
} else
{
desiredState.omegaRadPerSecond = 0;
}
if (SwerveDriveTelemetry.verbosity == TelemetryVerbosity.HIGH)
@@ -190,18 +193,20 @@ public class SwerveModule
if (desiredState.angle != lastState.angle || synchronizeEncoderQueued)
{
// Synchronize encoders if queued and send in the current position as the value from the absolute encoder.
double feedforward = Math.toDegrees(desiredState.omegaRadPerSecond) * configuration.angleKV;
System.out.println((float) (Math.toDegrees(0) * configuration.angleKV));
if (absoluteEncoder != null && synchronizeEncoderQueued)
{
double absoluteEncoderPosition = getAbsolutePosition();
angleMotor.setPosition(absoluteEncoderPosition);
angleMotor.setReference(desiredState.angle.getDegrees(),
Math.toDegrees(desiredState.omegaRadPerSecond) * configuration.angleKV,
feedforward,
absoluteEncoderPosition);
synchronizeEncoderQueued = false;
} else
{
angleMotor.setReference(desiredState.angle.getDegrees(),
Math.toDegrees(desiredState.omegaRadPerSecond) * configuration.angleKV);
feedforward);
}
}
lastState = desiredState;