Class LimelightHelpers
java.lang.Object
frc.spectrumLib.vision.LimelightHelpers
LimelightHelpers provides static methods and classes for interfacing with Limelight vision
cameras in FRC. This library supports all Limelight features including AprilTag tracking, Neural
Networks, and standard color/retroreflective tracking.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRepresents hardware statistics from the Limelight.static classEncapsulates the state of an internal Limelight IMU.static classRepresents IMU data from the JSON results.static classLimelight Results object, parsed from a Limelight's JSON results output.static classRepresents a Barcode Target Result extracted from JSON Outputstatic classRepresents a Neural Classifier Pipeline Result extracted from JSON Outputstatic classRepresents a Neural Detector Pipeline Result extracted from JSON Outputstatic classRepresents an AprilTag/Fiducial Target Result extracted from JSON Outputstatic classRepresents a Color/Retroreflective Target Result extracted from JSON Outputstatic classRepresents a 3D Pose Estimate.static classRepresents a Limelight Raw Neural Detector result from Limelight's NetworkTables output.static classRepresents a Limelight Raw Fiducial result from Limelight's NetworkTables output.static classRepresents a Limelight Raw Target/Contour result from Limelight's NetworkTables output.static classRepresents capture rewind buffer statistics. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidFlush()Flush.static double[]getBotpose(String limelightName) Deprecated.static double[]getBotPose(String limelightName) Returns the bot pose.static double[]getBotPose_TargetSpace(String limelightName) Returns the bot pose target space.static double[]getBotpose_wpiBlue(String limelightName) Deprecated.static double[]getBotPose_wpiBlue(String limelightName) Returns the bot pose wpi blue.static double[]getBotpose_wpiRed(String limelightName) Deprecated.static double[]getBotPose_wpiRed(String limelightName) Returns the bot pose wpi red.static Pose2dgetBotPose2d(String limelightName) Gets the Pose2d for easy use with Odometry vision pose estimator (addVisionMeasurement)static Pose2dgetBotPose2d_wpiBlue(String limelightName) Gets the Pose2d for easy use with Odometry vision pose estimator (addVisionMeasurement)static Pose2dgetBotPose2d_wpiRed(String limelightName) Gets the Pose2d for easy use with Odometry vision pose estimator (addVisionMeasurement)static Pose3dgetBotPose3d(String limelightName) Returns the bot pose 3d.static Pose3dgetBotPose3d_TargetSpace(String limelightName) Gets the robot's 3D pose with respect to the currently tracked target's coordinate system.static Pose3dgetBotPose3d_wpiBlue(String limelightName) (Recommended) Gets the robot's 3D pose in the WPILib Blue Alliance Coordinate System.static Pose3dgetBotPose3d_wpiRed(String limelightName) (Not Recommended) Gets the robot's 3D pose in the WPILib Red Alliance Coordinate System.getBotPoseEstimate_wpiBlue(String limelightName) Gets the MegaTag1 Pose2d and timestamp for use with WPILib pose estimator (addVisionMeasurement) in the WPILib Blue alliance coordinate system.getBotPoseEstimate_wpiBlue_MegaTag2(String limelightName) Gets the MegaTag2 Pose2d and timestamp for use with WPILib pose estimator (addVisionMeasurement) in the WPILib Blue alliance coordinate system.getBotPoseEstimate_wpiRed(String limelightName) Gets the Pose2d and timestamp for use with WPILib pose estimator (addVisionMeasurement) when you are on the RED alliancegetBotPoseEstimate_wpiRed_MegaTag2(String limelightName) Gets the Pose2d and timestamp for use with WPILib pose estimator (addVisionMeasurement) when you are on the RED alliancestatic double[]getCameraPose_TargetSpace(String limelightName) Returns the camera pose target space.static Pose3dgetCameraPose3d_RobotSpace(String limelightName) Gets the camera's 3D pose with respect to the robot's coordinate system.static Pose3dgetCameraPose3d_TargetSpace(String limelightName) Gets the camera's 3D pose with respect to the currently tracked target's coordinate system.static StringgetClassifierClass(String limelightName) Gets the current neural classifier result class name.static intgetClassifierClassIndex(String limelightName) Gets the classifier class index from the currently running neural classifier pipelinestatic double[]getCornerCoordinates(String limelightName) Gets the corner coordinates of detected targets from NetworkTables.static doublegetCurrentPipelineIndex(String limelightName) Gets the active pipeline index.static StringgetCurrentPipelineType(String limelightName) Gets the current pipeline type.static StringgetDetectorClass(String limelightName) Gets the primary neural detector result class name.static intgetDetectorClassIndex(String limelightName) Gets the detector class index from the primary result of the currently running neural detector pipeline.static doublegetFiducialID(String limelightName) Returns the fiducial id.static doublegetHeartbeat(String limelightName) Gets the Limelight heartbeat value.static LimelightHelpers.IMUDatagetIMUData(String limelightName) Gets the current IMU data from NetworkTables.static StringgetJSONDump(String limelightName) Gets the full JSON results dump.static doublegetLatency_Capture(String limelightName) Gets the capture latency.static doublegetLatency_Pipeline(String limelightName) Gets the pipeline's processing latency contribution.getLatestResults(String limelightName) Gets the latest JSON results output and returns a LimelightResults object.static DoubleArrayEntrygetLimelightDoubleArrayEntry(String tableName, String entryName) Returns the limelight double array entry.static doublegetLimelightNTDouble(String tableName, String entryName) Returns the limelight nt double.static double[]getLimelightNTDoubleArray(String tableName, String entryName) Returns the limelight nt double array.static StringgetLimelightNTString(String tableName, String entryName) Returns the limelight nt string.static String[]getLimelightNTStringArray(String tableName, String entryName) Returns the limelight nt string array.static NetworkTablegetLimelightNTTable(String tableName) Returns the limelight nt table.static NetworkTableEntrygetLimelightNTTableEntry(String tableName, String entryName) Returns the limelight nt table entry.static StringgetNeuralClassID(String limelightName) Returns the neural class id.static double[]getPythonScriptData(String limelightName) Returns the python script data.static String[]getRawBarcodeData(String limelightName) Returns the raw barcode data.static LimelightHelpers.RawDetection[]getRawDetections(String limelightName) Gets the latest raw neural detector results from NetworkTablesstatic LimelightHelpers.RawFiducial[]getRawFiducials(String limelightName) Gets the latest raw fiducial/AprilTag detection results from NetworkTables.static LimelightHelpers.RawTarget[]getRawTargets(String limelightName) Gets the raw target contours from NetworkTables.static double[]getT2DArray(String limelightName) T2D is an array that contains several targeting metricsstatic doubleGets the target area as a percentage of the image (0-100%).static double[]getTargetColor(String limelightName) Gets the average color under the crosshair region as a 3-element array.static intgetTargetCount(String limelightName) Gets the number of targets currently detected.static double[]getTargetPose_CameraSpace(String limelightName) Returns the target pose camera space.static double[]getTargetPose_RobotSpace(String limelightName) Returns the target pose robot space.static Pose3dgetTargetPose3d_CameraSpace(String limelightName) Gets the target's 3D pose with respect to the camera's coordinate system.static Pose3dgetTargetPose3d_RobotSpace(String limelightName) Gets the target's 3D pose with respect to the robot's coordinate system.static booleanDoes the Limelight have a valid target?static doubleGets the horizontal offset from the crosshair to the target in degrees.static doubleGets the horizontal offset from the principal pixel/point to the target in degrees.static doubleGets the vertical offset from the crosshair to the target in degrees.static doubleGets the vertical offset from the principal pixel/point to the target in degrees.parsePoseEstimate(double[] poseArray, long timestampMicros, boolean isMegaTag2) Parses a raw botpose array (as published onbotpose_wpiblueorbotpose_orb_wpiblue) into aLimelightHelpers.PoseEstimate.static double[]pose2dToArray(Pose2d pose) Converts a Pose2d object to an array of doubles in the format [x, y, z, roll, pitch, yaw].static double[]pose3dToArray(Pose3d pose) Converts a Pose3d object to an array of doubles in the format [x, y, z, roll, pitch, yaw].static voidPrints detailed information about a PoseEstimate to standard output.static voidsetCameraPose_RobotSpace(String limelightName, double forward, double side, double up, double roll, double pitch, double yaw) Sets the camera pose relative to the robot.static voidsetCropWindow(String limelightName, double cropXMin, double cropXMax, double cropYMin, double cropYMax) Sets the crop window for the camera.static voidsetFiducial3DOffset(String limelightName, double offsetX, double offsetY, double offsetZ) Sets 3D offset point for easy 3D targeting.static voidSetFiducialDownscalingOverride(String limelightName, float downscale) Sets the downscaling factor for AprilTag detection.static voidSetFiducialIDFiltersOverride(String limelightName, int[] validIDs) Overrides the valid AprilTag IDs that will be used for localization.static voidSetIMUAssistAlpha(String limelightName, double alpha) Configures the complementary filter alpha value for IMU Assist Modes (Modes 3 and 4)static voidSetIMUMode(String limelightName, int mode) Configures the IMU mode for MegaTag2 Localizationstatic voidsetKeystone(String limelightName, double horizontal, double vertical) Sets the keystone modification for the crop window.static voidsetLEDMode_ForceBlink(String limelightName) Sets the led mode force blink.static voidsetLEDMode_ForceOff(String limelightName) Sets the led mode force off.static voidsetLEDMode_ForceOn(String limelightName) Sets the led mode force on.static voidsetLEDMode_PipelineControl(String limelightName) Sets LED mode to be controlled by the current pipeline.static voidsetLimelightNTDouble(String tableName, String entryName, double val) Sets the limelight nt double.static voidsetLimelightNTDoubleArray(String tableName, String entryName, double[] val) Sets the limelight nt double array.static voidsetPipelineIndex(String limelightName, int pipelineIndex) Sets the pipeline index.static voidsetPriorityTagID(String limelightName, int ID) Sets the priority tag id.static voidsetPythonScriptData(String limelightName, double[] outgoingPythonData) Sets the python script data.static voidsetRewindEnabled(String limelightName, boolean enabled) Enables or pauses the rewind buffer recording.static voidSetRobotOrientation(String limelightName, double yaw, double yawRate, double pitch, double pitchRate, double roll, double rollRate) Sets robot orientation values used by MegaTag2 localization algorithm.static voidSetRobotOrientation_NoFlush(String limelightName, double yaw, double yawRate, double pitch, double pitchRate, double roll, double rollRate) Sets robot orientation values without flushing.static voidsetStreamMode_PiPMain(String limelightName) Enables Picture-in-Picture mode with secondary stream in the corner.static voidsetStreamMode_PiPSecondary(String limelightName) Enables Picture-in-Picture mode with primary stream in the corner.static voidsetStreamMode_Standard(String limelightName) Enables standard side-by-side stream mode.static voidSetThrottle(String limelightName, int throttle) Configures the throttle value.static voidsetupPortForwardingUSB(int usbIndex) Sets up port forwarding for a Limelight 3A/3G connected via USB.static Pose2dtoPose2D(double[] inData) Takes a 6-length array of pose data and converts it to a Pose2d object.static Pose3dtoPose3D(double[] inData) Takes a 6-length array of pose data and converts it to a Pose3d object.static voidtriggerRewindCapture(String limelightName, double durationSeconds) Triggers a rewind capture with the specified duration.static voidtriggerSnapshot(String limelightName) Triggers a snapshot capture via NetworkTables by incrementing the snapshot counter.static BooleanReturnstrueif the pose estimate is valid.
-
Constructor Details
-
LimelightHelpers
public LimelightHelpers()
-
-
Method Details
-
toPose3D
Takes a 6-length array of pose data and converts it to a Pose3d object. Array format: [x, y, z, roll, pitch, yaw] where angles are in degrees.- Parameters:
inData- Array containing pose data [x, y, z, roll, pitch, yaw]- Returns:
- Pose3d object representing the pose, or empty Pose3d if invalid data
-
toPose2D
Takes a 6-length array of pose data and converts it to a Pose2d object. Uses only x, y, and yaw components, ignoring z, roll, and pitch. Array format: [x, y, z, roll, pitch, yaw] where angles are in degrees.- Parameters:
inData- Array containing pose data [x, y, z, roll, pitch, yaw]- Returns:
- Pose2d object representing the pose, or empty Pose2d if invalid data
-
pose3dToArray
Converts a Pose3d object to an array of doubles in the format [x, y, z, roll, pitch, yaw]. Translation components are in meters, rotation components are in degrees.- Parameters:
pose- The Pose3d object to convert- Returns:
- A 6-element array containing [x, y, z, roll, pitch, yaw]
-
pose2dToArray
Converts a Pose2d object to an array of doubles in the format [x, y, z, roll, pitch, yaw]. Translation components are in meters, rotation components are in degrees. Note: z, roll, and pitch will be 0 since Pose2d only contains x, y, and yaw.- Parameters:
pose- The Pose2d object to convert- Returns:
- A 6-element array containing [x, y, 0, 0, 0, yaw]
-
parsePoseEstimate
public static LimelightHelpers.PoseEstimate parsePoseEstimate(double[] poseArray, long timestampMicros, boolean isMegaTag2) Parses a raw botpose array (as published onbotpose_wpiblueorbotpose_orb_wpiblue) into aLimelightHelpers.PoseEstimate. Pure function; performs no NetworkTables access, so callers that already hold a sample can derive an estimate without a second read.- Parameters:
poseArray- raw pose array;nullor empty yields a defaultLimelightHelpers.PoseEstimatetimestampMicros- NetworkTables server timestamp of the sample, in microsecondsisMegaTag2- whether the array came from a MegaTag2 topic- Returns:
- the parsed estimate (never
null)
-
getRawFiducials
Gets the latest raw fiducial/AprilTag detection results from NetworkTables.- Parameters:
limelightName- Name/identifier of the Limelight- Returns:
- Array of RawFiducial objects containing detection details
-
getRawDetections
Gets the latest raw neural detector results from NetworkTables- Parameters:
limelightName- Name/identifier of the Limelight- Returns:
- Array of RawDetection objects containing detection details
-
getRawTargets
Gets the raw target contours from NetworkTables. Returns ungrouped contours in normalized screen space (-1 to 1).- Parameters:
limelightName- Name/identifier of the Limelight- Returns:
- Array of RawTarget objects containing up to 3 contours
-
getCornerCoordinates
Gets the corner coordinates of detected targets from NetworkTables. Requires "send contours" to be enabled in the Limelight Output tab.- Parameters:
limelightName- Name/identifier of the Limelight- Returns:
- Array of doubles containing corner coordinates [x0, y0, x1, y1, ...]
-
printPoseEstimate
Prints detailed information about a PoseEstimate to standard output. Includes timestamp, latency, tag count, tag span, average tag distance, average tag area, and detailed information about each detected fiducial.- Parameters:
pose- The PoseEstimate object to print. If null, prints "No PoseEstimate available."
-
validPoseEstimate
Returnstrueif the pose estimate is valid.- Parameters:
pose- the pose estimate to check- Returns:
trueif the pose is non-null and contains at least one raw fiducial
-
getLimelightNTTable
Returns the limelight nt table.- Parameters:
tableName- the limelight name- Returns:
- the limelight nt table
-
Flush
public static void Flush()Flush. -
getLimelightNTTableEntry
Returns the limelight nt table entry.- Parameters:
tableName- the limelight nameentryName- the network table entry name- Returns:
- the limelight nt table entry
-
getLimelightDoubleArrayEntry
Returns the limelight double array entry.- Parameters:
tableName- the limelight nameentryName- the network table entry name- Returns:
- the limelight double array entry
-
getLimelightNTDouble
-
setLimelightNTDouble
-
setLimelightNTDoubleArray
-
getLimelightNTDoubleArray
-
getLimelightNTString
-
getLimelightNTStringArray
-
getTV
Does the Limelight have a valid target?- Parameters:
limelightName- Name of the Limelight camera ("" for default)- Returns:
- True if a valid target is present, false otherwise
-
getTX
Gets the horizontal offset from the crosshair to the target in degrees.- Parameters:
limelightName- Name of the Limelight camera ("" for default)- Returns:
- Horizontal offset angle in degrees
-
getTY
Gets the vertical offset from the crosshair to the target in degrees.- Parameters:
limelightName- Name of the Limelight camera ("" for default)- Returns:
- Vertical offset angle in degrees
-
getTXNC
Gets the horizontal offset from the principal pixel/point to the target in degrees. This is the most accurate 2d metric if you are using a calibrated camera and you don't need adjustable crosshair functionality.- Parameters:
limelightName- Name of the Limelight camera ("" for default)- Returns:
- Horizontal offset angle in degrees
-
getTYNC
Gets the vertical offset from the principal pixel/point to the target in degrees. This is the most accurate 2d metric if you are using a calibrated camera and you don't need adjustable crosshair functionality.- Parameters:
limelightName- Name of the Limelight camera ("" for default)- Returns:
- Vertical offset angle in degrees
-
getTA
Gets the target area as a percentage of the image (0-100%).- Parameters:
limelightName- Name of the Limelight camera ("" for default)- Returns:
- Target area percentage (0-100)
-
getT2DArray
T2D is an array that contains several targeting metrics- Parameters:
limelightName- Name of the Limelight camera- Returns:
- Array containing [targetValid, targetCount, targetLatency, captureLatency, tx, ty, txnc, tync, ta, tid, targetClassIndexDetector, targetClassIndexClassifier, targetLongSidePixels, targetShortSidePixels, targetHorizontalExtentPixels, targetVerticalExtentPixels, targetSkewDegrees]
-
getTargetCount
Gets the number of targets currently detected.- Parameters:
limelightName- Name of the Limelight camera- Returns:
- Number of detected targets
-
getClassifierClassIndex
Gets the classifier class index from the currently running neural classifier pipeline- Parameters:
limelightName- Name of the Limelight camera- Returns:
- Class index from classifier pipeline
-
getDetectorClassIndex
Gets the detector class index from the primary result of the currently running neural detector pipeline.- Parameters:
limelightName- Name of the Limelight camera- Returns:
- Class index from detector pipeline
-
getClassifierClass
-
getDetectorClass
-
getLatency_Pipeline
Gets the pipeline's processing latency contribution.- Parameters:
limelightName- Name of the Limelight camera- Returns:
- Pipeline latency in milliseconds
-
getLatency_Capture
Gets the capture latency.- Parameters:
limelightName- Name of the Limelight camera- Returns:
- Capture latency in milliseconds
-
getCurrentPipelineIndex
Gets the active pipeline index.- Parameters:
limelightName- Name of the Limelight camera- Returns:
- Current pipeline index (0-9)
-
getCurrentPipelineType
-
getJSONDump
-
getBotpose
Deprecated.Switch to getBotPose- Parameters:
limelightName- the Limelight table name- Returns:
-
getBotpose_wpiRed
Deprecated.Switch to getBotPose_wpiRed- Parameters:
limelightName- the Limelight table name- Returns:
-
getBotpose_wpiBlue
Deprecated.Switch to getBotPose_wpiBlue- Parameters:
limelightName- the Limelight table name- Returns:
-
getBotPose
Returns the bot pose.- Parameters:
limelightName- the Limelight table name- Returns:
- the bot pose
-
getBotPose_wpiRed
Returns the bot pose wpi red.- Parameters:
limelightName- the Limelight table name- Returns:
- the bot pose wpi red
-
getBotPose_wpiBlue
Returns the bot pose wpi blue.- Parameters:
limelightName- the Limelight table name- Returns:
- the bot pose wpi blue
-
getBotPose_TargetSpace
Returns the bot pose target space.- Parameters:
limelightName- the Limelight table name- Returns:
- the bot pose target space
-
getCameraPose_TargetSpace
Returns the camera pose target space.- Returns:
- the camera pose target space
-
getTargetPose_CameraSpace
Returns the target pose camera space.- Parameters:
limelightName- the Limelight table name- Returns:
- the target pose camera space
-
getTargetPose_RobotSpace
Returns the target pose robot space.- Parameters:
limelightName- the Limelight table name- Returns:
- the target pose robot space
-
getTargetColor
Gets the average color under the crosshair region as a 3-element array.- Parameters:
limelightName- Name of the Limelight camera- Returns:
- Array containing [Blue, Green, Red] color values (BGR order)
-
getFiducialID
Returns the fiducial id.- Parameters:
limelightName- the Limelight table name- Returns:
- the fiducial id
-
getHeartbeat
Gets the Limelight heartbeat value. Increments once per frame, allowing you to detect if the Limelight is connected and alive.- Parameters:
limelightName- Name of the Limelight camera- Returns:
- Heartbeat value that increments each frame
-
getNeuralClassID
-
getRawBarcodeData
-
getBotPose3d
-
getBotPose3d_wpiRed
(Not Recommended) Gets the robot's 3D pose in the WPILib Red Alliance Coordinate System.- Parameters:
limelightName- Name/identifier of the Limelight- Returns:
- Pose3d object representing the robot's position and orientation in Red Alliance field space
-
getBotPose3d_wpiBlue
(Recommended) Gets the robot's 3D pose in the WPILib Blue Alliance Coordinate System.- Parameters:
limelightName- Name/identifier of the Limelight- Returns:
- Pose3d object representing the robot's position and orientation in Blue Alliance field space
-
getBotPose3d_TargetSpace
Gets the robot's 3D pose with respect to the currently tracked target's coordinate system.- Parameters:
limelightName- Name/identifier of the Limelight- Returns:
- Pose3d object representing the robot's position and orientation relative to the target
-
getCameraPose3d_TargetSpace
Gets the camera's 3D pose with respect to the currently tracked target's coordinate system.- Parameters:
limelightName- Name/identifier of the Limelight- Returns:
- Pose3d object representing the camera's position and orientation relative to the target
-
getTargetPose3d_CameraSpace
Gets the target's 3D pose with respect to the camera's coordinate system.- Parameters:
limelightName- Name/identifier of the Limelight- Returns:
- Pose3d object representing the target's position and orientation relative to the camera
-
getTargetPose3d_RobotSpace
-
getCameraPose3d_RobotSpace
-
getBotPose2d_wpiBlue
-
getBotPoseEstimate_wpiBlue
Gets the MegaTag1 Pose2d and timestamp for use with WPILib pose estimator (addVisionMeasurement) in the WPILib Blue alliance coordinate system.- Parameters:
limelightName- the Limelight table name- Returns:
-
getBotPoseEstimate_wpiBlue_MegaTag2
public static LimelightHelpers.PoseEstimate getBotPoseEstimate_wpiBlue_MegaTag2(String limelightName) Gets the MegaTag2 Pose2d and timestamp for use with WPILib pose estimator (addVisionMeasurement) in the WPILib Blue alliance coordinate system. Make sure you are calling setRobotOrientation() before calling this method.- Parameters:
limelightName- the Limelight table name- Returns:
-
getBotPose2d_wpiRed
-
getBotPoseEstimate_wpiRed
Gets the Pose2d and timestamp for use with WPILib pose estimator (addVisionMeasurement) when you are on the RED alliance- Parameters:
limelightName- the Limelight table name- Returns:
-
getBotPoseEstimate_wpiRed_MegaTag2
public static LimelightHelpers.PoseEstimate getBotPoseEstimate_wpiRed_MegaTag2(String limelightName) Gets the Pose2d and timestamp for use with WPILib pose estimator (addVisionMeasurement) when you are on the RED alliance- Parameters:
limelightName- the Limelight table name- Returns:
-
getBotPose2d
-
getIMUData
Gets the current IMU data from NetworkTables. IMU data is formatted as [robotYaw, Roll, Pitch, Yaw, gyroX, gyroY, gyroZ, accelX, accelY, accelZ]. Returns all zeros if data is invalid or unavailable.- Parameters:
limelightName- Name/identifier of the Limelight- Returns:
- IMUData object containing all current IMU data
-
setPipelineIndex
Sets the pipeline index.- Parameters:
limelightName- the Limelight table namepipelineIndex- the pipeline index to set
-
setPriorityTagID
Sets the priority tag id.- Parameters:
limelightName- the Limelight table nameID- the priority tag ID
-
setLEDMode_PipelineControl
Sets LED mode to be controlled by the current pipeline.- Parameters:
limelightName- Name of the Limelight camera
-
setLEDMode_ForceOff
Sets the led mode force off.- Parameters:
limelightName- the Limelight table name
-
setLEDMode_ForceBlink
Sets the led mode force blink.- Parameters:
limelightName- the Limelight table name
-
setLEDMode_ForceOn
Sets the led mode force on.- Parameters:
limelightName- the Limelight table name
-
setStreamMode_Standard
Enables standard side-by-side stream mode.- Parameters:
limelightName- Name of the Limelight camera
-
setStreamMode_PiPMain
Enables Picture-in-Picture mode with secondary stream in the corner.- Parameters:
limelightName- Name of the Limelight camera
-
setStreamMode_PiPSecondary
Enables Picture-in-Picture mode with primary stream in the corner.- Parameters:
limelightName- Name of the Limelight camera
-
setCropWindow
public static void setCropWindow(String limelightName, double cropXMin, double cropXMax, double cropYMin, double cropYMax) Sets the crop window for the camera. The crop window in the UI must be completely open.- Parameters:
limelightName- Name of the Limelight cameracropXMin- Minimum X value (-1 to 1)cropXMax- Maximum X value (-1 to 1)cropYMin- Minimum Y value (-1 to 1)cropYMax- Maximum Y value (-1 to 1)
-
setKeystone
Sets the keystone modification for the crop window.- Parameters:
limelightName- Name of the Limelight camerahorizontal- Horizontal keystone value (-0.95 to 0.95)vertical- Vertical keystone value (-0.95 to 0.95)
-
setFiducial3DOffset
public static void setFiducial3DOffset(String limelightName, double offsetX, double offsetY, double offsetZ) Sets 3D offset point for easy 3D targeting. -
SetRobotOrientation
public static void SetRobotOrientation(String limelightName, double yaw, double yawRate, double pitch, double pitchRate, double roll, double rollRate) Sets robot orientation values used by MegaTag2 localization algorithm.- Parameters:
limelightName- Name/identifier of the Limelightyaw- Robot yaw in degrees. 0 = robot facing red alliance wall in FRCyawRate- (Unnecessary) Angular velocity of robot yaw in degrees per secondpitch- (Unnecessary) Robot pitch in degreespitchRate- (Unnecessary) Angular velocity of robot pitch in degrees per secondroll- (Unnecessary) Robot roll in degreesrollRate- (Unnecessary) Angular velocity of robot roll in degrees per second
-
SetRobotOrientation_NoFlush
public static void SetRobotOrientation_NoFlush(String limelightName, double yaw, double yawRate, double pitch, double pitchRate, double roll, double rollRate) Sets robot orientation values without flushing.- Parameters:
limelightName- the Limelight table name
-
SetIMUMode
Configures the IMU mode for MegaTag2 Localization- Parameters:
limelightName- Name/identifier of the Limelightmode- IMU mode.
-
SetIMUAssistAlpha
Configures the complementary filter alpha value for IMU Assist Modes (Modes 3 and 4)- Parameters:
limelightName- Name/identifier of the Limelightalpha- Defaults to .001. Higher values will cause the internal IMU to converge onto the assist source more rapidly.
-
SetThrottle
Configures the throttle value. Set to 100-200 while disabled to reduce thermal output/temperature.- Parameters:
limelightName- Name/identifier of the Limelightthrottle- Defaults to 0. Your Limelgiht will process one frame after skippingframes.
-
SetFiducialIDFiltersOverride
Overrides the valid AprilTag IDs that will be used for localization. Tags not in this list will be ignored for robot pose estimation.- Parameters:
limelightName- Name/identifier of the LimelightvalidIDs- Array of valid AprilTag IDs to track
-
SetFiducialDownscalingOverride
Sets the downscaling factor for AprilTag detection. Increasing downscale can improve performance at the cost of potentially reduced detection range.- Parameters:
limelightName- Name/identifier of the Limelightdownscale- Downscale factor. Valid values: 1.0 (no downscale), 1.5, 2.0, 3.0, 4.0. Set to 0 for pipeline control.
-
setCameraPose_RobotSpace
public static void setCameraPose_RobotSpace(String limelightName, double forward, double side, double up, double roll, double pitch, double yaw) Sets the camera pose relative to the robot.- Parameters:
limelightName- Name of the Limelight cameraforward- Forward offset in metersside- Side offset in metersup- Up offset in metersroll- Roll angle in degreespitch- Pitch angle in degreesyaw- Yaw angle in degrees
-
setPythonScriptData
Sets the python script data.- Parameters:
limelightName- the limelight nameoutgoingPythonData- the data to pass to the python script
-
getPythonScriptData
Returns the python script data.- Parameters:
limelightName- the Limelight table name- Returns:
- the python script data
-
triggerSnapshot
Triggers a snapshot capture via NetworkTables by incrementing the snapshot counter. Rate-limited to once per 10 frames on the Limelight.- Parameters:
limelightName- Name of the Limelight camera
-
setRewindEnabled
Enables or pauses the rewind buffer recording.- Parameters:
limelightName- Name of the Limelight cameraenabled- True to enable recording, false to pause
-
triggerRewindCapture
Triggers a rewind capture with the specified duration. Maximum duration is 165 seconds. Rate-limited on the Limelight.- Parameters:
limelightName- Name of the Limelight cameradurationSeconds- Duration of rewind capture in seconds (max 165)
-
getLatestResults
Gets the latest JSON results output and returns a LimelightResults object.- Parameters:
limelightName- Name of the Limelight camera- Returns:
- LimelightResults object containing all current target data
-
setupPortForwardingUSB
public static void setupPortForwardingUSB(int usbIndex) Sets up port forwarding for a Limelight 3A/3G connected via USB. This allows access to the Limelight web interface and video stream when connected to the robot over USB.For usbIndex 0: ports 5800-5809 forward to 172.29.0.1 For usbIndex 1: ports 5810-5819 forward to 172.29.1.1 etc.
Call this method once during robot initialization. To access the interface of the camera with usbIndex0, you would go to roboRIO-(teamnum)-FRC.local:5801. Port 5811 for usb index 1
- Parameters:
usbIndex- The USB index of the Limelight (0, 1, 2, etc.)
-