Class SwerveParser
- java.lang.Object
-
- frc.robot.subsystems.swervedrive2.swervelib.parser.SwerveParser
-
public class SwerveParser extends Object
Helper class used to parse the JSON directory with specified configuration options.
-
-
Field Summary
Fields Modifier and Type Field Description static ControllerPropertiesJsoncontrollerPropertiesJsonParsed controllerproperties.jsonprivate static HashMap<String,Integer>moduleConfigsstatic ModuleJson[]moduleJsonsArray holding the module jsons given inSwerveDriveJson.static PhysicalPropertiesJsonphysicalPropertiesJsonParsed modules/physicalproperties.jsonstatic PIDFPropertiesJsonpidfPropertiesJsonParsed modules/pidfproperties.jsonstatic SwerveDriveJsonswerveDriveJsonParsed swervedrive.json
-
Constructor Summary
Constructors Constructor Description SwerveParser(File directory)Construct a swerve parser.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidcheckDirectory(File directory)Check directory structure.SwerveDrivecreateSwerveDrive()CreateSwerveDrivefrom JSON configuration directory.static SwerveModulegetModuleConfigurationByName(String name, SwerveDriveConfiguration driveConfiguration)Get the swerve module by the json name.private com.fasterxml.jackson.databind.JsonNodeopenJson(File file)Open JSON file.
-
-
-
Field Detail
-
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 inSwerveDriveJson.
-
-
Constructor Detail
-
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
-
-
Method Detail
-
getModuleConfigurationByName
public static SwerveModule getModuleConfigurationByName(String name, SwerveDriveConfiguration driveConfiguration)
Get the swerve module by the json name.- Parameters:
name- JSON name.driveConfiguration-SwerveDriveConfigurationto pull from.- Returns:
SwerveModuleConfigurationbased 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()
CreateSwerveDrivefrom JSON configuration directory.- Returns:
SwerveDriveinstance.
-
-