Class SwerveParser


  • public class SwerveParser
    extends java.lang.Object
    Swerve Drive JSON parser.
    • Constructor Summary

      Constructors 
      Constructor Description
      SwerveParser()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      private static void checkDirectory​(java.io.File directory)
      Check directory structure.
      private static void checkMain​(com.fasterxml.jackson.databind.JsonNode mainJson)
      Check the main json for correct attributes.
      private static void checkModule​(com.fasterxml.jackson.databind.JsonNode moduleJson)
      Check module JSON config for existing values.
      private static java.lang.Object createEncoder​(com.fasterxml.jackson.databind.JsonNode encoderConfig)
      Create SwerveEncoder from JSON config.
      private static com.ctre.phoenix.sensors.WPI_Pigeon2 createGyro​(com.fasterxml.jackson.databind.JsonNode gyroConfig)
      Create the gyro object based off the configuration.
      private static SwerveModule<?,​?,​?> createModule​(com.fasterxml.jackson.databind.JsonNode mainJson, java.io.File moduleFile, SwerveModule.SwerveModuleLocation moduleLocation)
      Create SwerveModule from JSON configuration file.
      private static edu.wpi.first.wpilibj.motorcontrol.MotorController createMotor​(com.fasterxml.jackson.databind.JsonNode motorConfig)
      Create the motor controller based off the config.
      static SwerveDrive fromJSONDirectory​(java.io.File directory)
      Create SwerveDrive from JSON configuration directory.
      private static com.fasterxml.jackson.databind.JsonNode openJson​(java.io.File file)
      Open JSON file.
      private static void setModulePIDF​(SwerveMotor motor, com.fasterxml.jackson.databind.JsonNode jsonPIDF)
      Set the PIDF for the module if the given JSON has the paramters.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SwerveParser

        public SwerveParser()
    • Method Detail

      • openJson

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

        private static void checkDirectory​(java.io.File directory)
        Check directory structure.
        Parameters:
        directory - JSON Configuration Directory
      • createMotor

        private static edu.wpi.first.wpilibj.motorcontrol.MotorController createMotor​(com.fasterxml.jackson.databind.JsonNode motorConfig)
        Create the motor controller based off the config.
        Parameters:
        motorConfig - JSON Motor config object.
        Returns:
        Motor Controller
      • createEncoder

        private static java.lang.Object createEncoder​(com.fasterxml.jackson.databind.JsonNode encoderConfig)
        Create SwerveEncoder from JSON config.
        Parameters:
        encoderConfig - Swerve Encoder JSON config.
        Returns:
        SwerveEncoder
      • createGyro

        private static com.ctre.phoenix.sensors.WPI_Pigeon2 createGyro​(com.fasterxml.jackson.databind.JsonNode gyroConfig)
        Create the gyro object based off the configuration.
        Parameters:
        gyroConfig - Gyro configuration.
        Returns:
        Gyro object.
      • checkModule

        private static void checkModule​(com.fasterxml.jackson.databind.JsonNode moduleJson)
        Check module JSON config for existing values.
        Parameters:
        moduleJson - Module JSON object.
      • checkMain

        private static void checkMain​(com.fasterxml.jackson.databind.JsonNode mainJson)
        Check the main json for correct attributes.
        Parameters:
        mainJson - Main JSON.
      • createModule

        private static SwerveModule<?,​?,​?> createModule​(com.fasterxml.jackson.databind.JsonNode mainJson,
                                                                    java.io.File moduleFile,
                                                                    SwerveModule.SwerveModuleLocation moduleLocation)
        Create SwerveModule from JSON configuration file.
        Parameters:
        mainJson - Main JSON to pull from.
        moduleFile - Module specific JSON data to pull from.
        moduleLocation - Swerve module location that is being created.
        Returns:
        SwerveModule
      • setModulePIDF

        private static void setModulePIDF​(SwerveMotor motor,
                                          com.fasterxml.jackson.databind.JsonNode jsonPIDF)
        Set the PIDF for the module if the given JSON has the paramters.
        Parameters:
        motor - Motor to configure.
        jsonPIDF - JSON ndoe with values.
      • fromJSONDirectory

        public static SwerveDrive fromJSONDirectory​(java.io.File directory)
        Create SwerveDrive from JSON configuration directory.
        Parameters:
        directory - JSON Configuration directory.
        Returns:
        SwerveDrive