From b100007bd69d56af918a3740773f6c0f33a4a4fd Mon Sep 17 00:00:00 2001 From: T Grinch <10247070+thenetworkgrinch@users.noreply.github.com> Date: Wed, 12 Jun 2024 16:16:27 -0500 Subject: [PATCH] Fixed undefined getter/setter for PWMDutyCycleEncoderSwerve Signed-off-by: thenetworkgrinch --- .../encoders/PWMDutyCycleEncoderSwerve.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/main/java/swervelib/encoders/PWMDutyCycleEncoderSwerve.java b/src/main/java/swervelib/encoders/PWMDutyCycleEncoderSwerve.java index 24e15d66..1b8bb6b8 100644 --- a/src/main/java/swervelib/encoders/PWMDutyCycleEncoderSwerve.java +++ b/src/main/java/swervelib/encoders/PWMDutyCycleEncoderSwerve.java @@ -26,6 +26,10 @@ public class PWMDutyCycleEncoderSwerve extends SwerveAbsoluteEncoder * An {@link Alert} for if the encoder cannot report accurate velocities. */ private Alert inaccurateVelocities; + /** + * The Offset in degrees of the PWM absolute encoder. + */ + private double offset; /** * Constructor for the PWM duty cycle encoder. @@ -61,7 +65,7 @@ public void configure(boolean inverted) @Override public double getAbsolutePosition() { - return (isInverted ? -1.0 : 1.0) * encoder.getAbsolutePosition() * 360; + return (isInverted ? -1.0 : 1.0) * ((encoder.get() * 360) - offset); } /** @@ -105,16 +109,11 @@ public void clearStickyFaults() // Do nothing } - /** - * Sets the offset of the Encoder in the WPILib Encoder Library. - * - * @param offset the offset the Absolute Encoder uses as the zero point. - * @return Always true due to no external device commands. - */ + @Override public boolean setAbsoluteEncoderOffset(double offset) { - encoder.setPositionOffset(offset); + this.offset = offset; return true; }