Class CANMotorConfig


  • public class CANMotorConfig
    extends java.lang.Object
    CANMotorConfig packages together the CAN IDs of motors and if they should be inverted or not. Before, these used to be stray values that would be managed independently of each other, but keeping them grouped makes it a bit easier to reason about.
    See Also:
    Spark Max CAN Documentation, CTRE CAN Documentation
    • Field Summary

      Fields 
      Modifier and Type Field Description
      int kCANBusID
      The CAN bus ID of the motor
      MotorIdleMode kIdleMode
      Determines the default idle mode of the motor; if it should be braking or coasting
      boolean kIsInverted
      If the motor power output should be inverted or not
    • Constructor Summary

      Constructors 
      Constructor Description
      CANMotorConfig​(int canBusID, boolean isInverted)
      Create a new CAN bus motor configuration with brake mode enabled by default
      CANMotorConfig​(int canBusID, boolean isInverted, MotorIdleMode idleMode)
      Create a new CAN bus motor configuration with brake mode enabled by default
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      com.revrobotics.CANSparkMax toSparkMaxBrushless()
      Converts the CAN motor config into a Spark Max controlling a brushless motor, such as a Neo or Neo 550
      com.ctre.phoenix.motorcontrol.can.TalonSRX toTalonSRX()
      Converts the CAN motor config into a Talon SRX controlling a brushed motor, such as a CIM, 775, or Redline.
      com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX toWPITalonSRX()
      Converts the CAN motor config into a Talon SRX controlling a brushed motor, such as a CIM, 775, or Redline.
      com.revrobotics.CANSparkMax UNSAFE_toSparkMaxBrushed()
      Converts the CAN motor config into a Spark Max controlling a brushed motor, such as a CIM, 775, or Redline.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • kCANBusID

        public final int kCANBusID
        The CAN bus ID of the motor
      • kIsInverted

        public final boolean kIsInverted
        If the motor power output should be inverted or not
      • kIdleMode

        public final MotorIdleMode kIdleMode
        Determines the default idle mode of the motor; if it should be braking or coasting
    • Constructor Detail

      • CANMotorConfig

        public CANMotorConfig​(int canBusID,
                              boolean isInverted)
        Create a new CAN bus motor configuration with brake mode enabled by default
        Parameters:
        canBusID - the CAN bus ID number to use
        isInverted - if the motor output should be inverted or not
      • CANMotorConfig

        public CANMotorConfig​(int canBusID,
                              boolean isInverted,
                              MotorIdleMode idleMode)
        Create a new CAN bus motor configuration with brake mode enabled by default
        Parameters:
        canBusID - the CAN bus ID number to use
        isInverted - if the motor output should be inverted or not
        idleMode - the desired idle mode of the motor; either brake or coasting
    • Method Detail

      • toSparkMaxBrushless

        public com.revrobotics.CANSparkMax toSparkMaxBrushless()
        Converts the CAN motor config into a Spark Max controlling a brushless motor, such as a Neo or Neo 550
        Returns:
        a Spark Max abstracted motor controller
      • UNSAFE_toSparkMaxBrushed

        public com.revrobotics.CANSparkMax UNSAFE_toSparkMaxBrushed()
        Converts the CAN motor config into a Spark Max controlling a brushed motor, such as a CIM, 775, or Redline. This is very uncommon as we would usually use a Talon SRX for those motors
        Returns:
        a Spark Max abstracted motor controller
      • toTalonSRX

        public com.ctre.phoenix.motorcontrol.can.TalonSRX toTalonSRX()
        Converts the CAN motor config into a Talon SRX controlling a brushed motor, such as a CIM, 775, or Redline.
        Returns:
        a Talon SRX abstracted motor controller
      • toWPITalonSRX

        public com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX toWPITalonSRX()
        Converts the CAN motor config into a Talon SRX controlling a brushed motor, such as a CIM, 775, or Redline.
        Returns:
        a Talon SRX abstracted motor controller