Class LimelightWrapper

java.lang.Object
yall.VisionCamera
yall.cameras.LimelightWrapper
All Implemented Interfaces:
AutoCloseable

public class LimelightWrapper extends VisionCamera
A Limelight, through LimelightLib 2.

Pose estimates are MegaTag1 for PoseEstimationMode.TAGS_ONLY and MegaTag2 for PoseEstimationMode.HEADING_ASSISTED, in WPILib blue-origin coordinates. The config's robot-to-camera transform, if set, overrides the camera pose from the Limelight web interface.

Vendor configs accepted by VisionCameraConfig.withVendorConfig(Object):

  • PoseEstimateConfig: Limelight's own pose filter and standard deviations replace YALL's VisionPoseFilter for this camera.
  • PipelineConfiguration: applied as a pipeline override.

Without a camera model in the config, it is simulated as a CameraModel.LIMELIGHT_4.

This wrapper reads Limelight.readResultsQueue(), so don't read any of the Limelight's queues elsewhere: each frame is handed out only once.

  • Constructor Details

    • LimelightWrapper

      public LimelightWrapper(com.limelightvision.Limelight limelight, VisionCameraConfig config)
      Wraps a Limelight.
      Parameters:
      limelight - The Limelight.
      config - The camera's config.
  • Method Details

    • readFrames

      protected List<VisionFrame> readFrames()
      Description copied from class: VisionCamera
      Reads the frames the real camera produced since the last call. Call once per loop.
      Specified by:
      readFrames in class VisionCamera
      Returns:
      The frames, oldest first.
    • applyPipelineIndex

      protected void applyPipelineIndex(int index)
      Description copied from class: VisionCamera
      Switches the real camera's pipeline.
      Specified by:
      applyPipelineIndex in class VisionCamera
      Parameters:
      index - Pipeline index.
    • readPipelineIndex

      protected int readPipelineIndex()
      Description copied from class: VisionCamera
      Reads the real camera's pipeline.
      Specified by:
      readPipelineIndex in class VisionCamera
      Returns:
      Pipeline index.
    • readConnected

      protected boolean readConnected()
      Description copied from class: VisionCamera
      Whether the real camera is sending data.
      Specified by:
      readConnected in class VisionCamera
      Returns:
      true if connected.
    • applyRobotOrientation

      protected void applyRobotOrientation(double timestampSeconds, Rotation3d orientation, double yawRateDegreesPerSecond)
      Description copied from class: VisionCamera
      Passes the robot orientation to the real camera, for cameras that use it themselves.
      Overrides:
      applyRobotOrientation in class VisionCamera
      Parameters:
      timestampSeconds - When the orientation was measured.
      orientation - Robot orientation on the field.
      yawRateDegreesPerSecond - Yaw rate, or NaN if unknown.
    • applyRobotToCamera

      protected void applyRobotToCamera(Transform3d robotToCamera)
      Description copied from class: VisionCamera
      Passes a new camera position to the real camera, for cameras that use it themselves.
      Overrides:
      applyRobotToCamera in class VisionCamera
      Parameters:
      robotToCamera - Transform from the robot origin to the camera.
    • getCamera

      public com.limelightvision.Limelight getCamera()
      Description copied from class: VisionCamera
      The vendor's camera object, for settings YALL doesn't cover. Each wrapper narrows the return type to its vendor's class.
      Specified by:
      getCamera in class VisionCamera
      Returns:
      The vendor's camera object.
    • setRobotToCameraAndOrientation

      public void setRobotToCameraAndOrientation(Transform3d robotToCamera, Rotation3d orientation, AngularVelocity yawRate)
      Updates both a moving/turret-mounted camera's robot-to-camera transform and the robot's orientation in a single NetworkTables flush so MegaTag2 receives both values atomically.
      Parameters:
      robotToCamera - Current transform from the robot origin to the camera.
      orientation - Current robot orientation on the field: the yaw from your pose estimator, the roll and pitch from the gyro.
      yawRate - Current robot yaw rate.