Skip to content
This repository was archived by the owner on Dec 6, 2025. It is now read-only.

Commit b100007

Browse files
Fixed undefined getter/setter for PWMDutyCycleEncoderSwerve
Signed-off-by: thenetworkgrinch <[email protected]>
1 parent d0f7ae7 commit b100007

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/main/java/swervelib/encoders/PWMDutyCycleEncoderSwerve.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ public class PWMDutyCycleEncoderSwerve extends SwerveAbsoluteEncoder
2626
* An {@link Alert} for if the encoder cannot report accurate velocities.
2727
*/
2828
private Alert inaccurateVelocities;
29+
/**
30+
* The Offset in degrees of the PWM absolute encoder.
31+
*/
32+
private double offset;
2933

3034
/**
3135
* Constructor for the PWM duty cycle encoder.
@@ -61,7 +65,7 @@ public void configure(boolean inverted)
6165
@Override
6266
public double getAbsolutePosition()
6367
{
64-
return (isInverted ? -1.0 : 1.0) * encoder.getAbsolutePosition() * 360;
68+
return (isInverted ? -1.0 : 1.0) * ((encoder.get() * 360) - offset);
6569
}
6670

6771
/**
@@ -105,16 +109,11 @@ public void clearStickyFaults()
105109
// Do nothing
106110
}
107111

108-
/**
109-
* Sets the offset of the Encoder in the WPILib Encoder Library.
110-
*
111-
* @param offset the offset the Absolute Encoder uses as the zero point.
112-
* @return Always true due to no external device commands.
113-
*/
112+
114113
@Override
115114
public boolean setAbsoluteEncoderOffset(double offset)
116115
{
117-
encoder.setPositionOffset(offset);
116+
this.offset = offset;
118117

119118
return true;
120119
}

0 commit comments

Comments
 (0)