Skip to content

Generic Vision Subsystem Refactor#296

Draft
Spybh66 wants to merge 6 commits into
devfrom
258-generic-vision-subsystem
Draft

Generic Vision Subsystem Refactor#296
Spybh66 wants to merge 6 commits into
devfrom
258-generic-vision-subsystem

Conversation

@Spybh66

@Spybh66 Spybh66 commented May 15, 2026

Copy link
Copy Markdown
Member

No description provided.

@Spybh66 Spybh66 linked an issue May 15, 2026 that may be closed by this pull request

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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) in VisionIO and updates cameras/IO implementations to decode into them.
  • Refactors AprilTagCamera to log raw frames and delegate all decoding to VisionIO#decodeResults.
  • Updates VisionSubsystem to 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;
Comment thread src/main/java/frc/robot/subsystems/vision/VisionSubsystem.java
Comment thread src/main/java/frc/lib/io/vision/VisionIO.java
- 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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Comment thread src/main/java/frc/robot/subsystems/vision/VisionSubsystem.java
Comment thread src/main/java/frc/lib/io/vision/VisionIOPhotonVision.java
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.

Generic Vision Subsystem

2 participants