Class LimelightUtils

java.lang.Object
limelight.networktables.LimelightUtils

public class LimelightUtils extends Object
Utility classes to convert WPILib data to LimelightLib expected values.
  • Constructor Details

    • LimelightUtils

      public LimelightUtils()
  • Method Details

    • sanitizeName

      public static final String sanitizeName(String name)
      Sanitize the Limelight name
      Parameters:
      name - Limelight name
      Returns:
      Limelight.limelightName or "limelight"
    • getLimelightURLString

      public static URL getLimelightURLString(String tableName, String request)
      Get the URL for the limelight.
      Parameters:
      tableName - Limelight.limelightName
      request - URI to request from Limelight
      Returns:
      URL to request for Limelight
    • toPose3D

      public static Pose3d toPose3D(double[] inData)
      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

      public static Pose2d toPose2D(double[] inData)
      Takes a 6-length array of Pose2d 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
    • toTranslation3d

      public static Translation3d toTranslation3d(double[] translation)
      Takes a 3-length array of Translation3d data and converts it into a Translation3d. Array format: [x, y, z]
      Parameters:
      translation - Array containing translation data [x, y, z] in Meters.
      Returns:
      Translation3d to set.
    • toOrientation

      public static Orientation3d toOrientation(double[] orientation)
      Takes a 6-length array of Orientation3d data and converts it into a Orientation3d. Array format: [yaw,yawrate,pitch,pitchrate,roll,rollrate]
      Parameters:
      orientation - Array containing Orientation3d [yaw,yawrate,pitch,pitchrate,roll,rollrate] in Degrees.
      Returns:
      Orientation3d
    • orientation3dToArray

      public static double[] orientation3dToArray(Orientation3d orientation)
      Converts an Orientation3d to a 6-length array of [yaw,yawrate,pitch,pitchrate,roll,rollrate] in Degrees.
      Parameters:
      orientation - Orientation3d to convert.
      Returns:
      Array [yaw,yawrate,pitch,pitchrate,roll,rollrate] in Degrees.
    • pose3dToArray

      public static double[] pose3dToArray(Pose3d pose)
      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

      public static double[] pose2dToArray(Pose2d pose)
      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]
    • translation3dToArray

      public static double[] translation3dToArray(Translation3d translation)
      Converts a Translation3d object to an array of doubles in format [x, y, z]. Measurements are in Meters.
      Parameters:
      translation - Translation3d to convert.
      Returns:
      Double array containing [x, y, z]
    • extractArrayEntry

      public static double extractArrayEntry(double[] inData, int position)
      Return a double from a double array if it exists, else return 0.
      Parameters:
      inData - Double array to extract from
      position - Position to read
      Returns:
      0 if data isn't present, else the double.