Class TorqueSwerveModule2021

java.lang.Object
org.texastorque.torquelib.modules.base.TorqueSwerveModule
org.texastorque.torquelib.modules.TorqueSwerveModule2021

public final class TorqueSwerveModule2021 extends TorqueSwerveModule
A representation of the 2021 Texas Torque custom swervedrive module. The module utalizes a Rev Neo driven by a Rev Spark Max for the drive, and a Vex 775 Pro driven by a CTRE Talon SRX for the rotation. The default constants and configurations are tuned to the 2022 robot.
  • Field Summary

    Fields inherited from class org.texastorque.torquelib.modules.base.TorqueSwerveModule

    id
  • Constructor Summary

    Constructors
    Constructor
    Description
    TorqueSwerveModule2021(int id, int drivePort, int rotatePort, double driveGearing, double wheelRadiusMeters, TorquePID drivePID, TorquePID rotatePID, double maxVelocity, double maxAcceleration, edu.wpi.first.math.controller.SimpleMotorFeedforward driveFeedForward)
    Construct a new TorqueSwerveModule2021.
    TorqueSwerveModule2021(int id, int drivePort, int rotatePort, double driveGearing, double wheelRadiusMeters, KPID drivePID, KPID rotatePID, double maxVelocity, double maxAcceleration, edu.wpi.first.math.controller.SimpleMotorFeedforward driveFeedForward)
    Deprecated.
    Uses KPID, use TorquePID instead.
  • Method Summary

    Modifier and Type
    Method
    Description
    final double
    encoderPerMinuteToMetersPerSecond(double encodersPerMinute)
    Conveerts motor speed in rotations per minute to meters per second.
    static void
    equalizedDriveRatio(edu.wpi.first.math.kinematics.SwerveModuleState[] states, double max)
    Equalizes drive speeds to never exceed full power on the Neo.
    final double
     
    double
     
    final edu.wpi.first.math.geometry.Rotation2d
    Gets the rotation of the swerve module as a Rotation2d.
    final edu.wpi.first.math.kinematics.SwerveModuleState
    Gets the current swerve module state.
    final double
    metersPerSecondToEncoderPerMinute(double metersPerSecond)
    Converts wheel speed in meters per second to rotations per minute.
    final void
    setDesiredState(edu.wpi.first.math.kinematics.SwerveModuleState state)
    Set the state of the swerve module.
    final void
    setLogging(boolean logging)
    Set the logging status of the module.
    void
    setRotatePosition(double pos)
     
    final void
    spin(double speed)
     

    Methods inherited from class org.texastorque.torquelib.modules.base.TorqueSwerveModule

    getPort

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • TorqueSwerveModule2021

      public TorqueSwerveModule2021(int id, int drivePort, int rotatePort, double driveGearing, double wheelRadiusMeters, TorquePID drivePID, TorquePID rotatePID, double maxVelocity, double maxAcceleration, edu.wpi.first.math.controller.SimpleMotorFeedforward driveFeedForward)
      Construct a new TorqueSwerveModule2021.
      Parameters:
      id - The id of the swerve module.
      drivePort - The port (can id) of the drive motor.
      rotatePort - The port (can id) of the rotation motor.
      driveGearing - The drive motor gearing.
      wheelRadiusMeters - The radius of the wheel in meters.
      drivePID - The drive motor PID.
      rotatePID - The rotation motor PID.
      maxVelocity - The maximum velocity of the drive motor in meters per second.
      maxAcceleration - The maximum acceleration of the drive motor in meters per second per second.
      driveFeedForward - The drive motor feed forward for autonomous.
    • TorqueSwerveModule2021

      @Deprecated public TorqueSwerveModule2021(int id, int drivePort, int rotatePort, double driveGearing, double wheelRadiusMeters, KPID drivePID, KPID rotatePID, double maxVelocity, double maxAcceleration, edu.wpi.first.math.controller.SimpleMotorFeedforward driveFeedForward)
      Deprecated.
      Uses KPID, use TorquePID instead.
      Construct a new TorqueSwerveModule2021.
      Parameters:
      id - The id of the swerve module.
      drivePort - The port (can id) of the drive motor.
      rotatePort - The port (can id) of the rotation motor.
      driveGearing - The drive motor gearing.
      wheelRadiusMeters - The radius of the wheel in meters.
      drivePID - The drive motor PID.
      rotatePID - The rotation motor PID.
      maxVelocity - The maximum velocity of the drive motor in meters per second.
      maxAcceleration - The maximum acceleration of the drive motor in meters per second per second.
      driveFeedForward - The drive motor feed forward for autonomous.
  • Method Details

    • setDesiredState

      public final void setDesiredState(edu.wpi.first.math.kinematics.SwerveModuleState state)
      Set the state of the swerve module.
      Specified by:
      setDesiredState in class TorqueSwerveModule
      Parameters:
      state - The state of the swerve module.
    • getState

      public final edu.wpi.first.math.kinematics.SwerveModuleState getState()
      Gets the current swerve module state.
      Specified by:
      getState in class TorqueSwerveModule
      Returns:
      The SwerveModuleState that represents the current state of the module.
    • getRotation

      public final edu.wpi.first.math.geometry.Rotation2d getRotation()
      Gets the rotation of the swerve module as a Rotation2d.
      Specified by:
      getRotation in class TorqueSwerveModule
      Returns:
      The Rotation2d that represents the motor rotation.
    • metersPerSecondToEncoderPerMinute

      public final double metersPerSecondToEncoderPerMinute(double metersPerSecond)
      Converts wheel speed in meters per second to rotations per minute.
      Parameters:
      metersPerSecond - Speed wheel in meters per second.
      Returns:
      Speed in rotations per minute.
    • encoderPerMinuteToMetersPerSecond

      public final double encoderPerMinuteToMetersPerSecond(double encodersPerMinute)
      Conveerts motor speed in rotations per minute to meters per second.
      Parameters:
      encodersPerMinute - Speed in rotations per minute.
      Returns:
      Wheel speed in meters per second.
    • equalizedDriveRatio

      public static void equalizedDriveRatio(edu.wpi.first.math.kinematics.SwerveModuleState[] states, double max)
      Equalizes drive speeds to never exceed full power on the Neo.
      Parameters:
      states - The swerve module states, this is mutated!
      max - Maximum translational speed.
    • setLogging

      public final void setLogging(boolean logging)
      Set the logging status of the module.
      Parameters:
      logging - To log or not to log.
    • getDisplacement

      public final double getDisplacement()
    • spin

      public final void spin(double speed)
    • getRotatePosition

      public double getRotatePosition()
    • setRotatePosition

      public void setRotatePosition(double pos)