Class Limelight

java.lang.Object
com.limelightvision.Limelight
All Implemented Interfaces:
AutoCloseable

public class Limelight extends Object implements AutoCloseable
Interface to one Limelight camera or Systemcore vision instance.

Quick start

Visual servoing

double turnKp = -0.02;
Limelight camera = new Limelight("limelight");
//Limelight camera = new Limelight(Limelight.SYSTEMCORE_USB0);
//Limelight camera = new Limelight(Limelight.SYSTEMCORE_USB1);

// Each loop
double turn = joystick.getRightX();
if(aimingEnabled && camera.hasTarget()){
     turn = turnKp * camera.getTXDegrees();
}
drivetrain.arcadeDrive(forward, turn);

MegaTag1 localization

Pose3d cameraPoseRobotSpace = new Pose3d(0.30, 0.0, 0.20, new Rotation3d());
Limelight camera = new Limelight("limelight", cameraPoseRobotSpace);

// Each robot loop
Limelight.PoseEstimateType type = Limelight.PoseEstimateType.MT1_WPIBLUE;
for (var estimate : camera.readAcceptedPoseEstimates(type)) {
  poseEstimator.addVisionMeasurement(estimate.pose, estimate.timestampSeconds, estimate.stdDevs);
}

MegaTag2 localization

Publish robot yaw before reading the queue each robot loop.

Pose3d cameraPoseRobotSpace = new Pose3d(0.30, 0.0, 0.20, new Rotation3d());
Limelight camera = new Limelight("limelight", cameraPoseRobotSpace);

// Each robot loop
Limelight.setSharedRobotOrientation(robotYawDegrees);
Limelight.PoseEstimateType type = Limelight.PoseEstimateType.MT2_WPIBLUE;
for (var estimate : camera.readAcceptedPoseEstimates(type)) {
  poseEstimator.addVisionMeasurement(estimate.pose, estimate.timestampSeconds, estimate.stdDevs);
}

Configured MegaTag1 and MegaTag2

This example configures every filter and standard-deviation scaling term. MT1 scales XY uncertainty linearly with distance and clamps it to 0.05-2.0 meters. MT2 scales it by the square root of distance and clamps it to 0.0001-2.0 meters. Both divide by the square root of the fielded tag count. Vision heading is not fused. The field bounds are for the 2026 welded field. Tune the other thresholds on your robot.

double untrusted = Limelight.PoseEstimateConfig.UNTRUSTED;
// Start from the default so you do not have to set every value.
Limelight.PoseEstimateConfig mt1Config = Limelight.PoseEstimateConfig.defaultMT1()
    .withMinTagCount(1)
    .withMaxSingleTagAmbiguity(0.7) // MT1 needs low-ambiguity perspectives
    .withMaxSingleTagDistance(3.0) // Trust a single tag only within 3 m
    .withMaxAvgTagDistance(6.0) // With several tags, average distance under 6 m
    .withMinAvgTagArea(0.05)
    .withFieldBounds(16.541, 8.069) // Reject estimates outside the field
    .withFieldBoundsMargin(0.5) // Allow 0.5 m past the field walls
    .withStdDevXY(0.5, 0.05, 2.0) // 0.5 base, minimum 0.05, maximum 2.0
    .withStdDevTheta(untrusted, untrusted, untrusted) // Never fuse vision heading
    .withStdDevDistanceScaling(1.0, 0.0, 6.0) // Linear scaling
    .withStdDevTagCountDivision(0.5);

Limelight.PoseEstimateConfig mt2Config = Limelight.PoseEstimateConfig.defaultMT2()
    .withMinTagCount(1)
    .withMaxSingleTagAmbiguity(1.0) // MT2 handles ambiguous perspectives, accept all
    .withMaxSingleTagDistance(0.0) // 0 disables this check
    .withMaxAvgTagDistance(8.0)
    .withMinAvgTagArea(0.02)
    .withFieldBounds(16.541, 8.069)
    .withFieldBoundsMargin(0.5)
    .withStdDevXY(0.3, 0.0001, 2.0)
    .withStdDevTheta(untrusted, untrusted, untrusted)
    .withStdDevDistanceScaling(0.5, 0.0, 8.0) // Square root of distance for MT2
    .withStdDevTagCountDivision(0.5);

Pose3d cameraPoseRobotSpace = new Pose3d(0.30, 0.0, 0.20, new Rotation3d());
Limelight camera = new Limelight("limelight", cameraPoseRobotSpace)
    .withPoseEstimateConfig_MT1(mt1Config)
    .withPoseEstimateConfig_MT2(mt2Config)
    .withTelemetry(true); // Keep accepted and rejected poses visible on dashboards
boolean useMegaTag2 = true;

// Each robot loop
Limelight.PoseEstimateType type = Limelight.PoseEstimateType.MT1_WPIBLUE;
if (useMegaTag2) {
  type = Limelight.PoseEstimateType.MT2_WPIBLUE;
  // Use your robot pose heading here, not your raw IMU reading.
  Limelight.setSharedRobotOrientation(robotYawDegrees);
}
for (var estimate : camera.readAcceptedPoseEstimates(type)) {
  poseEstimator.addVisionMeasurement(estimate.pose, estimate.timestampSeconds, estimate.stdDevs);
}

All values from one getLatestResults() call come from the same frame. This includes tx, botpose, fiducials, latencies, and timestamps.

All 3D data uses the right-handed NWU convention in every space (field, robot, camera, target): x = forward, y = left, z = up. Raw pose arrays are [x, y, z, roll, pitch, yaw] in meters and degrees.

Getters decode at most one new frame. Otherwise they return cached data. After a disconnect, they return the values of the last frame. Use getStatus() or Limelight.LimelightResults.getAgeSeconds() to detect a stale camera.

Use this class from one thread, the robot loop.

  • Field Details

    • STALE_FRAME_SECONDS

      public static final double STALE_FRAME_SECONDS
      Default stale threshold. getStatus() reports Limelight.Status.STALE for a frame older than this. Override per instance with withStaleFrameThreshold(double).
      See Also:
    • NT_TICKS_PER_SECOND

      public static final double NT_TICKS_PER_SECOND
      NetworkTables timestamp ticks per second for the WPILib build this library targets. WPILib 2027 alpha-7 and later use 1e9. Alpha-6 and earlier use 1e6. Divide a NetworkTables timestamp by this value to get seconds.
      See Also:
    • SUPPORTED_PROTOCOL_VERSION

      public static final int SUPPORTED_PROTOCOL_VERSION
      The highest camera protocol version ("protover") this library understands. If a camera publishes a higher version, the library prints one warning.
      See Also:
    • MAX_PIPELINE_CONFIGURATION_OVERRIDE_BYTES

      public static final int MAX_PIPELINE_CONFIGURATION_OVERRIDE_BYTES
      Maximum size in bytes of a pipeline configuration override. Both this library and the camera reject larger publishes.
      See Also:
    • MAX_SHARED_MAP_BYTES

      public static final int MAX_SHARED_MAP_BYTES
      Maximum size in bytes of a shared field map. Both this library and the camera reject larger publishes.
      See Also:
    • SYSTEMCORE_USB0

      public static final String SYSTEMCORE_USB0
      Name of the vision instance running on Systemcore USB port 0: new Limelight(Limelight.SYSTEMCORE_USB0).
      See Also:
    • SYSTEMCORE_USB1

      public static final String SYSTEMCORE_USB1
      Name of the vision instance running on Systemcore USB port 1.
      See Also:
    • SYSTEMCORE_USB2

      public static final String SYSTEMCORE_USB2
      Name of the vision instance running on Systemcore USB port 2.
      See Also:
    • SYSTEMCORE_USB3

      public static final String SYSTEMCORE_USB3
      Name of the vision instance running on Systemcore USB port 3.
      See Also:
    • TELEMETRY_TABLE

      public static final String TELEMETRY_TABLE
      Root telemetry table. Each camera uses limelight_telemetry/<name>/. The shared Field2d table is limelight_telemetry/Field.
      See Also:
  • Constructor Details

    • Limelight

      public Limelight()
      Creates an interface to the Limelight with the default name ("limelight").
    • Limelight

      public Limelight(String name)
      Creates an interface to the given Limelight.
      Parameters:
      name - The camera or vision instance's NetworkTables name (e.g. "limelight" or "limelight-left")
    • Limelight

      public Limelight(String name, org.wpilib.math.geometry.Pose3d cameraPoseRobotSpace)
      Creates an interface to the given Limelight and sets its camera pose in robot space.
      Parameters:
      name - The NetworkTables name of the camera, for example "limelight" or "limelight-left"
      cameraPoseRobotSpace - The pose of the camera relative to the robot center (x = forward, y = left, z = up, in meters). This overrides the camera pose configured in the web interface. Call clearCameraPose_RobotSpaceOverride() to return to it. Null publishes nothing. An all-zero pose is the clear value, so the camera keeps the pose from the web interface.
    • Limelight

      public Limelight(String name, double forward, double left, double up, double rollDegrees, double pitchDegrees, double yawDegrees)
      Creates an interface to the given Limelight and sets its camera pose in robot space. This overrides the camera pose configured in the web interface. Call clearCameraPose_RobotSpaceOverride() to return to it. An all-zero pose is the clear value, so the camera keeps the pose from the web interface.
      Parameters:
      name - The NetworkTables name of the camera, for example "limelight" or "limelight-left"
      forward - Forward (x) offset in meters
      left - Left (y) offset in meters
      up - Up (z) offset in meters
      rollDegrees - Roll angle in degrees
      pitchDegrees - Pitch angle in degrees
      yawDegrees - Yaw angle in degrees
  • Method Details

    • withStaleFrameThreshold

      public Limelight withStaleFrameThreshold(double seconds)
      Sets the maximum age of the newest frame. Above this age, getStatus() reports Limelight.Status.STALE and hasTarget() returns false. Raise this value when you use setThrottle(int).
      Parameters:
      seconds - Stale threshold in seconds. Positive infinity disables stale detection.
      Returns:
      this, for chaining with the constructor
    • withPoseEstimateConfig_MT1

      public Limelight withPoseEstimateConfig_MT1(Limelight.PoseEstimateConfig config)
      Configures filtering and fusion standard deviations for every MegaTag1 pose estimate. MegaTag1 computes heading from tag geometry only. It usually needs stricter ambiguity and tag-count gates than MegaTag2. Rejected estimates report isValid() == false. Limelight.PoseEstimate.rejectionFlags lists the failed checks.
      Parameters:
      config - The MegaTag1 configuration. The configuration is copied. Later changes to the object have no effect until you attach it again. Null resets to Limelight.PoseEstimateConfig.defaultMT1()
      Returns:
      this, for chaining with the constructor
    • withPoseEstimateConfig_MT2

      public Limelight withPoseEstimateConfig_MT2(Limelight.PoseEstimateConfig config)
      Configures filtering and fusion standard deviations for every MegaTag2 pose estimate.
      Parameters:
      config - The MegaTag2 configuration. The configuration is copied. Later changes to the object have no effect until you attach it again. Null resets to Limelight.PoseEstimateConfig.defaultMT2()
      Returns:
      this, for chaining with the constructor
    • withTelemetry

      public Limelight withTelemetry(boolean enabled)
      Enables or disables automatic pose-estimate telemetry. Enabled by default. Pose estimates publish under limelight_telemetry/<name>/<type>/:
      • accepted and rejected: Pose2d struct arrays for field views
      • rejectionReasons: for example TAG_COUNT|AMBIGUITY

      The camera-level counts/ topics aggregate all estimate types that readPoseEstimateQueue(Limelight.PoseEstimateType) and readAcceptedPoseEstimates(Limelight.PoseEstimateType) process. One estimate can increment several rejection-reason totals. The same estimates appear on the shared limelight_telemetry/Field Field2d table for Glass and Elastic. Camera health publishes as connected, customCalibration, and status. Pose displays clear when the camera is unhealthy. Disabling telemetry unpublishes everything and resets the counters.

      Returns:
      this, for chaining with the constructor
    • getName

      public String getName()
      Returns the camera's NetworkTables name.
      Returns:
      The camera's NetworkTables name
    • getProtocolVersion

      public int getProtocolVersion()
      Returns the msgpack envelope protocol version from the camera.
      Returns:
      The msgpack envelope protocol version from the camera. 0 if the camera has not connected or runs old software
    • getLatestResults

      public Limelight.LimelightResults getLatestResults()
      Returns the latest results envelope. Decodes the newest MessagePack frame if one arrived since the last call. This method is cheap to call many times per loop. The decoded envelope is cached until a new frame arrives. This method never consumes the frame queue. You can use it together with readResultsQueue().
      Returns:
      The latest LimelightResults, never null. Use getStatus() for camera health. Use Limelight.LimelightResults.valid for target validity. Each new frame produces a new object. Call this getter every loop instead of keeping the returned object.
    • decode

      public static Limelight.LimelightResults decode(byte[] envelope)
      Decodes a results envelope from raw MessagePack bytes. Decode failures are reported in Limelight.LimelightResults.error. This method never throws. Use it for unit tests.

      receiveTimestampSeconds stays 0. Pose estimates built from the result are rejected as NO_TIMESTAMP. Use decode(byte[], long) for pose estimate tests.

      Parameters:
      envelope - The raw MessagePack results dump
      Returns:
      The decoded results. receiveTimestampSeconds stays 0
    • decode

      public static Limelight.LimelightResults decode(byte[] envelope, long receiveTimestampMicros)
      Decodes a results envelope and stamps it with its NetworkTables receive time. This matches live decoding and timestamp handling. For log replay: record raw frames with getLatestRawFrame() or readRawFrameQueue(). Then pass the bytes and the timestamp to this method. Estimates built from the result have latency-compensated timestamps.
      Parameters:
      envelope - The raw MessagePack results dump
      receiveTimestampMicros - NetworkTables receive time in microseconds (local NetworkTables timebase, WPILib alpha-6 or older), for example TimestampedRaw.timestamp
    • getStatus

      public Limelight.Status getStatus()
      Returns the current health of the camera from the point of view of this consumer.
      Returns:
      The current health of the camera from the point of view of this consumer. Limelight.Status.OK means a decodable frame arrived within the stale threshold. The threshold is STALE_FRAME_SECONDS unless you override it with withStaleFrameThreshold(double).
    • isConnected

      public boolean isConnected()
      Returns true if the camera is reachable.
      Returns:
      True if the camera is reachable. The status is not Limelight.Status.NO_DATA and not Limelight.Status.STALE
    • close

      public void close()
      Releases this instance's NetworkTables subscriptions and removes its telemetry topics. Call from test teardown. Robot code normally never needs this.
      Specified by:
      close in interface AutoCloseable
    • hasTarget

      public boolean hasTarget()
      Returns true if the camera is connected, sends fresh frames, and has at least one valid target.
      Returns:
      True if the camera is connected, sends fresh frames, and has at least one valid target. Returns false when the newest frame is older than the stale threshold.
    • getTXDegrees

      public double getTXDegrees()
      Returns horizontal offset from crosshair to target in degrees.
      Returns:
      Horizontal offset from crosshair to target in degrees. This value holds the last received value after a disconnect. Check hasTarget() every loop.
    • getTYDegrees

      public double getTYDegrees()
      Returns vertical offset from crosshair to target in degrees.
      Returns:
      Vertical offset from crosshair to target in degrees. This value holds the last received value after a disconnect. Check hasTarget() every loop.
    • getTXDegreesNoCrosshair

      public double getTXDegreesNoCrosshair()
      Returns horizontal offset from principal pixel to target in degrees (crosshair-independent).
      Returns:
      Horizontal offset from principal pixel to target in degrees (crosshair-independent)
    • getTYDegreesNoCrosshair

      public double getTYDegreesNoCrosshair()
      Returns vertical offset from principal pixel to target in degrees (crosshair-independent).
      Returns:
      Vertical offset from principal pixel to target in degrees (crosshair-independent)
    • getTargetAreaPercent

      public double getTargetAreaPercent()
      Returns target area as a percentage of the image (0-100).
      Returns:
      Target area as a percentage of the image (0-100). This value holds the last received value after a disconnect. Check hasTarget() every loop.
    • getTargetDistanceMeters

      public double getTargetDistanceMeters()
      Returns 3D distance from the camera to the primary fiducial target in meters.
      Returns:
      3D distance from the camera to the primary fiducial target in meters. 0 if not available
    • getTargetCount

      public int getTargetCount()
      Returns total number of retro, fiducial, detector, classifier, and barcode targets in the latest frame.
      Returns:
      Total number of retro, fiducial, detector, classifier, and barcode targets in the latest frame
    • getCurrentPipelineIndex

      public int getCurrentPipelineIndex()
      Returns active pipeline index (0-9).
      Returns:
      Active pipeline index (0-9). -1 before the first frame arrives
    • getCurrentPipelineType

      public String getCurrentPipelineType()
      Returns active pipeline type, for example "pipe_fiducial", "pipe_color", or "pipe_detector".
      Returns:
      Active pipeline type, for example "pipe_fiducial", "pipe_color", or "pipe_detector"
    • getTargetingLatencyMillis

      public double getTargetingLatencyMillis()
      Returns targeting/pipeline latency in milliseconds.
      Returns:
      Targeting/pipeline latency in milliseconds
    • getCaptureLatencyMillis

      public double getCaptureLatencyMillis()
      Returns capture latency in milliseconds.
      Returns:
      Capture latency in milliseconds
    • getIMUData

      public Limelight.IMUData getIMUData()
      Returns iMU state from the latest frame.
      Returns:
      IMU state from the latest frame
    • getHardwareData

      public Limelight.HardwareData getHardwareData()
      Returns hardware/system stats from the latest frame.
      Returns:
      Hardware/system stats from the latest frame
    • getCameraIntrinsics

      public Limelight.CameraIntrinsics getCameraIntrinsics()
      Returns the camera intrinsics that the running pipeline uses.
      Returns:
      The camera intrinsics that the running pipeline uses. Includes the camera matrix scaled to the processing resolution, the OpenCV distortion coefficients, and the FOV
    • isUsingCustomCalibration

      public boolean isUsingCustomCalibration()
      Returns true if the running pipeline uses a user-uploaded camera calibration instead of a built-in default.
      Returns:
      True if the running pipeline uses a user-uploaded camera calibration instead of a built-in default. See Limelight.CameraIntrinsics.customCalibration. False before the first frame arrives.
    • getPythonScriptData

      public double[] getPythonScriptData()
      Returns data set by a python snapscript via llpython.
      Returns:
      Data set by a python snapscript via llpython
    • getPoseEstimate

      public Limelight.PoseEstimate getPoseEstimate(Limelight.PoseEstimateType type)
      Gets the pose estimate of the given type from the newest frame. This getter can return the same frame many times, also after a disconnect. Use readAcceptedPoseEstimates(Limelight.PoseEstimateType) for fusion. Use getStatus() for current camera health.
      Parameters:
      type - Which pose estimate to produce
    • getPoseEstimate

      Builds a pose estimate of the given type from one results envelope. Applies the Limelight.PoseEstimateConfig for the algorithm of the estimate. Use this with readResultsQueue() to get several estimate types (for example MT1 and MT2) from one queue read.
      Parameters:
      results - The envelope to build from
      type - Which pose estimate to produce
    • readResultsQueue

      public Limelight.LimelightResults[] readResultsQueue()
      Decodes and returns every buffered results envelope received since the last queue read. The queue holds 20 frames. If more frames arrive between reads, the oldest frames are discarded. The newest frame also becomes the result of getLatestResults().

      Use only one queue reading method per camera. The queue reading methods are this method, readPoseEstimateQueue(Limelight.PoseEstimateType), readAcceptedPoseEstimates(Limelight.PoseEstimateType), and readRawFrameQueue(). To get several values from each frame, read the queue here one time. Then call getPoseEstimate(LimelightResults, PoseEstimateType) for each frame. Other getters only read the newest frame. They do not consume the queue.

      Returns:
      All buffered frames, oldest first. Empty if no new frame arrived
    • readPoseEstimateQueue

      public Limelight.PoseEstimate[] readPoseEstimateQueue(Limelight.PoseEstimateType type)
      Reads every frame received since the last queue read. Returns one pose estimate of the given type for each frame. This lets your pose estimator use every vision update. Check Limelight.PoseEstimate.isValid() on each estimate before you fuse it.

      This method consumes the queue. Do not use another queue reading method for this camera.

      Parameters:
      type - Which pose estimate to produce for each frame
      Returns:
      One pose estimate per frame, oldest first
    • readAcceptedPoseEstimates

      public Limelight.PoseEstimate[] readAcceptedPoseEstimates(Limelight.PoseEstimateType type)
      Reads every frame received since the last queue read. Returns only the pose estimates that passed validation and filtering. Each queued frame is processed one time. The pose estimator decides if the timestamp is still in range.
      PoseEstimateType type = PoseEstimateType.MT2_WPIBLUE;
      for (PoseEstimate estimate : camera.readAcceptedPoseEstimates(type)) {
        poseEstimator.addVisionMeasurement(
            estimate.pose, estimate.timestampSeconds, estimate.stdDevs);
      }
      

      Telemetry shows the newest estimate and keeps rejection counters. Use readPoseEstimateQueue(Limelight.PoseEstimateType) to inspect every rejected estimate.

      This method consumes the queue. Do not use another queue reading method for this camera.

      Parameters:
      type - Which pose estimate to produce for each frame
      Returns:
      The accepted estimates, oldest first. Empty if no new frame arrived or no estimate passed
    • getLatestRawFrame

      public org.wpilib.networktables.TimestampedRaw getLatestRawFrame()
      Returns the newest raw results envelope without decoding it. The result has the MessagePack bytes and the NetworkTables receive timestamp in microseconds (local NetworkTables timebase). This method does not consume the frame queue. Use it with decode(byte[], long) for logging and replay.
      Returns:
      The newest raw frame. The value is empty if no frame has arrived
    • readRawFrameQueue

      public org.wpilib.networktables.TimestampedRaw[] readRawFrameQueue()
      Reads every raw envelope received since the last queue read, without decoding. Use this for logging and replay systems. These systems record raw frames and decode them with decode(byte[], long), live or from a log.

      This method consumes the queue. Do not use another queue reading method for this camera.

      Returns:
      All buffered raw frames, oldest first. Empty if no new frame arrived
    • getRobotPose

      public org.wpilib.math.geometry.Pose3d getRobotPose(Limelight.PoseEstimateType type)
      Returns the full 3D robot pose for the given estimate type.
      Returns:
      The full 3D robot pose for the given estimate type. The type selects the origin and the algorithm
    • getCameraPose_RobotSpace

      public org.wpilib.math.geometry.Pose3d getCameraPose_RobotSpace()
      Returns camera pose in robot space (meters, degrees) as a Pose3d.
      Returns:
      Camera pose in robot space (meters, degrees) as a Pose3d
    • setPipelineIndex

      public void setPipelineIndex(int pipelineIndex)
      Switches to the given pipeline.
      Parameters:
      pipelineIndex - Pipeline index (0-9)
    • setPipelineConfigurationOverride

      public void setPipelineConfigurationOverride(Limelight.PipelineConfiguration config)
      Publishes a pipeline configuration override to this camera. Flushes NetworkTables immediately. The camera runs the override while it is enabled with setUsePipelineConfigurationOverride(boolean). The ten pipelines on the camera do not change. You can switch between them and the override at any time.

      Create the Limelight.PipelineConfiguration during robot initialization. Publishing is only a NetworkTables write. It does not access the disk. You can switch between several prepared configurations during a match:

      // robotInit
      PipelineConfiguration aiming = Limelight.PipelineConfiguration.fromDeployFolder("aiming");
      // whenever
      camera.setPipelineConfigurationOverride(aiming);
      camera.setUsePipelineConfigurationOverride(true);
      
      Parameters:
      config - The configuration to publish. The method ignores null or a configuration that is not valid and prints a warning
    • clearPipelineConfigurationOverride

      public void clearPipelineConfigurationOverride()
      Clears the published pipeline configuration override. Flushes NetworkTables immediately. If the override was running, the camera returns immediately to the pipeline selected by setPipelineIndex(int). Otherwise, it returns when the override is next disabled.
    • setUsePipelineConfigurationOverride

      public void setUsePipelineConfigurationOverride(boolean use)
      Enables or disables the pipeline configuration override. While enabled, the camera runs the pipeline published with setPipelineConfigurationOverride(Limelight.PipelineConfiguration). While disabled, the camera runs the pipeline selected by setPipelineIndex(int). The published override stays on the camera in both states. You can switch between the two at any time.
      Parameters:
      use - True to run the override. False to run the indexed pipeline
    • isPipelineConfigurationOverrideEnabled

      public boolean isPipelineConfigurationOverrideEnabled()
      Reads back whether the camera runs the pipeline configuration override. The value comes from the latest results frame. It can differ from the value requested with setUsePipelineConfigurationOverride(boolean). For example, the camera web interface can force the override off.
      Returns:
      True if the camera reports that the override is running
    • getPipelineConfigurationOverrideState

      public Limelight.PipelineConfigurationOverrideState getPipelineConfigurationOverrideState()
      Returns the camera's pipeline configuration override state from the latest results frame.
      Returns:
      The camera's pipeline configuration override state from the latest results frame
    • isSharedMapActive

      public boolean isSharedMapActive()
      Returns true if the camera localizes with the shared field map published with setSharedMap(Limelight.FieldMap).
      Returns:
      True if the camera localizes with the shared field map published with setSharedMap(Limelight.FieldMap). The value comes from the latest results frame
    • getSharedMapState

      public Limelight.SharedMapState getSharedMapState()
      Returns the camera's shared field map state from the latest results frame.
      Returns:
      The camera's shared field map state from the latest results frame
    • setSharedMap

      public static void setSharedMap(Limelight.FieldMap fieldMap)
      Publishes a shared field map on the "limelightshared" table. Flushes NetworkTables immediately. Publishing is only a NetworkTables write. All file IO and validation happened when the Limelight.FieldMap was created. While the shared map is not empty, every Limelight on the network localizes with it instead of its uploaded map.
      Parameters:
      fieldMap - The field map to publish. The method ignores null or a field map that is not valid and prints a warning
    • clearSharedMap

      public static void clearSharedMap()
      Clears the shared field map. Flushes NetworkTables immediately. Every Limelight on the network returns to its own uploaded map.
    • setPriorityTagIDOverride

      public void setPriorityTagIDOverride(int id)
      Sets the priority AprilTag ID for tx/ty targeting.
      Parameters:
      id - Priority tag ID
    • clearPriorityTagIDOverride

      public void clearPriorityTagIDOverride()
      Clears the priority AprilTag ID override. tx/ty targeting returns to the target selection of the pipeline.
    • setLEDMode

      public void setLEDMode(Limelight.LEDMode mode)
      Sets the LED behavior.
    • setCropWindowOverride

      public void setCropWindowOverride(double cropXMin, double cropXMax, double cropYMin, double cropYMax)
      Sets the crop window. The crop window in the web interface must be fully open (as large as possible).
      Parameters:
      cropXMin - 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)
    • clearCropWindowOverride

      public void clearCropWindowOverride()
      Clears the crop window override, returning to the full image.
    • setKeystoneOverride

      public void setKeystoneOverride(double horizontal, double vertical)
      Sets the keystone modification for the crop window.
      Parameters:
      horizontal - Horizontal keystone value (-0.95 to 0.95)
      vertical - Vertical keystone value (-0.95 to 0.95)
    • clearKeystoneOverride

      public void clearKeystoneOverride()
      Clears the keystone override.
    • setFiducial3DOffsetOverride

      public void setFiducial3DOffsetOverride(double forward, double left, double up)
      Moves the 3D targeting point away from the center of the primary in-view fiducial. The offset is in target space (the coordinate system of the target: x = forward, y = left, z = up).
      Parameters:
      forward - Forward (x) offset from the target in meters
      left - Left (y) offset from the target in meters
      up - Up (z) offset from the target in meters
    • setFiducial3DOffsetOverride

      public void setFiducial3DOffsetOverride(org.wpilib.math.geometry.Translation3d offset)
      Moves the 3D targeting point away from the center of the primary in-view fiducial. The offset is in target space (the coordinate system of the target). Same as setFiducial3DOffsetOverride(double, double, double) with a Translation3d.
      Parameters:
      offset - Offset from the target in meters (x = forward, y = left, z = up). Null is ignored
    • clearFiducial3DOffsetOverride

      public void clearFiducial3DOffsetOverride()
      Clears the fiducial 3D offset override. The 3D targeting point returns to the center of the primary in-view fiducial.
    • setRobotOrientation

      public void setRobotOrientation(double yawDegrees, boolean flush)
      (ADVANCED) Sets the individual robot orientation of this camera for the MegaTag2 algorithm. Call this every loop. Most robots should use setSharedRobotOrientation(double) instead. It updates every camera at one time.

      Every call makes this camera ignore the shared orientation from setSharedRobotOrientation(double). Use setUseSharedOrientation(boolean) to make it use the shared orientation again.

      Parameters:
      yawDegrees - Robot yaw in degrees.
      flush - True to flush NetworkTables immediately. Pass false when you update several cameras in one loop. Then call flushNT() one time.
    • setRobotOrientation

      public void setRobotOrientation(double yaw, double yawRate, double pitch, double pitchRate, double roll, double rollRate, boolean flush)
      (ADVANCED) Sets the full individual robot orientation of this camera for the MegaTag2 algorithm. Every call makes this camera ignore the shared orientation (see setUseSharedOrientation(boolean)).
      Parameters:
      yaw - Robot yaw in degrees.
      yawRate - (optional, may be 0) Angular velocity of robot yaw in degrees per second
      pitch - (optional, may be 0) Robot pitch in degrees
      pitchRate - (optional, may be 0) Angular velocity of robot pitch in degrees per second
      roll - (optional, may be 0) Robot roll in degrees
      rollRate - (optional, may be 0) Angular velocity of robot roll in degrees per second
      flush - True to flush NetworkTables immediately. Pass false when you update several cameras in one loop. Then call flushNT() one time.
    • setUseSharedOrientation

      public void setUseSharedOrientation(boolean useShared)
      (ADVANCED) Controls whether this camera reads the shared orientation from setSharedRobotOrientation(double). Every setRobotOrientation(double, boolean) call makes the camera ignore the shared orientation. Call this method with true to use the shared orientation again. For example, call setRobotOrientation(double, boolean) one time to seed the camera. Then let the shared orientation drive MegaTag2.
      Parameters:
      useShared - True to follow the shared orientation. False to use only the individual orientation of this camera
    • setSharedRobotOrientation

      public static void setSharedRobotOrientation(double yawDegrees)
      Sets the robot orientation for MegaTag2 on the shared "limelightshared" table. Flushes NetworkTables immediately. Every Limelight on the network reads this table. One call updates all cameras. You do not need to call setRobotOrientation(double, boolean) for each instance.

      Each camera follows this shared orientation unless it was opted out. Every setRobotOrientation(double, boolean) call opts a camera out (see setUseSharedOrientation(boolean)). For example, a turret camera can use its own orientation while every other camera follows the shared value.

      Parameters:
      yawDegrees - Robot yaw in degrees.
    • setSharedRobotOrientation

      public static void setSharedRobotOrientation(double yaw, double yawRate, double pitch, double pitchRate, double roll, double rollRate)
      Sets the full shared robot orientation for MegaTag2 on the "limelightshared" table. Flushes NetworkTables immediately. Each camera follows this shared orientation unless it was opted out with setRobotOrientation(double, boolean) or setUseSharedOrientation(boolean).
      Parameters:
      yaw - Robot yaw in degrees.
      yawRate - (optional, may be 0) Angular velocity of robot yaw in degrees per second
      pitch - (optional, may be 0) Robot pitch in degrees
      pitchRate - (optional, may be 0) Angular velocity of robot pitch in degrees per second
      roll - (optional, may be 0) Robot roll in degrees
      rollRate - (optional, may be 0) Angular velocity of robot roll in degrees per second
    • setIMUMode

      public void setIMUMode(Limelight.IMUMode mode)
      Configures the robot-yaw source for MegaTag2 localization.
    • setIMUAssistAlpha

      public void setIMUAssistAlpha(double alpha)
      Configures the complementary filter alpha for the IMU assist modes (modes 3 and 4).
      Parameters:
      alpha - Default .001. Higher values converge on the assist source faster.
    • setThrottle

      public void setThrottle(int throttle)
      Configures the throttle value. The Limelight skips throttle frames between processed frames. Set 100-200 while the robot is disabled to reduce heat. Use withStaleFrameThreshold(double) with this so getStatus() does not report the camera as stale.
      Parameters:
      throttle - Default 0. The camera processes one frame, then skips this many frames.
    • setFiducialIDFiltersOverride

      public void setFiducialIDFiltersOverride(int[] validIDs)
      Overrides the valid AprilTag IDs for localization. Tags not in this list are ignored for robot pose estimation. They do not get the "fielded" flag.
      Parameters:
      validIDs - Valid AprilTag IDs to track
    • clearFiducialIDFiltersOverride

      public void clearFiducialIDFiltersOverride()
      Clears the AprilTag ID filter override. The camera returns to the ID filters of the pipeline.
    • setFiducialDownscalingOverride

      public void setFiducialDownscalingOverride(Limelight.DownscaleOverride downscale)
      Overrides the AprilTag detector's downscaling factor.
    • clearFiducialDownscalingOverride

      public void clearFiducialDownscalingOverride()
      Clears the AprilTag downscaling override. The camera returns to the downscale configured in the current pipeline.
    • setCameraPose_RobotSpaceOverride

      public void setCameraPose_RobotSpaceOverride(double forward, double left, double up, double roll, double pitch, double yaw, boolean flush)
      Sets the camera pose relative to the robot. You can call this every loop. Use it to track a camera on a moving mechanism (elevator, turret). An all-zero pose is the clear value, so the camera returns to the pose from the web interface.
      Parameters:
      forward - Forward (x) offset in meters
      left - Left (y) offset in meters
      up - Up (z) offset in meters
      roll - Roll angle in degrees
      pitch - Pitch angle in degrees
      yaw - Yaw angle in degrees
      flush - True to flush NetworkTables immediately. Pass false when you update several cameras in one loop. Then call flushNT() one time.
    • setCameraPose_RobotSpaceOverride

      public void setCameraPose_RobotSpaceOverride(org.wpilib.math.geometry.Pose3d cameraPoseRobotSpace, boolean flush)
      Sets the camera pose relative to the robot. The camera applies updates live. See setCameraPose_RobotSpaceOverride(double, double, double, double, double, double, boolean).
      Parameters:
      cameraPoseRobotSpace - The pose of the camera relative to the robot center (x = forward, y = left, z = up, in meters). Null is ignored. An all-zero pose is the clear value
      flush - True to flush NetworkTables immediately. Pass false when you update several cameras in one loop. Then call flushNT() one time.
    • clearCameraPose_RobotSpaceOverride

      public void clearCameraPose_RobotSpaceOverride()
      Clears the camera pose override. Flushes NetworkTables immediately. The camera returns to the camera pose configured in its web interface.
    • setPythonScriptData

      public void setPythonScriptData(double[] outgoingPythonData)
      Sends data to a running python snapscript via llrobot.
    • triggerSnapshot

      public void triggerSnapshot()
      Triggers a snapshot capture. The Limelight firmware rate-limits this.
    • setRewindEnabled

      public void setRewindEnabled(boolean enabled)
      Enables or pauses the rewind buffer recording.
      Parameters:
      enabled - True to enable recording. False to pause. Default true on supported platforms.
    • triggerRewindCapture

      public void triggerRewindCapture(double durationSeconds)
      Triggers a rewind capture with the given duration. The maximum duration is 165 seconds. The camera rate-limits this.
      Parameters:
      durationSeconds - Duration of the rewind capture in seconds (maximum 165)
    • flushNT

      public static void flushNT()
      Flushes NetworkTables immediately. These methods call it automatically: the pose-setting constructors, setSharedRobotOrientation(double), setPipelineConfigurationOverride(Limelight.PipelineConfiguration), clearPipelineConfigurationOverride(), setSharedMap(Limelight.FieldMap), clearSharedMap(), clearCameraPose_RobotSpaceOverride(), and setRobotOrientation(double, boolean) / setCameraPose_RobotSpaceOverride(double, double, double, double, double, double, boolean) when their flush argument is true. The other setters and clear methods do not flush. Call it yourself after a group of them.
    • toPose3D

      public static org.wpilib.math.geometry.Pose3d toPose3D(double[] inData)
      Converts a pose array to a Pose3d. The array has 6 values: [x, y, z, roll, pitch, yaw]. Units are meters and degrees.
      Returns:
      The pose. Returns an empty Pose3d if the array is not valid
    • toPose2D

      public static org.wpilib.math.geometry.Pose2d toPose2D(double[] inData)
      Converts a pose array to a Pose2d. The array has 6 values: [x, y, z, roll, pitch, yaw]. Units are meters and degrees. Uses only the x, y, and yaw values.
      Returns:
      The pose. Returns an empty Pose2d if the array is not valid