Class SwerveDrive.SwerveModuleConfig<DriveMotorType extends edu.wpi.first.wpilibj.motorcontrol.MotorController,​SteeringMotorType extends edu.wpi.first.wpilibj.motorcontrol.MotorController,​AbsoluteEncoder extends com.ctre.phoenix.sensors.CANCoder>

  • Type Parameters:
    DriveMotorType - The motor type for the drive motor on the swerve moduule.
    SteeringMotorType - The motor type for the steering motor on the module.
    AbsoluteEncoder - The absolute encoder type.
    Enclosing class:
    SwerveDrive

    public static class SwerveDrive.SwerveModuleConfig<DriveMotorType extends edu.wpi.first.wpilibj.motorcontrol.MotorController,​SteeringMotorType extends edu.wpi.first.wpilibj.motorcontrol.MotorController,​AbsoluteEncoder extends com.ctre.phoenix.sensors.CANCoder>
    extends java.lang.Object
    Helper class for easier swerve module creation
    • Constructor Detail

      • SwerveModuleConfig

        public SwerveModuleConfig​(DriveMotorType driveMotor,
                                  SteeringMotorType steerMotor,
                                  AbsoluteEncoder encoderSteering,
                                  double offset,
                                  SwerveModule.SwerveModuleLocation location)
        Swerve Module configuration class to define the motor CAN IDs and absolute encoder offset of a swerve module.
        Parameters:
        driveMotor - Drive motor for the swerve module.
        steerMotor - Steer motor for the swerve module.
        encoderSteering - CANCoder for the steering motor on the swerve module.
        offset - Absolute encoder offset.
        location - Swerve Moduule location on the chassis.
    • Method Detail

      • createModule

        public SwerveModule<DriveMotorType,​SteeringMotorType,​AbsoluteEncoder> createModule​(double driveGearRatio,
                                                                                                       double steerGearRatio,
                                                                                                       double wheelDiameterMeters,
                                                                                                       double wheelBaseMeters,
                                                                                                       double driveTrainWidthMeters,
                                                                                                       double steeringMotorFreeSpeedRPM,
                                                                                                       double maxSpeedMPS,
                                                                                                       double maxDriveAcceleration,
                                                                                                       boolean steeringInverted,
                                                                                                       boolean drivingInverted)
        Create the swerve module from the configuration.
        Parameters:
        driveGearRatio - Drive gear ratio in form of (rotation:1 AKA rotations/1) to get the encoder ticks per rotation.
        steerGearRatio - Steering motor gear ratio (usually 12.8:1 for MK4 in form of rotations:1 or rotations/1), only applied if using Neo's.
        wheelDiameterMeters - The wheel diameter of the swerve drive module in meters.
        wheelBaseMeters - The Distance between front and back wheels of the robot in meters.
        driveTrainWidthMeters - The Distance between centers of right and left wheels in meters.
        steeringMotorFreeSpeedRPM - The RPM free speed of the steering motor.
        maxSpeedMPS - The maximum drive speed in meters per second.
        maxDriveAcceleration - The maximum drive acceleration in meters^2 per second.
        steeringInverted - The steering motor is inverted.
        drivingInverted - The driving motor is inverted.
        Returns:
        The Swerve Module.