Added overrides for canandcoder, falcon/talonfx for encoder pulse per rotation configuration option.

This commit is contained in:
thenetworkgrinch
2023-08-09 16:20:15 -05:00
parent f88fdfb6cf
commit de4e35db62
3 changed files with 30 additions and 3 deletions

View File

@@ -68,6 +68,14 @@ public class ModuleJson
SwerveMotor angleMotor = angle.createMotor(false);
SwerveAbsoluteEncoder absEncoder = encoder.createEncoder(angleMotor);
// Override angle encoder pulse per rotation based on the encoder and motor type.
int encoderPulseOverride = encoder.getPulsePerRotation(physicalCharacteristics.angleEncoderPulsePerRotation);
int motorPulseOverride = angle.getPulsePerRotation(physicalCharacteristics.angleEncoderPulsePerRotation);
int angleEncoderPulsePerRotation =
motorPulseOverride != physicalCharacteristics.angleEncoderPulsePerRotation ? motorPulseOverride
: encoderPulseOverride;
// If the absolute encoder is attached.
if (absEncoder == null)
{
@@ -89,7 +97,7 @@ public class ModuleJson
absoluteEncoderInverted,
inverted.drive,
inverted.angle,
angleEncoderPulsePerRevolution == 0 ? physicalCharacteristics.angleEncoderPulsePerRotation
angleEncoderPulsePerRevolution == 0 ? angleEncoderPulsePerRotation
: angleEncoderPulsePerRevolution,
name.replaceAll("\\.json", ""));
}