From c7a14b7a0b8ba85769ed1682980c9250cc5cadcc Mon Sep 17 00:00:00 2001 From: Mihir Patankar Date: Sat, 30 Mar 2024 18:40:14 -0400 Subject: [PATCH] add new current limits --- .../frc/robot/drivetrain/ModuleIOTalonFX.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/java/frc/robot/drivetrain/ModuleIOTalonFX.java b/src/main/java/frc/robot/drivetrain/ModuleIOTalonFX.java index 1f79d3f..0d3d667 100644 --- a/src/main/java/frc/robot/drivetrain/ModuleIOTalonFX.java +++ b/src/main/java/frc/robot/drivetrain/ModuleIOTalonFX.java @@ -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; @@ -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");