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

    • swerveDriveJson

      public static SwerveDriveJson swerveDriveJson
      Parsed swervedrive.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()
      Construct a swerve parser.
  • Method Details

    • parse

      public static SwerveParser parse(File directory)
      Parses a swerve configuration directory and creates a SwerveParser containing the parsed configuration.
      Parameters:
      directory - the directory containing the swerve configuration files
      Returns:
      a SwerveParser containing the parsed configuration
      Throws:
      UncheckedIOException - if the directory or any of its configuration files cannot be read
    • parseDirectory

      public static void parseDirectory(File directory) throws IOException
      Throws:
      IOException
    • createSwerveDrive

      public static yams.mechanisms.swerve.SwerveDrive createSwerveDrive(yams.mechanisms.config.SwerveDriveConfig swerveDriveConfig)
      Create a SwerveDrive from the parsed JSON configuration.
      Parameters:
      swerveDriveConfig - SwerveDriveConfig to apply to the created SwerveDrive.
      Returns:
      Configured SwerveDrive.
    • createSwerveDriveDevices

      public static SwerveParser.SwerveDriveDevices createSwerveDriveDevices(yams.mechanisms.config.SwerveDriveConfig swerveDriveConfig)
      Create a SwerveDrive from the parsed JSON configuration, exposing the raw vendor hardware devices created along the way (drive/azimuth motor controllers, absolute encoders, and the gyro) alongside it. Useful when code needs direct access to a vendor device for configuration that isn't exposed through SmartMotorController -- everything else should prefer createSwerveDrive(SwerveDriveConfig).
      Parameters:
      swerveDriveConfig - SwerveDriveConfig to apply to the created SwerveDrive.
      Returns:
      SwerveParser.SwerveDriveDevices containing the configured SwerveDrive and every raw device created for it.