-
Notifications
You must be signed in to change notification settings - Fork 666
[wpilib] Add unit-aware constructor overloads to physics sim classes #8198
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
base: main
Are you sure you want to change the base?
Conversation
/format |
I'm not a fan of this. We have too many constructor overloads as it is. |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess you could also overload getVelocityRadPerSec()
and getCurrentDrawAmps()
.
wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/ElevatorSim.java
Outdated
Show resolved
Hide resolved
That's what I initially thought too, but the non-unit constructor overloads will get replaced in 2027 anyways. |
…rSim.java Co-authored-by: Dan Katzuv <[email protected]>
Who said so? |
I'm assuming that in 2027 all of the non-units interop will be replaced since the GC overhead is no longer as big of a deal |
It's definetely been discussed for that reason, but due to 2027 needing to support FTC students there's also concern about requiring units everywhere raising the barrier to entry. |
GC overhead is one factor, but not the only reason. WPILib discussed this topic internally before, and we concluded that we'd keep the double overloads around on the 2027 branch because the Java units library isn't as straightforward to use as the double API for inexperienced users. WPILib C++ has only unit overloads because implicit conversions, operator overloading, and user-defined literals make the C++ units APIs look almost identical to the double APIs but with added unit type safety. It's more ergonomic and less verbose than the Java units library. Here's docs pages for comparison: https://docs.wpilib.org/en/stable/docs/software/basic-programming/cpp-units.html |
No description provided.