Class SwerveParser

java.lang.Object
swervelib.parser.SwerveParser

public class SwerveParser extends Object
Helper class used to parse the JSON directory with specified configuration options.
  • Field Details

    • moduleConfigs

      private static final HashMap<String,Integer> moduleConfigs
      Module number mapped to the JSON name.
    • swerveDriveJson

      public static SwerveDriveJson swerveDriveJson
      Parsed swervedrive.json
    • controllerPropertiesJson

      public static ControllerPropertiesJson controllerPropertiesJson
      Parsed controllerproperties.json
    • pidfPropertiesJson

      public static PIDFPropertiesJson pidfPropertiesJson
      Parsed modules/pidfproperties.json
    • physicalPropertiesJson

      public static PhysicalPropertiesJson physicalPropertiesJson
      Parsed modules/physicalproperties.json
    • moduleJsons

      public static ModuleJson[] moduleJsons
      Array holding the module jsons given in SwerveDriveJson.
  • Constructor Details

    • SwerveParser

      public SwerveParser(File directory) throws IOException
      Construct a swerve parser. Will throw an error if there is a missing file.
      Parameters:
      directory - Directory with swerve configurations.
      Throws:
      IOException - if a file doesn't exist.
  • Method Details

    • getModuleConfigurationByName

      public static SwerveModule getModuleConfigurationByName(String name, SwerveDriveConfiguration driveConfiguration)
      Get the swerve module by the json name.
      Parameters:
      name - JSON name.
      driveConfiguration - SwerveDriveConfiguration to pull from.
      Returns:
      SwerveModuleConfiguration based on the file.
    • openJson

      private com.fasterxml.jackson.databind.JsonNode openJson(File file)
      Open JSON file.
      Parameters:
      file - JSON File to open.
      Returns:
      JsonNode of file.
    • checkDirectory

      private void checkDirectory(File directory)
      Check directory structure.
      Parameters:
      directory - JSON Configuration Directory
    • createSwerveDrive

      public SwerveDrive createSwerveDrive()
      Create SwerveDrive from JSON configuration directory.
      Returns:
      SwerveDrive instance.