Comments (4)
I love the Java units library.
One of the barriers to entry I feel is writing a method that returns a type. That type is something like acceleration. The type signature for the method is Measure<Velocity<Velocity>>>.
This is a little inelegant and people will just look away and handle units in their own way. However this seems more to be due to the limitations of Java than anything else. Adding a unit for force and torque is fine, but a method returning this type would have a signature is ridiculous.
The library itself seems to have some issues separating Dimension, Unit, and Physical quantity.
Torque and Energy are two physical quantities, they are measured with the same dimension. That dimension can be captured in a variety of named units that are also characterized by a dimension. I feel like instead of Measure it should be more Measure. Each dimension should have its own list of units. Internally a dimension can either be a base dimension (like mass or current, or time, I'm going by the SI unit definition here) or a composite dimension like Nm or J/S. Under the hood every dimension is a product of these base dimensions, quotients being negative integer powers. Nm is just Mass * Distance * Distance * Second^-1 * Second^-1.
from allwpilib.
I agree with the separation being confusing, for example the library has Power as its own sort of unit when it could be work/energy over time. Same thing with the torque units, I feel like it would be cleaner to have Torque be its own unit instead of deriving it from the other base units because it would become extremely cumbersome to define a method to take in or return some unit of torque.
from allwpilib.
So every dimension in SI is built up of integer power of base units. One can remove the unit concept entirely from the picture and think in terms of dimension
Torque and Energy are measurable things.
A measurable thing has a dimension.
Units are when we go from dimension to measurements of those measurable things.
The main dimensions are time, mass, electric current, temperature, substance and luminous intensity.
I'd argue not using the last two. I can't imagine needing moles in FRC. Luminous intensity is possible, but could be expanded up later.
from allwpilib.
The type signature for the method is Measure<Velocity>>.
You mean Measure<Velocity<Velocity<Distance>>>
?
However this seems more to be due to the limitations of Java than anything else.
Yes, Java's type system is very limiting in what we can do for units. Unlike C++, there is no ability in Java to define type aliases like using Acceleration = Velocity<Velocity<Distance>>
to simplify function signatures or the generic types in general, thus the proliferation of specific "units" that aren't really base units. The fact that generics are not reified in Java also is a limiter, so we can't just overload functions based on the generic type, or do things at runtime based on the generic type. This is compounded by the fact we do not want to use immutable values (thus the separation of Measure and MutableMeasure) due to memory allocation / GC concerns.
I feel like instead of Measure it should be more Measure.
I think something was lost here?
from allwpilib.
Related Issues (20)
- Make DriverStation error and warning reporting easier in C++ HOT 3
- Sim GUI does not disable joystick data in auto mode
- [wpimath] Remove or deprecate unused WheelPositions interface/concept HOT 4
- Provide a way to flush NetworkTables to the wire immediately HOT 8
- Question about New Radio from Vivid Hosting wireless connection HOT 4
- NetworkTables server crashes when publishers are rapidly created and closed HOT 6
- Closing NetworkTables publisher doesn't flush queued data HOT 3
- Use Jinja to generate PWM motor controller classes
- Include sendable type information in topic metadata
- [Build] Consider breaking up wpimath / geometry classes HOT 5
- Make encoder classes unit-aware
- Feedforward Javadocs use incorrect terminology
- Consider adding VirtualSubsystems? HOT 2
- Add DataLog support for logging stdout/stderr
- Add 2D addressable LED display class
- Rotation2d(0,0) should be some sort of NaN HOT 19
- Synchronize C++ and Java versions of BooleanEvent HOT 1
- Trigger.onChange has no test HOT 3
- cmake build broken as of 2024.1.1 HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from allwpilib.