Package swervelib.parser
Class SwerveParser
java.lang.Object
swervelib.parser.SwerveParser
Helper class used to parse the JSON directory with specified configuration options.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic ControllerPropertiesJsonParsed controllerproperties.jsonModule number mapped to the JSON name.static ModuleJson[]Array holding the module jsons given inSwerveDriveJson.static PhysicalPropertiesJsonParsed modules/physicalproperties.jsonstatic PIDFPropertiesJsonParsed modules/pidfproperties.jsonstatic SwerveDriveJsonParsed swervedrive.json -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidcheckDirectory(File directory) Check directory structure.createSwerveDrive(double maxSpeed) CreateSwerveDrivefrom JSON configuration directory.createSwerveDrive(double maxSpeed, double angleMotorConversionFactor, double driveMotorConversion) CreateSwerveDrivefrom JSON configuration directory.createSwerveDrive(edu.wpi.first.math.controller.SimpleMotorFeedforward driveFeedforward, double maxSpeed) CreateSwerveDrivefrom JSON configuration directory.createSwerveDrive(edu.wpi.first.math.controller.SimpleMotorFeedforward driveFeedforward, double maxSpeed, double angleMotorConversionFactor, double driveMotorConversion) CreateSwerveDrivefrom JSON configuration directory.static SwerveModulegetModuleConfigurationByName(String name, SwerveDriveConfiguration driveConfiguration) Get the swerve module by the json name.private com.fasterxml.jackson.databind.JsonNodeOpen JSON file.
-
Field Details
-
moduleConfigs
Module number mapped to the JSON name. -
swerveDriveJson
Parsed swervedrive.json -
controllerPropertiesJson
Parsed controllerproperties.json -
pidfPropertiesJson
Parsed modules/pidfproperties.json -
physicalPropertiesJson
Parsed modules/physicalproperties.json -
moduleJsons
Array holding the module jsons given inSwerveDriveJson.
-
-
Constructor Details
-
SwerveParser
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-SwerveDriveConfigurationto pull from.- Returns:
SwerveModuleConfigurationbased on the file.
-
openJson
Open JSON file.- Parameters:
file- JSON File to open.- Returns:
- JsonNode of file.
-
checkDirectory
Check directory structure.- Parameters:
directory- JSON Configuration Directory
-
createSwerveDrive
CreateSwerveDrivefrom JSON configuration directory.- Parameters:
maxSpeed- Maximum speed of the robot in meters per second, used for both angular acceleration used inSwerveControllerand drive feedforward inSwerveMath.createDriveFeedforward(double, double, double).- Returns:
SwerveDriveinstance.
-
createSwerveDrive
public SwerveDrive createSwerveDrive(double maxSpeed, double angleMotorConversionFactor, double driveMotorConversion) CreateSwerveDrivefrom JSON configuration directory.- Parameters:
maxSpeed- Maximum speed of the robot in meters per second, used for both angular acceleration used inSwerveControllerand drive feedforward inSwerveMath.createDriveFeedforward(double, double, double).angleMotorConversionFactor- Angle (AKA azimuth) motor conversion factor to convert motor controller PID loop units to degrees, usually created usingSwerveMath.calculateDegreesPerSteeringRotation(double, double).driveMotorConversion- Drive motor conversion factor to convert motor controller PID loop units to meters per rotation, usually created usingSwerveMath.calculateMetersPerRotation(double, double, double).- Returns:
SwerveDriveinstance.
-
createSwerveDrive
public SwerveDrive createSwerveDrive(edu.wpi.first.math.controller.SimpleMotorFeedforward driveFeedforward, double maxSpeed, double angleMotorConversionFactor, double driveMotorConversion) CreateSwerveDrivefrom JSON configuration directory.- Parameters:
driveFeedforward- Drive feedforward to use for swerve modules, should be created usingSwerveMath.createDriveFeedforward(double, double, double).maxSpeed- Maximum speed of the robot in meters per second for normal+angular acceleration inSwerveControllerof the robot.angleMotorConversionFactor- Angle (AKA azimuth) motor conversion factor to convert motor controller PID loop units to degrees, usually created usingSwerveMath.calculateDegreesPerSteeringRotation(double, double).driveMotorConversion- Drive motor conversion factor to convert motor controller PID loop units to meters per rotation, usually created usingSwerveMath.calculateMetersPerRotation(double, double, double).- Returns:
SwerveDriveinstance.
-
createSwerveDrive
public SwerveDrive createSwerveDrive(edu.wpi.first.math.controller.SimpleMotorFeedforward driveFeedforward, double maxSpeed) CreateSwerveDrivefrom JSON configuration directory.- Parameters:
driveFeedforward- Drive feedforward to use for swerve modules, should be created usingSwerveMath.createDriveFeedforward(double, double, double).maxSpeed- Maximum speed of the robot in meters per second for normal+angular acceleration inSwerveControllerof the robot- Returns:
SwerveDriveinstance.
-