Skip to content

Commit

Permalink
Revert "Merge branch 'Pre-States2024' of https://github.com/robo7660/…
Browse files Browse the repository at this point in the history
…Robot into Pre-States2024"

This reverts commit f27ede4, reversing
changes made to cc8bd92.
  • Loading branch information
robo7660 committed Apr 5, 2024
1 parent 6316d97 commit b6a80fe
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/main/java/frc/robot/subsystems/SwerveSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

package frc.robot.subsystems;

import com.ctre.phoenix6.configs.CurrentLimitsConfigs;
import com.ctre.phoenix6.controls.DutyCycleOut;
import com.ctre.phoenix6.hardware.TalonFX;
import com.ctre.phoenix6.hardware.core.CoreTalonFX;
Expand Down Expand Up @@ -100,6 +101,7 @@ public SwerveSubsystem(File directory)
setupCustom();
initDriveTalons();
setupFOC();
setCurrentLimits();
}

/**
Expand All @@ -115,6 +117,7 @@ public SwerveSubsystem(SwerveDriveConfiguration driveCfg, SwerveControllerConfig
setupCustom();
initDriveTalons();
setupFOC();
setCurrentLimits();
}

/**
Expand Down Expand Up @@ -354,6 +357,21 @@ private void updateMatchTime() {
SmartDashboard.putString("Match Time", matchTime);
}

private void setCurrentLimits() {
for (SwerveModule swerveModule : swerveDrive.getModules()){
TalonFX motor = (TalonFX) swerveModule.getDriveMotor().getMotor();
CurrentLimitsConfigs config = new CurrentLimitsConfigs();
config.StatorCurrentLimitEnable = true;
config.SupplyCurrentLimitEnable = true;
config.SupplyCurrentThreshold = 60;
config.SupplyTimeThreshold = 2.5;
config.StatorCurrentLimit = Constants.driveStatorCurrentLimit;
config.SupplyCurrentLimit = Constants.driveSupplyCurrentLimit;
motor.getConfigurator().apply(config);
motor.getConfigurator().refresh(config);
}
}

@Override
public void simulationPeriodic()
{
Expand Down

0 comments on commit b6a80fe

Please sign in to comment.