Class Limelight
Every getter is safe on a detached camera (isAttached() is false) and returns zero,
false, or an empty value.
Getters share one NetworkTables sample per robot loop. The first getter to need a topic reads
it, and every later getter in that loop reuses the sample, so pose, tag count, fiducials, and
timestamp all describe the same camera frame. The owning subsystem calls invalidate()
once per loop before any getter. Returned LimelightHelpers.PoseEstimate and LimelightHelpers.RawFiducial objects
belong to that sample and must not be mutated.
MegaTag1 solves pose from the tags alone. MegaTag2 fuses in the heading the owning subsystem
passes to setRobotOrientation(double).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classNetwork-table name and mounting position for one camera. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidSame asgetName().doubledoubleDistance to the closest tag, from the X and Z axes of the camera-in-tag-space pose.doublegetDistanceToTarget(double targetHeight) Distance to a target at a known height, from the camera's height above the floor and the camera's pitch plus the reported vertical offset.doubleHorizontal offset from the crosshair to the target, in degrees.doubleSeconds from the last estimate's capture time to now, or NaN if this camera produced none this loop.Full MegaTag1 estimate, including timestamp, tag count, and raw fiducials, in the WPILib Blue origin frame.doubleTimestamp of the MegaTag1 pose estimate, in seconds.Full heading-fused MegaTag2 estimate, including timestamp and tag count, in the WPILib Blue origin frame.doubleTimestamp of the MegaTag2 pose estimate, in seconds.getName()Raw fiducials from the MegaTag1 estimate, or an empty array when there is no estimate.doubledoubleZ-axis rotation of the primary target in robot space, in degrees.doublegetTagTA()Area of the primary target as a percentage of the camera image.doublegetTagTx()X offset of the primary target in robot space, in metres along the robot's left/right axis.doubleArea of the primary target as a percentage of the camera image (0-100).doubleVertical offset from the crosshair to the target, in degrees.booleanNeeds more than one tag and a target area above 0.1 percent of the frame.voidDrops the per-loop snapshot so the next getter re-reads the camera.booleanbooleanTrue when the raw MT1 sample is long enough to hold a pose.booleanWritten by the owning subsystem as it accepts or rejects each estimate.booleanWhether the pose estimator is currently fusing a measurement from this camera.booleanvoidvoidWrites the configured mount offsets (Limelight.LimelightConfig.withTranslation(double, double, double)andLimelight.LimelightConfig.withRotation(double, double, double)) to the camera, so the code is the source of truth instead of the values typed into the web UI.voidsendInvalidStatus(String message) Marks this camera as not integrating and records why.voidsendValidStatus(String message) Marks this camera as integrating and records why.voidsetIMUmode(int mode) voidsetIntegratedThisLoop(boolean integratedThisLoop) Written by the owning subsystem as it accepts or rejects each estimate.voidsetIntegrating(boolean isIntegrating) Whether the pose estimator is currently fusing a measurement from this camera.voidsetLastEstimateAgeSeconds(double lastEstimateAgeSeconds) Seconds from the last estimate's capture time to now, or NaN if this camera produced none this loop.voidsetLEDMode(boolean enabled) voidsetLimelightPipeline(int pipelineIndex) Activates a pipeline by index; the indexes come from the robot's vision configuration.voidsetLogStatus(String logStatus) voidsetRobotOrientation(double degrees) Sets the robot heading the camera's internal IMU fuses, in degrees.voidsetRobotOrientation(double degrees, double angularRate) Sets the heading and yaw rate the camera's internal IMU fuses, for MegaTag2.voidsetTagStatus(String tagStatus) booleanvoidupdateCameraPose(Pose3d pose)
-
Constructor Details
-
Limelight
-
Limelight
-
Limelight
-
Limelight
- Parameters:
pipeline- index to activate; the indexes come from the robot's vision configuration
-
Limelight
- Parameters:
pipeline- index to activate; the indexes come from the robot's vision configuration
-
-
Method Details
-
invalidate
public void invalidate()Drops the per-loop snapshot so the next getter re-reads the camera.The owning subsystem calls this once per loop before any getter (see
Vision.periodic()). Safe on a detached camera. -
getName
-
getCameraName
Same asgetName(). -
isAttached
public boolean isAttached() -
getHorizontalOffset
public double getHorizontalOffset()Horizontal offset from the crosshair to the target, in degrees. LL1 spans -27 to 27, LL2 -29.8 to 29.8. -
getVerticalOffset
public double getVerticalOffset()Vertical offset from the crosshair to the target, in degrees. LL1 spans -20.5 to 20.5, LL2 -24.85 to 24.85. -
targetInView
public boolean targetInView() -
multipleTagsInView
public boolean multipleTagsInView() -
getTagCountInView
public double getTagCountInView() -
getClosestTagID
public double getClosestTagID() -
getTargetSize
public double getTargetSize()Area of the primary target as a percentage of the camera image (0-100). -
getMegaTag1_Pose3d
-
getMegaTag2_Pose2d
-
getMegaTag1_PoseEstimate
Full MegaTag1 estimate, including timestamp, tag count, and raw fiducials, in the WPILib Blue origin frame. -
getMegaTag2_PoseEstimate
Full heading-fused MegaTag2 estimate, including timestamp and tag count, in the WPILib Blue origin frame. -
hasAccuratePose
public boolean hasAccuratePose()Needs more than one tag and a target area above 0.1 percent of the frame. -
getDistanceToTagFromCamera
public double getDistanceToTagFromCamera()Distance to the closest tag, from the X and Z axes of the camera-in-tag-space pose. -
getRawFiducial
Raw fiducials from the MegaTag1 estimate, or an empty array when there is no estimate. -
getMegaTag1PoseTimestamp
public double getMegaTag1PoseTimestamp()Timestamp of the MegaTag1 pose estimate, in seconds. -
getMegaTag2PoseTimestamp
public double getMegaTag2PoseTimestamp()Timestamp of the MegaTag2 pose estimate, in seconds. -
getDistanceToTarget
public double getDistanceToTarget(double targetHeight) Distance to a target at a known height, from the camera's height above the floor and the camera's pitch plus the reported vertical offset.- Parameters:
targetHeight- height of the target above the floor, in metres
-
sendValidStatus
Marks this camera as integrating and records why.- Parameters:
message- status text the caller wants on the dashboard
-
sendInvalidStatus
Marks this camera as not integrating and records why.- Parameters:
message- status text the caller wants on the dashboard
-
setLimelightPipeline
public void setLimelightPipeline(int pipelineIndex) Activates a pipeline by index; the indexes come from the robot's vision configuration. -
setRobotOrientation
public void setRobotOrientation(double degrees) Sets the robot heading the camera's internal IMU fuses, in degrees.Does not flush NetworkTables. The owning subsystem flushes once after all per-loop writes.
-
updateCameraPose
-
pushConfiguredCameraPose
public void pushConfiguredCameraPose()Writes the configured mount offsets (Limelight.LimelightConfig.withTranslation(double, double, double)andLimelight.LimelightConfig.withRotation(double, double, double)) to the camera, so the code is the source of truth instead of the values typed into the web UI. The six values cross in the order and sign the camera wants, so a config value can be read straight against the matching web UI box.A camera keeps its own copy in flash and falls back to it on boot, so this has to run again periodically: one that reboots mid-match reverts to whatever was last typed into it. See the resend loop in
Vision.periodic(). Does not flush NetworkTables. -
setRobotOrientation
public void setRobotOrientation(double degrees, double angularRate) Sets the heading and yaw rate the camera's internal IMU fuses, for MegaTag2.Does not flush NetworkTables. The owning subsystem flushes once after all per-loop writes.
- Parameters:
degrees- robot heading in degrees, positive counter-clockwiseangularRate- current yaw rate in degrees per second
-
setIMUmode
public void setIMUmode(int mode) - Parameters:
mode- IMU mode index; valid values are in the Limelight documentation
-
getTagTx
public double getTagTx()X offset of the primary target in robot space, in metres along the robot's left/right axis. Returns -99999 when no target is in view. -
getTagTA
public double getTagTA()Area of the primary target as a percentage of the camera image. Returns -99999 when no target is in view. -
getTagRotationDegrees
public double getTagRotationDegrees()Z-axis rotation of the primary target in robot space, in degrees. Returns -99999 when no target is in view. -
setLEDMode
public void setLEDMode(boolean enabled) -
blinkLEDs
public void blinkLEDs() -
isCameraConnected
public boolean isCameraConnected()True when the raw MT1 sample is long enough to hold a pose. -
printDebug
public void printDebug() -
isIntegrating
public boolean isIntegrating()Whether the pose estimator is currently fusing a measurement from this camera. -
setIntegrating
public void setIntegrating(boolean isIntegrating) Whether the pose estimator is currently fusing a measurement from this camera. -
getLogStatus
-
setLogStatus
-
getTagStatus
-
setTagStatus
-
isIntegratedThisLoop
public boolean isIntegratedThisLoop()Written by the owning subsystem as it accepts or rejects each estimate. -
setIntegratedThisLoop
public void setIntegratedThisLoop(boolean integratedThisLoop) Written by the owning subsystem as it accepts or rejects each estimate. -
getLastEstimateAgeSeconds
public double getLastEstimateAgeSeconds()Seconds from the last estimate's capture time to now, or NaN if this camera produced none this loop. A large value means the camera's timestamps are not trustworthy. -
setLastEstimateAgeSeconds
public void setLastEstimateAgeSeconds(double lastEstimateAgeSeconds) Seconds from the last estimate's capture time to now, or NaN if this camera produced none this loop. A large value means the camera's timestamps are not trustworthy.
-