-
Notifications
You must be signed in to change notification settings - Fork 6
Description
We're huge fans of the swerve builder API, and have really enjoyed how quickly we are able to get robots working using the robust driving features it provides. Unfortunately, we've recently experienced one pain point related to how current limits are configured for drive motors. Specifically, the SwerveModule class from the swerve builder API contains the following code in the constructor:
TalonFXConfiguration driveConfigs = constants.DriveMotorInitialConfigs;
driveConfigs.MotorOutput.NeutralMode = NeutralModeValue.Brake;
driveConfigs.Slot0 = constants.DriveMotorGains;
driveConfigs.TorqueCurrent.PeakForwardTorqueCurrent = constants.SlipCurrent;
driveConfigs.TorqueCurrent.PeakReverseTorqueCurrent = -constants.SlipCurrent;
driveConfigs.CurrentLimits.StatorCurrentLimit = constants.SlipCurrent;
driveConfigs.CurrentLimits.StatorCurrentLimitEnable = true;This reads the configured slip current, and overwrites the configured torque current limits & the configured stator current limit with it.
After observing unusual current draw from the swerve subsystem, we took a closer look and realized the current limits we'd been setting with the drive motor initial configs were being overwritten. This behavior seems confusing, since I'd expect that the current limits we provide to the initial configs would be used, or take precedence over the slip current number (which seems to be documented a value only relevant for configuring odometry, with no effect on motor output).
Would it be possible to remove the code which overwrites configured current limits with the slip current value? Or maybe some way to opt into this behavior only when no other current limits are provided?
As a workaround we've started applying the CurrentLimitsConfigs and TorqueCurrentConfigs separately, after the SwerveModule class has done its init code, but it'd be great if the Phoenix Framework made it simpler than that.
Thanks,
Jonah
Team 581 coach