Class AutonUtil

java.lang.Object
com.stuypulse.robot.util.auton.AutonUtil

public final class AutonUtil extends Object

AutonUtil

Shared utilities for discovering and comparing autonomous path names.
  • Constructor Details

  • Method Details

    • getPathFileNames

      public static List<String> getPathFileNames(AutonUtil.AutonType autonType)
      Lists the available path names for an autonomous format.
      Parameters:
      autonType - The auton type to search for determining which auton directory and file extension to search
      Returns:
      Sorted path names without their file extensions. Returns an empty list if the directory cannot be read, in which case an error is reported to the Driver Station
    • findClosestMatch

      public static String findClosestMatch(List<String> paths, String input)
      Finds the listed path name with the smallest character-based distance from an input.
      Parameters:
      paths - The possible path names to compare
      input - The path name to match
      Returns:
      The closest candidate, or an empty string when no candidate is selected
    • countChars

      public static HashMap<Character, Integer> countChars(char[] chars)
      Counts the occurrences of each character in an array.

      This is mainly used for findClosestMatch(List, String).

      Parameters:
      chars - Characters to count
      Returns:
      A map from each encountered character to its amount of occurences
    • compareNameProximity

      public static double compareNameProximity(HashMap<Character, Integer> list1, HashMap<Character, Integer> list2)
      Computes a character-count distance between two names.

      Smaller values indicate closer names, while larger values indicate more distant names.

      This is mainly used for findClosestMatch(List, String).

      Parameters:
      list1 - Character counts for the first name
      list2 - Character counts for the second name
      Returns:
      The calculated distance between the names