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
    • id

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

      public int channel
      SmartIO Channel.
    • canbus

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

    • DeviceJson

      public DeviceJson()
  • Method Details

    • getDCMotor

      public static DCMotor getDCMotor(String motorType)
      Get the DC motor from the motor type.
      Parameters:
      motorType - Motor type.
      Returns:
      DCMotor
    • getGyro

      public Pair<Supplier<Angle>,Object> getGyro(SwerveDriveJson.GyroAxis axis, boolean inverted)
      Get the gyro angle supplier.
      Parameters:
      axis - Gyro axis.
      inverted - Invert the gyro angle.
      Returns:
      Supplier of Angle, or null if the gyro type is "custom" and the user is expected to configure the gyro themselves.
    • getVendor

      public DeviceJson.VENDOR getVendor(DeviceJson.VENDOR attachedType)
      Get the vendor of the device.
      Parameters:
      attachedType - Vendor to return when the device is directly attached (not on CAN/DIO/Analog), since the attached vendor cannot be determined from the device type string alone.
      Returns:
      Vendor of the device.
    • getMotorController

      public ReflectionsManager.VendorMotorController getMotorController()
      Get the ReflectionsManager.VendorMotorController object for the device.
      Returns:
      ReflectionsManager.VendorMotorController object for the device.
    • getAbsoluteEncoder

      public Pair<Supplier<Angle>,Object> getAbsoluteEncoder(ReflectionsManager.VendorMotorController angleMotorVendor, yams.motorcontrollers.SmartMotorController angleMotorController, boolean inverted)
      Get the Absolute Encoder Supplier and Vendor Absolute Encoder Object.
      Parameters:
      angleMotorVendor - Vendor of the angle/steering/azimuth motor controller, used when the absolute encoder is attached to the angle motor controller.
      angleMotorController - Angle/steering/azimuth SmartMotorController, used when the absolute encoder is attached to the angle motor controller.
      inverted - Inversion of the absolute encoder.
      Returns:
      Pair of Supplier and Vendor Absolute Encoder Object
    • getSmartMotorController

      public yams.motorcontrollers.SmartMotorController getSmartMotorController(yams.motorcontrollers.SmartMotorControllerConfig config)
      Get the SmartMotorController from the DeviceJson when given the SmartMotorControllerConfig.
      Parameters:
      config - SmartMotorControllerConfig to apply when creating SmartMotorController.
      Returns:
      SmartMotorController