Class Module

java.lang.Object
com.stuypulse.robot.subsystems.swerve.Module

public class Module extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final com.ctre.phoenix6.swerve.SwerveModuleConstants<com.ctre.phoenix6.configs.TalonFXConfiguration, com.ctre.phoenix6.configs.TalonFXConfiguration, com.ctre.phoenix6.configs.CANcoderConfiguration>
     
    private final org.wpilib.util.Alert
     
    private final int
     
    private final com.stuypulse.robot.subsystems.swerve.ModuleIOInputsAutoLogged
     
    private final ModuleIO
     
    private org.wpilib.math.kinematics.SwerveModulePosition[]
     
     
    private final org.wpilib.util.Alert
     
    private final org.wpilib.util.Alert
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Module(ModuleIO io, int index, com.ctre.phoenix6.swerve.SwerveModuleConstants<com.ctre.phoenix6.configs.TalonFXConfiguration, com.ctre.phoenix6.configs.TalonFXConfiguration, com.ctre.phoenix6.configs.CANcoderConfiguration> constants)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.wpilib.math.geometry.Rotation2d
    Returns the current turn angle of the module.
    double
    Returns the module velocity in rotations/sec (Phoenix native units).
    org.wpilib.math.kinematics.SwerveModulePosition[]
    Returns the module positions received this cycle.
    double[]
    Returns the timestamps of the samples received this cycle.
    org.wpilib.math.kinematics.SwerveModulePosition
    Returns the module position (turn angle and drive position).
    double
    Returns the current drive position of the module in meters.
    org.wpilib.math.kinematics.SwerveModuleVelocity
    Returns the module velocity (turn angle and drive velocity).
    double
    Returns the current drive velocity of the module in meters per second.
    double
    Returns the module position in radians.
    void
     
    void
     
    void
    runCharacterization(double output)
    Runs the module with the specified output while controlling to zero degrees.
    void
    runSetpoint(org.wpilib.math.kinematics.SwerveModuleVelocity state)
    Runs the module with the specified setpoint state.
    void
    Disables all outputs to motors.

    Methods inherited from class Object

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

    • io

      private final ModuleIO io
    • inputs

      private final com.stuypulse.robot.subsystems.swerve.ModuleIOInputsAutoLogged inputs
    • outputs

    • index

      private final int index
    • constants

      private final com.ctre.phoenix6.swerve.SwerveModuleConstants<com.ctre.phoenix6.configs.TalonFXConfiguration, com.ctre.phoenix6.configs.TalonFXConfiguration, com.ctre.phoenix6.configs.CANcoderConfiguration> constants
    • driveDisconnectedAlert

      private final org.wpilib.util.Alert driveDisconnectedAlert
    • turnDisconnectedAlert

      private final org.wpilib.util.Alert turnDisconnectedAlert
    • turnEncoderDisconnectedAlert

      private final org.wpilib.util.Alert turnEncoderDisconnectedAlert
    • odometryPositions

      private org.wpilib.math.kinematics.SwerveModulePosition[] odometryPositions
  • Constructor Details

    • Module

      public Module(ModuleIO io, int index, com.ctre.phoenix6.swerve.SwerveModuleConstants<com.ctre.phoenix6.configs.TalonFXConfiguration, com.ctre.phoenix6.configs.TalonFXConfiguration, com.ctre.phoenix6.configs.CANcoderConfiguration> constants)
  • Method Details

    • periodic

      public void periodic()
    • runSetpoint

      public void runSetpoint(org.wpilib.math.kinematics.SwerveModuleVelocity state)
      Runs the module with the specified setpoint state. Mutates the state to optimize it.
    • runCharacterization

      public void runCharacterization(double output)
      Runs the module with the specified output while controlling to zero degrees.
    • stop

      public void stop()
      Disables all outputs to motors.
    • getAngle

      public org.wpilib.math.geometry.Rotation2d getAngle()
      Returns the current turn angle of the module.
    • getPositionMeters

      public double getPositionMeters()
      Returns the current drive position of the module in meters.
    • getVelocityMetersPerSec

      public double getVelocityMetersPerSec()
      Returns the current drive velocity of the module in meters per second.
    • getPosition

      public org.wpilib.math.kinematics.SwerveModulePosition getPosition()
      Returns the module position (turn angle and drive position).
    • getVelocity

      public org.wpilib.math.kinematics.SwerveModuleVelocity getVelocity()
      Returns the module velocity (turn angle and drive velocity).
    • getOdometryPositions

      public org.wpilib.math.kinematics.SwerveModulePosition[] getOdometryPositions()
      Returns the module positions received this cycle.
    • getOdometryTimestamps

      public double[] getOdometryTimestamps()
      Returns the timestamps of the samples received this cycle.
    • getWheelRadiusCharacterizationPosition

      Returns the module position in radians.
    • getFFCharacterizationVelocity

      Returns the module velocity in rotations/sec (Phoenix native units).
    • periodicAfterScheduler

      public void periodicAfterScheduler()