-
Notifications
You must be signed in to change notification settings - Fork 0
add auto-only drive current limit #147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: event/norcal-states
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ | |
|
|
||
| import com.ctre.phoenix6.SignalLogger; | ||
| import com.ctre.phoenix6.Utils; | ||
| import com.ctre.phoenix6.configs.CurrentLimitsConfigs; | ||
| import com.ctre.phoenix6.swerve.SwerveDrivetrainConstants; | ||
| import com.ctre.phoenix6.swerve.SwerveModuleConstants; | ||
| import com.ctre.phoenix6.swerve.SwerveRequest; | ||
|
|
@@ -231,6 +232,32 @@ public CommandSwerveDrivetrain( | |
| configureAutoBuilder(); | ||
| } | ||
|
|
||
| /** | ||
| * Sets the supply current limit for all drive motors. | ||
| * | ||
| * @param currentLimit The supply current limit in amps | ||
| */ | ||
| private void setDriveMotorSupplyCurrentLimit(double currentLimit) { | ||
| var currentLimitsConfig = new CurrentLimitsConfigs() | ||
| .withStatorCurrentLimit(Amps.of(DrivetrainConstants.DRIVE_STATOR_CURRENT_LIMIT)) | ||
| .withStatorCurrentLimitEnable(true) | ||
| .withSupplyCurrentLimit(currentLimit) | ||
| .withSupplyCurrentLimitEnable(true); | ||
|
|
||
| // Apply to all modules' drive motors | ||
| for (var module : getModules()) { | ||
| module.getDriveMotor().getConfigurator().apply(currentLimitsConfig); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Severity: low 🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage. |
||
| } | ||
| } | ||
|
|
||
| public void setAutoDriveMotorSupplyCurrentLimit() { | ||
| setDriveMotorSupplyCurrentLimit(DrivetrainConstants.DRIVE_SUPPLY_CURRENT_LIMIT_AUTO); | ||
| } | ||
|
|
||
| public void setDefaultDriveMotorSupplyCurrentLimit() { | ||
| setDriveMotorSupplyCurrentLimit(DrivetrainConstants.DRIVE_SUPPLY_CURRENT_LIMIT); | ||
| } | ||
|
|
||
| /** | ||
| * Returns a command that applies the specified control request to this swerve drivetrain. | ||
| * | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
autonomousExit()is the only place that restores the default supply current limit; if that hook doesn’t run for any reason (unexpected restart / mode transition behavior), the higher auto limit could persist into teleop. Is there a reason you’re not also ensuring the default limit is restored on other transitions?Severity: medium
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.