Package frc.robot.subsystems.vision
Class Vision
java.lang.Object
frc.robot.subsystems.vision.Vision
- All Implemented Interfaces:
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classCamera identities, mount poses (translation in metres, rotation in degrees), and fusion covariance.classA pose estimate bundled with the timestamp and std-devs thatSwerveDrivePoseEstimator.addVisionMeasurement()expects. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionBlinks every camera's LEDs while the command runs, then turns them off.MegaTag1 pose, orPose2d.kZerowithout a usable estimate.MegaTag2 pose, orPose2d.kZerowithout a usable estimate.Camera with the highest tag count plus target size, or the back one when nothing is in view.MegaTag1 pose, orPose2d.kZerowithout a usable estimate.MegaTag2 pose, orPose2d.kZerowithout a usable estimate.getName()MegaTag1 pose, orPose2d.kZerowithout a usable estimate.MegaTag2 pose, orPose2d.kZerowithout a usable estimate.static AprilTagFieldLayoutbooleanvoidvoidperiodic()Called by the scheduler every loop, so everything here has to stay cheap.voidResets the pose from the best camera, taking its MT2 translation and MT1 heading.booleanresetPoseToVision(boolean targetInView, Pose3d botpose3D, Pose2d megaPose, double poseTimestamp) Snaps the pose estimator onto a specific vision pose.voidsetLimelightPipelines(int pipeline) Holds every camera's LEDs on while the command runs, then turns them off.booleanTrue if any camera's primary target is a scoring tag for the current alliance, treating an unknown alliance as blue.voidAsks every camera to rewind-capture 165 s, the longest buffer the Limelight keeps.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface edu.wpi.first.wpilibj2.command.Subsystem
defer, getCurrentCommand, getDefaultCommand, idle, register, removeDefaultCommand, run, runEnd, runOnce, setDefaultCommand, simulationPeriodic, startEnd, startRun
-
Field Details
-
backLL
-
leftLL
-
rightLL
-
allLimelights
-
-
Constructor Details
-
Vision
-
-
Method Details
-
getName
-
periodic
public void periodic()Called by the scheduler every loop, so everything here has to stay cheap. -
logTelemetry
public void logTelemetry() -
getBackMegaTag1Pose
MegaTag1 pose, orPose2d.kZerowithout a usable estimate. -
getLeftMegaTag1Pose
MegaTag1 pose, orPose2d.kZerowithout a usable estimate. -
getRightMegaTag1Pose
MegaTag1 pose, orPose2d.kZerowithout a usable estimate. -
getBackMegaTag2Pose
MegaTag2 pose, orPose2d.kZerowithout a usable estimate. -
getLeftMegaTag2Pose
MegaTag2 pose, orPose2d.kZerowithout a usable estimate. -
getRightMegaTag2Pose
MegaTag2 pose, orPose2d.kZerowithout a usable estimate. -
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 headingmegaPose- the MT2 pose, which supplies the translation- Returns:
trueif the reset was applied
-
setLimelightPipelines
public void setLimelightPipelines(int pipeline) -
blinkLimelights
Blinks every camera's LEDs while the command runs, then turns them off. -
solidLimelight
Holds every camera's LEDs on while the command runs, then turns them off. -
getBackLL
-
getLeftLL
-
getRightLL
-
getTagLayout
-