Skip to content

Conversation

@calcmogul
Copy link
Member

@calcmogul calcmogul commented Sep 20, 2025

The wrapper includes reverse mode autodiff, the Problem DSL, and the optimal control problem API. I wrote it by directly translating the upstream API and tests to Java (i.e., copy-paste-modify).

I replaced the ArmFeedforward and Ellipse2d JNIs with implementations using the Sleipnir Java bindings. Switching dev binary JNIs to release by default sped up wpimath test runs from several minutes to 7 seconds.

@github-actions github-actions bot added the component: wpimath Math library label Sep 20, 2025
@calcmogul calcmogul force-pushed the wpimath-add-sleipnir-java-bindings branch 29 times, most recently from 7e667cd to 9749bdc Compare September 22, 2025 04:37
Copy link
Contributor

@KangarooKoala KangarooKoala left a comment

Choose a reason for hiding this comment

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

Still haven't gotten to the tests, but the source looks pretty good.

Copy link
Contributor

Choose a reason for hiding this comment

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

Given the size of this PR, it'd be nice if the sleipnir update had it's own PR so that its changes wouldn't be buried.

Copy link
Member Author

@calcmogul calcmogul Oct 9, 2025

Choose a reason for hiding this comment

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

Yea, I was mainly bumping it here to keep it in sync with upstream bugfixes. I'll make a separate PR once review is done and the bugfixes slow down.

@calcmogul calcmogul force-pushed the wpimath-add-sleipnir-java-bindings branch 5 times, most recently from 437d2e1 to ef56a07 Compare October 13, 2025 20:03
Copy link
Contributor

@KangarooKoala KangarooKoala left a comment

Choose a reason for hiding this comment

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

Still reviewing the other tests, but submitting some initial comments now so that those can get addressed.

On another note, the tests leak every single Variable (including intermediates) since they are never closed. Unfortunately, I don't think we can really do anything about that (at least, not on the test side).

@calcmogul calcmogul force-pushed the wpimath-add-sleipnir-java-bindings branch from ef56a07 to d771285 Compare October 14, 2025 18:34
@calcmogul
Copy link
Member Author

calcmogul commented Oct 14, 2025

Yea... I was hoping the GC called close(), but it seems not. In any case, manually closing them or using try-with-resources with all of them is too onerous. Java deprecated and removed finalizers in favor of try-with-resource and cleaners, but idk if cleaners are much better.

@calcmogul calcmogul force-pushed the wpimath-add-sleipnir-java-bindings branch from d771285 to b046228 Compare October 14, 2025 19:40
@calcmogul calcmogul changed the base branch from main to 2027 October 17, 2025 06:29
@calcmogul calcmogul force-pushed the wpimath-add-sleipnir-java-bindings branch from b046228 to bc2b157 Compare October 17, 2025 06:29
@github-actions github-actions bot added the 2027 2027 target label Oct 17, 2025
@calcmogul calcmogul force-pushed the wpimath-add-sleipnir-java-bindings branch 4 times, most recently from 51fec82 to cc8b7a9 Compare October 17, 2025 22:59
@calcmogul calcmogul linked an issue Oct 22, 2025 that may be closed by this pull request
Copy link
Contributor

@KangarooKoala KangarooKoala left a comment

Choose a reason for hiding this comment

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

Done reviewing everything now (though a few parts were more verifying that it matched the original Sleipnir, not necessarily verifying correctness).

@calcmogul calcmogul force-pushed the wpimath-add-sleipnir-java-bindings branch from 8b5e065 to 0f442e5 Compare October 23, 2025 00:29
Copy link
Contributor

@KangarooKoala KangarooKoala left a comment

Choose a reason for hiding this comment

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

Seems fine to me for what it's worth, except some lingering concerns about the difference in accuracy of FlywheelOCP.

@calcmogul calcmogul force-pushed the wpimath-add-sleipnir-java-bindings branch 2 times, most recently from 5ba0fc9 to 41e3f36 Compare October 24, 2025 01:25
@calcmogul calcmogul force-pushed the wpimath-add-sleipnir-java-bindings branch 3 times, most recently from 681ee08 to adfab84 Compare October 27, 2025 20:12
Copy link
Contributor

@KangarooKoala KangarooKoala left a comment

Choose a reason for hiding this comment

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

Now that the FlywheelOCP stuff is sorted out, seems fine to me for what it's worth.

@calcmogul calcmogul force-pushed the wpimath-add-sleipnir-java-bindings branch from adfab84 to 5c2e6d0 Compare October 29, 2025 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2027 2027 target component: wpimath Math library component: wpiutil WPI utility library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Java wrapper for Sleipnir

2 participants