-
Notifications
You must be signed in to change notification settings - Fork 236
Make various refactors to clean up codebase #1830
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
Conversation
Do we wanna hold off until champs on this one? |
I’d be fine with that. I think there are other places I could do refactors as well. |
photon-core/src/main/java/org/photonvision/common/configuration/HardwareConfig.java
Show resolved
Hide resolved
photon-core/src/main/java/org/photonvision/vision/pipe/impl/AprilTagDetectionPipe.java
Show resolved
Hide resolved
photon-core/src/main/java/org/photonvision/vision/pipe/impl/AprilTagPoseEstimatorPipe.java
Show resolved
Hide resolved
Matt says this was for mmal, and we use libcamera now, so this is unnecessary now. Also, the filtering logic that used blacklistedResIndices was completely broken.
…efinitely never modified
a5f8e63
to
76f6528
Compare
In places like pipelines or DataSocketHandler, objects were being instantiated and assigned to a variable, but were then passed into a method, never to be used again. For pipelines especially, that style of code wasn't always consistently used, and other pipelines skipped assignment and instantiated objects in the method call. Make everything consistent by always instantiating in the method call. GenericUSBCameraSettables also had an unnecessary assignment, and that was cleaned up too for readability.
6aba6f7
to
7175275
Compare
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.
Blocking review until post champs
photonvision/photon-core/src/main/java/org/photonvision/common/configuration/ConfigManager.java Line 43 in cbdea5d
Take a peek at these guys, they don't seem to be doing anything |
Tempted to merge this as a not-squash to preserve history and make bisecting easier |
Sure. Imma put another blocking review so that we remember. |
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.
Rebase when we merge
This allowed us to drop a few Apache Commons dependencies, which is good for reducing JAR size and the number of things we need to pull in.
printTestResults was duplicated a lot, so it has been moved to TestUtils for maintainability.
QuirkyCamera was refactored to use EnumMap, since that seems to be more efficient. This also enables more concise copying of QuirkyCamera in getQuirkyCamera by just passing in the Map of the QuirkyCamera. Also, putAll was used instead of manually copying quirks in updateQuirks for conciseness.
Cleaned up history for a rebase merge so some of the commits have nice summaries and descriptions. |
FUCK IT EINSTEIN IS OVER WE BALL LETS GET THIS BREAD |
Description
Code that was unused has been removed to tidy up the codebase.
The creation of arrays was also tidied up, using initializers when possible and just
new Type[0]
for zero length arrays.Text blocks were used to increase readability.
VideoSimUtil was refactored to reduce copies when generating 36h11 tag images.
FileSaveFrameConsumer was refactored to let Java handle paths instead of us doing it manually.
I switched to WPILib's Pair class instead of the Apache Commons Pair class. This allowed us to drop a few Apache Commons dependencies, which is good for reducing JAR size and the number of things we need to pull in.
#1556 added a UiVmmState class, but it appears to have been unused, so removing it to reduce confusion.
printTestUtils
was a common function duplicated across several tests, so they were consolidated into TestUtils for maintainability.blacklistedResIndices
was removed from HardwareConfig because the filtering logic that used it was broken. Matt says it was something from the mmal days, but we use libcamera now, so we just don't need it.collect(Collectors.toList())
for Streams was replaced withtoList()
when the resulting List wasn't modified. It's more concise and possibly a little bit more performant.Math.hypot
was used in place ofMath.sqrt(a^2 + b^2)
for conciseness.Several classes were made into records to reduce boilerplate and increase readability.
In a few places, especially in pipelines, objects were being assigned to a variable, only to be passed to a method and never used again in the same scope. Worse, this wasn't consistent, and assignment was just skipped entirely sometimes. Now, the code more consistently creates the object directly in the method call, skipping the unnecessary assignment.
switch case and instanceof use was refactored to reduce unnecessary operations like casting if statements and casts and improve code clarity.
JUnit assertions were not always statically imported, so I statically imported all of them.
A Timer is now used to calculate FPS instead of handrolling the time tracking for readability and maintainability.
Whatever CameraServer bug caused #123 seems to have been fixed, so CameraServer is now used directly instead of duplicating its code.
QuirkyCamera was refactored to use EnumMap, since that seems to be more efficient. This also enables more concise copying of QuirkyCamera in
getQuirkyCamera
by just passing in the Map of the QuirkyCamera. Also,putAll
was used instead of manually copying quirks inupdateQuirks
for conciseness.There's some other miscellanous clean up in
Miscellanous clean up
, which is mostly either removing unnecessary code or making operations more efficient.Meta
Merge checklist: