Package swervelib.parser
Class SwerveParser
java.lang.Object
swervelib.parser.SwerveParser
Helper class used to parse the JSON directory with specified configuration
options.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordRaw hardware devices created bycreateSwerveDriveDevices(SwerveDriveConfig), alongside theSwerveDriveit built.static final recordRaw hardware devices created for a singleSwerveModulebySwerveParser. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic 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 TypeMethodDescriptionstatic yams.mechanisms.swerve.SwerveDrivecreateSwerveDrive(yams.mechanisms.config.SwerveDriveConfig swerveDriveConfig) Create aSwerveDrivefrom the parsed JSON configuration.createSwerveDriveDevices(yams.mechanisms.config.SwerveDriveConfig swerveDriveConfig) Create aSwerveDrivefrom the parsed JSON configuration, exposing the raw vendor hardware devices created along the way (drive/azimuth motor controllers, absolute encoders, and the gyro) alongside it.static SwerveParserParses a swerve configuration directory and creates aSwerveParsercontaining the parsed configuration.static voidparseDirectory(File directory)
-
Field Details
-
swerveDriveJson
Parsed swervedrive.json -
pidfPropertiesJson
Parsed modules/pidfproperties.json -
physicalPropertiesJson
Parsed modules/physicalproperties.json -
moduleJsons
Array holding the module jsons given inSwerveDriveJson.
-
-
Constructor Details
-
SwerveParser
public SwerveParser()Construct a swerve parser.
-
-
Method Details
-
parse
Parses a swerve configuration directory and creates aSwerveParsercontaining the parsed configuration.- Parameters:
directory- the directory containing the swerve configuration files- Returns:
- a
SwerveParsercontaining the parsed configuration - Throws:
UncheckedIOException- if the directory or any of its configuration files cannot be read
-
parseDirectory
- Throws:
IOException
-
createSwerveDrive
public static yams.mechanisms.swerve.SwerveDrive createSwerveDrive(yams.mechanisms.config.SwerveDriveConfig swerveDriveConfig) Create aSwerveDrivefrom the parsed JSON configuration.- Parameters:
swerveDriveConfig-SwerveDriveConfigto apply to the createdSwerveDrive.- Returns:
- Configured
SwerveDrive.
-
createSwerveDriveDevices
public static SwerveParser.SwerveDriveDevices createSwerveDriveDevices(yams.mechanisms.config.SwerveDriveConfig swerveDriveConfig) Create aSwerveDrivefrom the parsed JSON configuration, exposing the raw vendor hardware devices created along the way (drive/azimuth motor controllers, absolute encoders, and the gyro) alongside it. Useful when code needs direct access to a vendor device for configuration that isn't exposed throughSmartMotorController-- everything else should prefercreateSwerveDrive(SwerveDriveConfig).- Parameters:
swerveDriveConfig-SwerveDriveConfigto apply to the createdSwerveDrive.- Returns:
SwerveParser.SwerveDriveDevicescontaining the configuredSwerveDriveand every raw device created for it.
-