Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make encoder classes unit-aware #6746

Open
calcmogul opened this issue Jun 16, 2024 · 5 comments
Open

Make encoder classes unit-aware #6746

calcmogul opened this issue Jun 16, 2024 · 5 comments
Labels
component: wpilibc WPILib C++ component: wpilibj WPILib Java type: feature Brand new functionality, features, pages, workflows, endpoints, etc.

Comments

@calcmogul
Copy link
Member

Is your feature request related to a problem? Please describe.
We currently have Encoder, AnalogEncoder, and DutyCycleEncoder. None of them are unit-safe.

Describe the solution you'd like
To facilitate strong unit typing, we should split them all into linear and angular versions. I mocked up an API in C++ but never finished implementing the internals.

https://github.com/calcmogul/allwpilib/tree/_ref-new-encoder-api

@calcmogul calcmogul added type: feature Brand new functionality, features, pages, workflows, endpoints, etc. component: wpilibj WPILib Java component: wpilibc WPILib C++ labels Jun 16, 2024
@Daniel1464
Copy link

For the java version, would it be a good idea to include methods for returning stuff in the java units library, or should the only return value be doubles?

@calcmogul
Copy link
Member Author

calcmogul commented Oct 5, 2024

In Java. we've been offering getters and setters for both doubles and units. It's not ideal, but the Java units library just wasn't performant enough on the roboRIO for us to not offer an escape hatch. The units library got rewritten for 2025, so maybe units-only will work out better this time?

@Daniel1464
Copy link

Sure then. I don't think the units api rewrite does anything on the performance side of things though(just adds support for more methods that weren't possible w/ java's generics system).

@calcmogul
Copy link
Member Author

calcmogul commented Oct 5, 2024

Another option is just delaying this until 2027 when we get a more powerful processor and better garbage collectors (the more modern GCs don't support ARM 32-bit).

@Daniel1464
Copy link

Thinking about it, I think that for java we can probably mimic the simulation classes' methods(getVelocityRadPerSec(), getPositionRad()) as well as a getPosition() method that returns an Angle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: wpilibc WPILib C++ component: wpilibj WPILib Java type: feature Brand new functionality, features, pages, workflows, endpoints, etc.
Projects
None yet
Development

No branches or pull requests

2 participants