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

[wpimath] All non-deprecated SimpleMotorFeedforward calculate methods require units #7280

Open
jwbonner opened this issue Oct 23, 2024 · 11 comments
Labels

Comments

@jwbonner
Copy link
Member

I haven't been closely following all of the changes to SimpleMotorFeedforward, but it seems like the current set of calculate methods is a bit odd in Java. Here's are the current options:

  • calculate(velocity, acceleration) (non-units, deprecated)
  • calculate(velocity) (non-units, deprecated)
  • calculate(velocity) (units, non-deprecated)
  • calculate(currentVelocity, nextVelocity) (units, non-deprecated)

I understand the move from accepting acceleration values to two velocity values, but it looks like the parity between units and non-units methods was lost. It seems like there should be a calculate(currentVelocity, nextVelocity) method that doesn't use units and the calculate(velocity) method should wrap that new method and be un-deprecated (the same way that the the units version of calculate(velocity) wraps the units version of calculate(currentVelocity, nextVelocity)).

@rzblue
Copy link
Member

rzblue commented Oct 23, 2024

This is because calculate(double velocity, double acceleration) and calculate(double currentVelocity, double nextVelocity) are ambiguous, and same for the velocity-only functions. I believe the plan is to add calculate(double currentVelocity, double nextVelocity) next year to replace the double velocity, double acceleration version.

I agree that this isn't a great situation; I think we should add a note to the documentation explaining the above. I'm also concerned about silent breakage for teams that use the double functions this year, since the code would still compile with the new implementation, but the behavior would be wildly different.

@jwbonner
Copy link
Member Author

At a minimum, it seems odd that calculate(double velocity) is deprecated given that the new implementation would have the same behavior. Regardless, would the documented solution for using FF with kA for non-units be the deprecated method?

@jwbonner
Copy link
Member Author

Also, was there a reason that the new overloads weren't simply given a different name? It seems like that would have solved this issue without breaking parity between units and non-units.

@calcmogul
Copy link
Member

calcmogul commented Oct 23, 2024

Because calculate() is the ideal name. It's short and consistent with the rest of the library.

@jwbonner
Copy link
Member Author

Sure, but that leaves us in the current situation where there is literally no way to use the class without units. Unless, again, the documented solution is to use deprecated methods.

@calcmogul
Copy link
Member

calcmogul commented Oct 23, 2024

there is literally no way to use the class without units

That's intentional for those methods.

@jwbonner
Copy link
Member Author

Why? My understanding is that the plan (before 2027 at least) is to not require that teams use units. Why does no other part of WPILib do the same thing?

@calcmogul
Copy link
Member

calcmogul commented Oct 23, 2024

Because the Java feedforward functions in particular need types for disambiguation. C++ doesn't have this issue because they've always used units.

@calcmogul
Copy link
Member

calcmogul commented Oct 23, 2024

Also, using a different name means it'll take 4+ years to get back to the better name with the deprecation/removal cycles being what they are. Command-based went through this and is still stuck in a wpilibj2 namespace because it's "breakage for the sake of breakage".

@jwbonner
Copy link
Member Author

jwbonner commented Oct 23, 2024

That's fine, my point is just that there needs to be some documented solution for non-units. If that solution is using deprecated methods that's fine, in which case the Javadocs should clearly state that using the deprecated methods is intended in that situation.

And again, calculate(double velocity) doesn't have a conflict so it seems like that doesn't need to be deprecated at all.

@PeterJohnson
Copy link
Member

Re: breaking changes, we won’t have our usual deprecation cycle going into 2027. There will be (many) things in 2026 that break in 2027.

@rzblue rzblue added the component: wpimath Math library label Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants