Skip to content

Commit

Permalink
add new current limits
Browse files Browse the repository at this point in the history
  • Loading branch information
mpatankar6 committed Mar 30, 2024
1 parent 888a0c7 commit c7a14b7
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/main/java/frc/robot/drivetrain/ModuleIOTalonFX.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,18 @@

public class ModuleIOTalonFX implements ModuleIO {

private final double kDrivekP = 0.4;
private final double kDrivekS;
private final double kDrivekP = 0.15;
private final double kDrivekS = 0.13;
private final double kDrivekV = 0.72;
private final double kSteerkP = 100.0;
private final double kSteerkD = 0.2;
private final double kSlipCurrent = Constants.kIsSim ? 400.0 : 58.0;
private static final double kSlipCurrent;

static {
if (Constants.kIsSim) kSlipCurrent = 400.0;
else if (Constants.kIsViper) kSlipCurrent = 58.0;
else kSlipCurrent = 64.0;
}

private final TalonFX m_driveMotor, m_steerMotor;
private final CANcoder m_azimuthEncoder;
Expand Down Expand Up @@ -62,28 +68,24 @@ public ModuleIOTalonFX(int index) {
m_steerMotor = new TalonFX(3, Constants.kDrivetrainCanBus);
m_azimuthEncoder = new CANcoder(12, Constants.kDrivetrainCanBus);
m_absoluteEncoderMagnetOffset = Constants.kIsViper ? 0.37353515625 : 0.066162109375;
kDrivekS = 0.133;
break;
case 1: // FR
m_driveMotor = new TalonFX(6, Constants.kDrivetrainCanBus);
m_steerMotor = new TalonFX(5, Constants.kDrivetrainCanBus);
m_azimuthEncoder = new CANcoder(13, Constants.kDrivetrainCanBus);
m_absoluteEncoderMagnetOffset = Constants.kIsViper ? -0.090576171875 : -0.439697265625;
kDrivekS = 0.129;
break;
case 2: // BL
m_driveMotor = new TalonFX(2, Constants.kDrivetrainCanBus);
m_steerMotor = new TalonFX(1, Constants.kDrivetrainCanBus);
m_azimuthEncoder = new CANcoder(11, Constants.kDrivetrainCanBus);
m_absoluteEncoderMagnetOffset = Constants.kIsViper ? 0.275634765625 : 0.08740234375;
kDrivekS = 0.057;
break;
case 3: // BR
m_driveMotor = new TalonFX(7, Constants.kDrivetrainCanBus);
m_steerMotor = new TalonFX(8, Constants.kDrivetrainCanBus);
m_azimuthEncoder = new CANcoder(14, Constants.kDrivetrainCanBus);
m_absoluteEncoderMagnetOffset = Constants.kIsViper ? 0.314208984375 : -0.436767578125;
kDrivekS = 0.088;
break;
default:
throw new RuntimeException("Invalid module index");
Expand Down

0 comments on commit c7a14b7

Please sign in to comment.