Package swervelib.parser.json
Class DeviceJson
java.lang.Object
swervelib.parser.json.DeviceJson
Device JSON parsed class. Used to access the JSON data.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateEncoder(SwerveMotor motor) Create aSwerveAbsoluteEncoderfrom the current configuration.Create aSwerveIMUfrom the given configuration.Create aSwerveAbsoluteEncoderfrom the data port on the motor controller.createMotor(boolean isDriveMotor) Create aSwerveMotorfrom the given configuration.intgetPulsePerRotation(int angleEncoderPulsePerRotation) Get the encoder pulse per rotation based off of the encoder type.
-
Field Details
-
type
The device type, e.g. pigeon/pigeon2/sparkmax/talonfx/navx -
id
public int idThe CAN ID or pin ID of the device. -
canbus
The CAN bus name which the device resides on if using CAN.
-
-
Constructor Details
-
DeviceJson
public DeviceJson()
-
-
Method Details
-
createEncoder
Create aSwerveAbsoluteEncoderfrom the current configuration.- Parameters:
motor-SwerveMotorof which attached encoders will be created from, only used when the type is "attached" or "canandencoder".- Returns:
SwerveAbsoluteEncodergiven.
-
createIMU
Create aSwerveIMUfrom the given configuration.- Returns:
SwerveIMUgiven.
-
createMotor
Create aSwerveMotorfrom the given configuration.- Parameters:
isDriveMotor- If the motor being generated is a drive motor.- Returns:
SwerveMotorgiven.
-
createIntegratedEncoder
Create aSwerveAbsoluteEncoderfrom the data port on the motor controller.- Parameters:
motor- The motor to create the absolute encoder from.- Returns:
SwerveAbsoluteEncoderfrom the motor controller.
-
getPulsePerRotation
public int getPulsePerRotation(int angleEncoderPulsePerRotation) Get the encoder pulse per rotation based off of the encoder type.- Parameters:
angleEncoderPulsePerRotation- The configured pulse per rotation.- Returns:
- The correct pulse per rotation based off of the encoder type.
-