Class TorqueNEO

java.lang.Object
org.texastorque.torquelib.motors.TorqueNEO

public final class TorqueNEO extends Object
Designed to be the one and only motor wrapper for 2023. This is a loose wrapper, designed only to: - organize the REVLib objects. - provide more distinct and consise get and set methods. - handle REVLib errors.
  • Field Details

    • motor

      public final com.revrobotics.CANSparkMax motor
      The internal components to the motor wrapper. These are marked public for a reason. Since they are marked final their reference cannot be set from outside, but they can be accessed and mutated from outside just like a get method.
    • encoder

      public final com.revrobotics.RelativeEncoder encoder
    • controller

      public final com.revrobotics.SparkMaxPIDController controller
    • followers

      public final ArrayList<com.revrobotics.CANSparkMax> followers
  • Constructor Details

    • TorqueNEO

      public TorqueNEO(int id)
      Build a new TorqueNEO.
      Parameters:
      id - The CAN ID of the motor.
      encoderType - The type of encoder to use.
      inverted - Whether or not the motor is inverted.
      followers - The CAN IDs of the followers.
  • Method Details

    • setBreakMode

      public void setBreakMode(boolean isBreak)
    • setPositionConversionFactor

      public void setPositionConversionFactor(double factor)
    • setVelocityConversionFactor

      public void setVelocityConversionFactor(double factor)
    • setConversionFactors

      public void setConversionFactors(double posFactor, double veloFactor)
    • addFollower

      public void addFollower(int id, boolean invert)
      Add a follower motor ID.
      Parameters:
      id - The CAN ID of the follower.
      invert - Is the follower inverted relative to the leader?
    • burnFlash

      public void burnFlash()
    • setPercent

      public void setPercent(double percent)
      Set the motor to a percent output from a decimal. Domain is [-1, 1] where 0 is off and negative values are reversed.
      Parameters:
      percent - The percent output as a decimal.
    • getPercent

      public double getPercent()
    • setVolts

      public void setVolts(double volts)
      Set the motor to a voltage output. Domain is [-12, 12] where 0 is off and negative values are reversed assuming max volts of 12.
      Parameters:
      percent - The voltage output.
    • getVolts

      public double getVolts()
    • setVoltageCompensation

      public void setVoltageCompensation(double volts)
      Set the voltage compensation for the motor.
      Parameters:
      volts - Voltage compensation.
    • setCurrent

      public void setCurrent(double current)
      Set the motor to a amperage output. Domain is [-40, 40] where 0 is off and negative values are reversed assuming max amperage of 40.
      Parameters:
      percent - The amperage output.
    • getCurrent

      public double getCurrent()
    • setCurrentLimit

      public void setCurrentLimit(int amps)
      Set the maximum current the motor can draw.
      Parameters:
      amps - Maximum amperage.
    • configurePID

      public void configurePID(TorquePID pid)
      Configure the PID parameters. Necessary to use position and velocity control.
      Parameters:
      pid - The TorquePID object.
    • setPosition

      public void setPosition(double pos)
      Default unit is rotations, changed with setConversionFactors method.
      Parameters:
      pos - The position to set.
    • getPosition

      public double getPosition()
      Default unit is rotations, changed with setConversionFactors method.
      Returns:
      The position.
    • setVelocity

      public void setVelocity(double velo)
      Default unit is RPM, changed with setConversionFactors method.
      Parameters:
      velo - The velocity to set.
    • getVelocity

      public double getVelocity()
      Default unit is RPM, changed with setConversionFactors method.
      Returns:
      The velocity.
    • configureSmartMotion

      public void configureSmartMotion(TorqueNEO.SmartMotionProfile profile)
      Configure the SmartMotionProfile parameters. Necessary to use the smart motion control.
      Parameters:
      profile - The SmartMotionProfile object.
    • setSmartPosition

      public void setSmartPosition(double pos)
      Default unit is rotations, changed with setConversionFactors method.
      Parameters:
      pos - The position to set.
    • setSmartVelocity

      public void setSmartVelocity(double velo)
      Default unit is RPM, changed with setConversionFactors method.
      Parameters:
      velo - The velocity to set.