Class JsonUtilities

java.lang.Object
io.github.roboblazers7617.limelight.JsonUtilities

public class JsonUtilities extends Object
Utilities for working with Limelight JSON outputs.
  • Constructor Details

    • JsonUtilities

      public JsonUtilities()
  • Method Details

    • 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].
    • 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 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

      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.
      Parameters:
      pose - The Pose2d object to convert
      Returns:
      A 6-element array containing [x, y, 0, 0, 0, yaw].
      API Note:
      z, roll, and pitch will be 0 since Pose2d only contains x, y, and yaw.
    • extractArrayEntry

      public static double extractArrayEntry(double[] inData, int position)
      Gets the data from a double array at the given index.
      Parameters:
      inData - The array to read from.
      position - The index to read from.
      Returns:
      The data at that index, or 0 if outside array.