Skip to content

Commit

Permalink
Fixed undefined getter/setter for PWMDutyCycleEncoderSwerve
Browse files Browse the repository at this point in the history
Signed-off-by: thenetworkgrinch <thenetworkgrinch@users.noreply.github.com>
  • Loading branch information
thenetworkgrinch committed Jun 12, 2024
1 parent d0f7ae7 commit b100007
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/main/java/swervelib/encoders/PWMDutyCycleEncoderSwerve.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit b100007

Please sign in to comment.