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.jsonstatic 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 TypeMethodDescriptioncreateSwerveDrive(double maxSpeed) CreateSwerveDrivefrom JSON configuration directory.createSwerveDrive(double maxSpeed, double angleMotorConversionFactor, double driveMotorConversion) CreateSwerveDrivefrom JSON configuration directory.createSwerveDrive(double maxSpeed, Pose2d initialPose) CreateSwerveDrivefrom JSON configuration directory.static SwerveModulegetModuleConfigurationByName(String name, SwerveDriveConfiguration driveConfiguration) Get the swerve module by the json name.
-
Field Details
-
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.
-
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
CreateSwerveDrivefrom JSON configuration directory.- Parameters:
maxSpeed- Maximum speed of the robot in meters per second for normal+angular acceleration inSwerveControllerof the robotinitialPose-Pose2dinitial pose.- Returns:
SwerveDriveinstance.
-