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

[apriltag] AprilTagFieldLayout: Improve API shape for loading builtin JSONs #4949

Merged
merged 3 commits into from
Jan 19, 2023

Conversation

brennenputh
Copy link
Contributor

@brennenputh brennenputh commented Jan 15, 2023

C++ had a method dedicated to loading a inbuilt field from the enum, Java however was missing this. The unclear documentation on the AprilTagFieldLayout loadFromResource method led to users (read: me and my team) attempting to use it with non-internal fields. This would NPE in a non-expected way.

This PR:

  • Adds a specific method within AprilTagFields to get a AprilTagFieldLayout for the user
  • Adds some documentation to ensure that users don't mistake loadFromResource for the constructor they want.

@brennenputh brennenputh requested a review from a team as a code owner January 15, 2023 12:30
@Starlight220
Copy link
Member

Add a comment pointing to the correct method for loading official included fields

@brennenputh
Copy link
Contributor Author

Would it make sense to make m_resourceFile in AprilTagFields private since users shouldn't be using it directly now? I can't think of a usecase where m_resourceFile is going to be used outside of that one method.

@Starlight220
Copy link
Member

No reason to not have it public.

@PeterJohnson PeterJohnson changed the title Clarify documentation and improve API shape for loading inbuilt AprilTagFieldLayout JSONs [apriltag] AprilTagFieldLayout: Improve API shape for loading builtin JSONs Jan 19, 2023
@PeterJohnson PeterJohnson merged commit 3b084ec into wpilibsuite:main Jan 19, 2023
@brennenputh brennenputh deleted the fix-apriltagfieldlayout branch January 19, 2023 11:38
Starlight220 pushed a commit to Starlight220/allwpilib that referenced this pull request Mar 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants