Generic Vision Subsystem Refactor#296
Draft
Spybh66 wants to merge 6 commits into
Draft
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the vision stack to use a standardized VisionIO.CameraResult pipeline, moving vendor/wire-format decoding into the IO layer (PhotonVision structs, C2 flatbuffers) and simplifying VisionSubsystem to consume a common result type.
Changes:
- Introduces standardized vision result records (
TagObservation,MultiTagObservation,CameraResult) inVisionIOand updates cameras/IO implementations to decode into them. - Refactors
AprilTagCamerato log raw frames and delegate all decoding toVisionIO#decodeResults. - Updates
VisionSubsystemto compute robot pose from standardized results and adds a field-boundary post-filter.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/main/java/frc/robot/subsystems/vision/VisionSubsystem.java | Swaps PhotonVision types for standardized CameraResult, adds pose computation and filtering logic. |
| src/main/java/frc/robot/subsystems/vision/VisionConstants.java | Updates camera construction to new AprilTagCamera signature and cleans up constants/docs. |
| src/main/java/frc/lib/util/FieldUtil.java | Adds isPoseInField(...) helper used by vision post-filtering. |
| src/main/java/frc/lib/io/vision/VisionIOPhotonVisionSim.java | Updates sim IO to pass field layout into the PhotonVision IO base class. |
| src/main/java/frc/lib/io/vision/VisionIOPhotonVision.java | Adds decoding path from packed PhotonVision bytes to standardized CameraResult (with tag-layout reconstruction). |
| src/main/java/frc/lib/io/vision/VisionIOC2.java | Adds decoding from C2 flatbuffer frames to standardized CameraResult. |
| src/main/java/frc/lib/io/vision/VisionIO.java | Defines standardized result records and decodeResults API. |
| src/main/java/frc/lib/devices/AprilTagCamera.java | Removes in-device decoding and delegates decoding to the IO implementation. |
| if (target.ambiguity() > MAX_AMBIGUITY) { | ||
| return false; | ||
| } | ||
| if (target.fieldToCameraPose().getTranslation().getNorm() > MAX_DISTANCE_METERS) { |
Comment on lines
+139
to
+143
| && getAvgDistanceMeters(result) < MAX_DISTANCE_METERS) { | ||
| return true; | ||
| } | ||
|
|
||
| return bestTarget.getPoseAmbiguity() <= MAX_AMBIGUITY; | ||
| return false; |
- Rename CameraResult.captureLatencyUs to captureTimestampUs to reflect that the field stores an absolute capture timestamp, not a latency - Fix preFilter and getAvgDistanceMeters to compute actual camera-to-tag distance (tag field pose − camera field pose) instead of the camera's distance from the field origin (fieldToCameraPose norm) - Fix preFilter multi-tag fallback: frames with multiple tag observations but no multiTagObservation were unconditionally rejected; they now fall back to the lowest-ambiguity single-tag check so usable frames aren't dropped when multi-tag solve is disabled or unavailable - Add private static cameraToTagDistance helper to encapsulate the tag-layout lookup and distance computation Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.