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
Modifier and TypeFieldDescriptionstatic ControllerPropertiesJson
Parsed controllerproperties.jsonstatic ModuleJson[]
Array holding the module jsons given inSwerveDriveJson
.static PhysicalPropertiesJson
Parsed modules/physicalproperties.jsonstatic PIDFPropertiesJson
Parsed modules/pidfproperties.jsonstatic SwerveDriveJson
Parsed swervedrive.json -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncreateSwerveDrive
(double maxSpeed) CreateSwerveDrive
from JSON configuration directory.createSwerveDrive
(double maxSpeed, double angleMotorConversionFactor, double driveMotorConversion) CreateSwerveDrive
from JSON configuration directory.createSwerveDrive
(SimpleMotorFeedforward driveFeedforward, double maxSpeed) CreateSwerveDrive
from JSON configuration directory.createSwerveDrive
(SimpleMotorFeedforward driveFeedforward, double maxSpeed, double angleMotorConversionFactor, double driveMotorConversion) CreateSwerveDrive
from JSON configuration directory.static SwerveModule
getModuleConfigurationByName
(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
-SwerveDriveConfiguration
to pull from.- Returns:
SwerveModuleConfiguration
based on the file.
-
createSwerveDrive
CreateSwerveDrive
from JSON configuration directory.- Parameters:
maxSpeed
- Maximum speed of the robot in meters per second, used for both angular acceleration used inSwerveController
and drive feedforward inSwerveMath.createDriveFeedforward(double, double, double)
.- Returns:
SwerveDrive
instance.
-
createSwerveDrive
public SwerveDrive createSwerveDrive(double maxSpeed, double angleMotorConversionFactor, double driveMotorConversion) CreateSwerveDrive
from JSON configuration directory.- Parameters:
maxSpeed
- Maximum speed of the robot in meters per second, used for both angular acceleration used inSwerveController
and 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:
SwerveDrive
instance.
-
createSwerveDrive
public SwerveDrive createSwerveDrive(SimpleMotorFeedforward driveFeedforward, double maxSpeed, double angleMotorConversionFactor, double driveMotorConversion) CreateSwerveDrive
from 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 inSwerveController
of 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:
SwerveDrive
instance.
-
createSwerveDrive
CreateSwerveDrive
from 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 inSwerveController
of the robot- Returns:
SwerveDrive
instance.
-