Class DeviceJson

java.lang.Object
swervelib.parser.json.DeviceJson

public class DeviceJson extends Object
Device JSON parsed class. Used to access the JSON data.
  • Field Details

    • type

      public String type
      The device type, e.g. pigeon/pigeon2/sparkmax/talonfx/navx
    • id

      public int id
      The CAN ID or pin ID of the device.
    • canbus

      public String canbus
      The CAN bus name which the device resides on if using CAN.
  • Constructor Details

    • DeviceJson

      public DeviceJson()
  • Method Details

    • createEncoder

      public SwerveAbsoluteEncoder createEncoder(SwerveMotor motor)
      Create a SwerveAbsoluteEncoder from the current configuration.
      Parameters:
      motor - SwerveMotor of which attached encoders will be created from, only used when the type is "attached" or "canandencoder".
      Returns:
      SwerveAbsoluteEncoder given.
    • createIMU

      public SwerveIMU createIMU()
      Create a SwerveIMU from the given configuration.
      Returns:
      SwerveIMU given.
    • createMotor

      public SwerveMotor createMotor(boolean isDriveMotor)
      Create a SwerveMotor from the given configuration.
      Parameters:
      isDriveMotor - If the motor being generated is a drive motor.
      Returns:
      SwerveMotor given.
    • createIntegratedEncoder

      public SwerveAbsoluteEncoder createIntegratedEncoder(SwerveMotor motor)
      Create a SwerveAbsoluteEncoder from the data port on the motor controller.
      Parameters:
      motor - The motor to create the absolute encoder from.
      Returns:
      SwerveAbsoluteEncoder from 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.