Reject Limelight vision frames relying on far AprilTags - #45
Reject Limelight vision frames relying on far AprilTags#45YehudaRothstein wants to merge 1 commit into
Conversation
Vision pose updates now ignore any frame that contains an AprilTag farther than MAX_VISION_TAG_DISTANCE_METERS (5 m). Because the MegaTag estimate fuses every visible tag into one pose, a single distant, noisy tag degrades the whole result, so such frames are dropped entirely in Swerve.periodic() before addVisionMeasurement. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TQtWGoST1ZmacrRjafx2RV
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds a ChangesVision Tag Distance Filter
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR tightens Limelight (MegaTag1) vision integration in Swerve.periodic() by rejecting pose-estimate frames that include any AprilTag beyond a configurable distance threshold, preventing distant/noisy tags from degrading fused pose updates.
Changes:
- Added
MAX_VISION_TAG_DISTANCE_METERS(default5.0) as a tunable vision cutoff inConstants.SwerveConstants. - Added
allTagsWithinRange(...)gating inSwerve.periodic()so a frame is only accepted when everyrawFiducial.distToCamerais within the threshold.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/main/java/frc/robot/Constants.java | Introduces a single tunable constant to define the maximum acceptable AprilTag distance for vision pose frames. |
| src/main/java/frc/excalib/swerve/Swerve.java | Filters Limelight pose updates by rejecting frames containing any AprilTag farther than the configured threshold before fusing into odometry. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Vision pose updates now ignore any frame that includes an AprilTag farther than 5 m from the turret Limelight, so far/noisy tags no longer pull the robot pose.
Why
Swerve.periodic()usesgetBotPoseEstimate_wpiBlue(MegaTag1), which fuses every visible tag into a single pose. A single distant tag is noisy and degrades the whole estimate. Rather than averaging it in, we drop the entire frame when any contributing tag is out of range.Changes
Constants.SwerveConstants.MAX_VISION_TAG_DISTANCE_METERS = 5.0— new, tunable threshold.Swerve.periodic()— added anallTagsWithinRange(...)gate to the existingvisionReliablecondition. The frame is accepted only if allrawFiducialshavedistToCamera <= 5 m(in addition to the existing tag-count, motion, and ambiguity checks).Notes
distToCamera; to change the cutoff, edit the one constant.addVisionMeasurementstd devs with distance) was considered; this PR uses the hard cutoff as requested. Easy to switch later if smoother boundary behavior is wanted.Testing
./gradlew compileJavapasses.🤖 Generated with Claude Code
Generated by Claude Code
Summary by CodeRabbit