How to program DutyCycleEncoder Swerve in 2025?

We’re trying to figure out how to migrate the new wpilibj DutyCycleEncoder class from 2024 to 2025. The changelog shows a breaking change, but doesn’t provide any specifics about how to proceed. And FRC’s current documentation of encoders is not updated to 2025, as it is still referencing 2024’s DutyCycleEncoder API.

Specifically, we were relying getDistance() and getAbsolutePosition(), but those have been removed from the API. Thanks for any help.

get() is the replacement for both of those. The only difference between getDistance() and getAbsolutePosition() last year was zeroing and rollovers. Rollovers were completely broken, so got removed. That leaves only the zero position as the difference, which for most cases in swerve wasn’t needed. So just get() is what to replace both of those with.

If you do actually need the raw absolute position, construct a DutyCycle, and then use that to construct the DutyCycleEncoder. From the DutyCycle class, you can get the raw output.

Basically, last year getDistance() was fundamentally broken, and likely caused a lot of weird issues for teams. So it had to be removed as it was the cause of way too many bug reports.