Class Vision

java.lang.Object
frc.robot.subsystems.vision.Vision
All Implemented Interfaces:
Subsystem

public class Vision extends Object implements Subsystem
Fuses the three Limelights (back, left, right) into the swerve pose estimator.

Only the camera with the best view feeds the estimator. While disabled both MegaTag1 and MegaTag2 estimates are fused to pre-seed the pose; while enabled only MegaTag1 is.

  • Field Details

  • Constructor Details

  • Method Details

    • getName

      public String getName()
      Specified by:
      getName in interface Subsystem
    • periodic

      public void periodic()
      Called by the scheduler every loop, so everything here has to stay cheap.
      Specified by:
      periodic in interface Subsystem
    • logTelemetry

      public void logTelemetry()
    • getBackMegaTag1Pose

      public Pose2d getBackMegaTag1Pose()
      MegaTag1 pose, or Pose2d.kZero without a usable estimate.
    • getLeftMegaTag1Pose

      public Pose2d getLeftMegaTag1Pose()
      MegaTag1 pose, or Pose2d.kZero without a usable estimate.
    • getRightMegaTag1Pose

      public Pose2d getRightMegaTag1Pose()
      MegaTag1 pose, or Pose2d.kZero without a usable estimate.
    • getBackMegaTag2Pose

      public Pose2d getBackMegaTag2Pose()
      MegaTag2 pose, or Pose2d.kZero without a usable estimate.
    • getLeftMegaTag2Pose

      public Pose2d getLeftMegaTag2Pose()
      MegaTag2 pose, or Pose2d.kZero without a usable estimate.
    • getRightMegaTag2Pose

      public Pose2d getRightMegaTag2Pose()
      MegaTag2 pose, or Pose2d.kZero without a usable estimate.
    • getBestLimelight

      public Limelight getBestLimelight()
      Camera with the highest tag count plus target size, or the back one when nothing is in view.
    • hasAccuratePose

      public boolean hasAccuratePose()
    • tagsInView

      public boolean tagsInView()
      True if any camera's primary target is a scoring tag for the current alliance, treating an unknown alliance as blue.
    • triggerRewindCaptureForAllCameras

      public void triggerRewindCaptureForAllCameras()
      Asks every camera to rewind-capture 165 s, the longest buffer the Limelight keeps.
    • resetPoseToVision

      public void resetPoseToVision()
      Resets the pose from the best camera, taking its MT2 translation and MT1 heading. A rejected pose leaves the estimator untouched, and this overload gives the caller no way to tell.
    • resetPoseToVision

      public boolean resetPoseToVision(boolean targetInView, Pose3d botpose3D, Pose2d megaPose, double poseTimestamp)
      Snaps the pose estimator onto a specific vision pose. The covariance is tiny, so the estimator jumps to vision instead of blending toward it.

      Rejects on:

      • No target in view.
      • Either pose outside the field.
      • Camera height |z| > 0.25 m, which means a floating robot or a bad solve.
      • Roll or pitch > 5°, which means the camera was bumped.
      Parameters:
      botpose3D - the MT1 pose, which supplies the heading
      megaPose - the MT2 pose, which supplies the translation
      Returns:
      true if the reset was applied
    • setLimelightPipelines

      public void setLimelightPipelines(int pipeline)
    • blinkLimelights

      public Command blinkLimelights()
      Blinks every camera's LEDs while the command runs, then turns them off.
    • solidLimelight

      public Command solidLimelight()
      Holds every camera's LEDs on while the command runs, then turns them off.
    • getBackLL

      public Limelight getBackLL()
    • getLeftLL

      public Limelight getLeftLL()
    • getRightLL

      public Limelight getRightLL()
    • getTagLayout

      public static AprilTagFieldLayout getTagLayout()