Skip to content

Conversation

thenetworkgrinch
Copy link
Contributor

In addition to adding useful Imperial units like Miles. Useful missing time units like Hours, which is used to create RELATABLE UNITS!

Whimsical Units inspire creativity in students and let them think out of the box. Nothing in this PR is unprecedented because it is already in the C++ impl.

Discuss!

@thenetworkgrinch thenetworkgrinch changed the title Add Whimsical Units [wpiunits] Add Whimsical Units May 11, 2025
@rzblue
Copy link
Member

rzblue commented May 11, 2025

Nothing in this PR is unprecedented because it is already in the C++ impl.

The c++ units library is imported from https://github.com/nholthaus/units. Additionally, each unit type has its own header, and unit types aren't globally accessible in Intellisense.

@ThadHouse
Copy link
Member

Yeah. Our goal is not to match the c++ impl, because we didn’t write that, it was imported. We should only be adding units to Java we actually use.

@KangarooKoala
Copy link
Contributor

KangarooKoala commented May 11, 2025

Additionally, we will in all probability drop some of the units in C++ when we switch to a different units library (mp-units) for 2027.

@nobody5050
Copy link

I'm in favor of using whimsical types. Since FRC is mostly North American, it would be nice to include units like miles, if only to display robot speed in MPH, for example.

@thenetworkgrinch
Copy link
Contributor Author

We should only be adding units to Java we actually use.

Idk about you but i would love to have a virtual speedometer on my Dashboard showing my speed for the fun of it. Leagues would have been a great on-theme measurement for this year.

For any horse racing or city-planning sponsors furlongs is directly relatable!

I think by not merging this you're just making it that much harder to inspire and let programmers have fun while competing especially since FTC (middle-high schoolers) will see this and get thinking.

Additionally pollution for Units isn't a bad thing! The more Units we have the better!

@ThadHouse
Copy link
Member

Well for starters, something is wrong with this PR, because it says no files changed. So until it is actually fixed, we cannot review this.

@github-actions github-actions bot added component: wpiutil WPI utility library and removed component: wpiunits Java units library labels May 12, 2025
@github-actions github-actions bot added component: wpiunits Java units library and removed component: wpiutil WPI utility library labels May 12, 2025
@thenetworkgrinch
Copy link
Contributor Author

thenetworkgrinch commented May 12, 2025

Well for starters, something is wrong with this PR, because it says no files changed. So until it is actually fixed, we cannot review this.

Thats what happens when you have to open PR's from your phone bc you don't have a full busybox terminal setup yet to use.

Copy link
Member

@calcmogul calcmogul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I foresee the average FRC team using almost none of these.

@thenetworkgrinch
Copy link
Contributor Author

Aren't there many features few teams use anyways like meccanum drive classes? 💩

@Gold856
Copy link
Contributor

Gold856 commented May 12, 2025

For the record, Kiwi/Killough drive classes were removed because no one used them. Mecanum could be removed if usage continues to drop, but I doubt that will happen as FTC starts to use WPILib. Also, adding "useless" features because there's other features that have low use isn't really a good justification. Basically all of the features in wpimath, for example, have valid use cases, with maybe simulated annealing being one that would be the hardest to find a use case for. But otherwise, the various controllers, filters, kinematics, trajectory library, etc do have use cases. Units like Leagues and Cubits however, don't really have any use case at all. So there's not really a good reason to add arachic units like those.

I'm not opposed to adding units like Miles or Hours though. Those do have use cases, the most common likely being calculating robot velocity in miles per hour.

Also, keep in mind that even if whimsical units do inspire some students, you'd also annoy other students who use Intellisense and get annoyed that their suggestions are cluttered with units they wouldn't use. I'd probably be one of those annoyed students (I know, I'm no fun.)

@thenetworkgrinch
Copy link
Contributor Author

Speaking of which we may want to reconsider those classes since those drives are still used in FTC?

@Gold856
Copy link
Contributor

Gold856 commented May 12, 2025

To my knowledge (since I'm not a WPILib maintainer), Mecanum is not under consideration for removal.

@thenetworkgrinch
Copy link
Contributor Author

thenetworkgrinch commented May 12, 2025

Intellisense and get annoyed that their suggestions are cluttered

Intellisense works just fine even with these showing up and shows the package if you have it set to. You can also choose to import it like Units. but we all know that is ugly.

By this logic typing Command is the worst? Especially when you don't care about CommandHIDControllers. And dont even get started when you type Robot in! The horror/s!

I think you're overreacting and that its something that already has precedent. It's not something many people notice or care about (and considering it at this scope seems more pedantic than necessary).

In my opinion there are more students that care the names aren't duplicated across wpilib and common libraries in intelisense so they can auto-import with intellisense nicely.

@Gold856
Copy link
Contributor

Gold856 commented May 12, 2025

Command is not even close, Robot is even farther away. I can see all of the imports that start with Command or Robot. Units has many, many more things in Intellisense. Enough things that I have to scroll a lot to see all of them. We should try to minimize the list of units if possible, because this is noise and people will have to deal with it.

@thenetworkgrinch
Copy link
Contributor Author

Why? I usually use Units assuming a unit exists and start typing the name?

Why would you bother scrolling through all of them?

@kcooney
Copy link
Contributor

kcooney commented May 12, 2025

Agreed that adding new constants has a cost. In general, a larger API surface can make it harder to understand an API.

Suggestion: Instead of adding more constants to Units, update the class JavaDoc to say "Teams can define their own units. Below is an example of defining a constance representing distance in miles:" followed by a JavaDoc code block.

Doing this would provide a path for teams that want to add the robot's speed in MPH to a dashboard, and could allow some students to see how extensible APIs allow people to do fun things with the code that the maintainers might not have expected.

@sciencewhiz
Copy link
Contributor

Suggestion: Instead of adding more constants to Units, update the class JavaDoc to say "Teams can define their own units. Below is an example of defining a constance representing distance in miles:" followed by a JavaDoc code block.

There's documentation for defining a custom unit here: https://docs.wpilib.org/en/stable/docs/software/basic-programming/java-units.html#defining-new-units but nothing in the javadocs that I could find quickly.

@kcooney
Copy link
Contributor

kcooney commented May 13, 2025

Suggestion: Instead of adding more constants to Units, update the class JavaDoc to say "Teams can define their own units. Below is an example of defining a constance representing distance in miles:" followed by a JavaDoc code block.

There's documentation for defining a custom unit here: https://docs.wpilib.org/en/stable/docs/software/basic-programming/java-units.html#defining-new-units but nothing in the javadocs that I could find quickly.

Good to know. If someone added some example code in those docs(furlongs per fortnight, perhaps) we could add a link to there from the Units Javadoc so teams could see how easy it is to add their own units.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: wpiunits Java units library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants