Merged
Conversation
eeveemara
reviewed
Mar 19, 2026
eeveemara
reviewed
Mar 19, 2026
eeveemara
reviewed
Mar 19, 2026
| private SparkMax followerMotor2; | ||
| private RelativeEncoder followerEncoder2; | ||
| private SparkMaxConfig followerConfig2; | ||
|
|
Contributor
There was a problem hiding this comment.
Since all 3 followers have the exact same config (idle mode, current limit) except for CAN ID and invert direction, you could use an array + helper method:
private SparkMax[] followers;
// Then add a helper:
private SparkMax configureFollower(int canId, boolean inverted) {
SparkMax follower = new SparkMax(canId, MotorType.kBrushless);
SparkMaxConfig config = new SparkMaxConfig();
config.follow(Constants.CANDeviceIDs.kShooterID, inverted);
config.idleMode(SparkBaseConfig.IdleMode.kCoast);
config.smartCurrentLimit(60);
follower.configure(config, ResetMode.kNoResetSafeParameters, PersistMode.kPersistParameters);
return follower;
}
// and the constructor becomes:
followers = new SparkMax[] {
configureFollower(CANDeviceIDs.kShooterFollower, false), // same direction
configureFollower(CANDeviceIDs.kShooterFollower1, true), // inverted
configureFollower(CANDeviceIDs.kShooterFollower2, true), // inverted
};This way, the current limit and idle mode exist in only one place. If we need to change something later, we change it once instead of multiple times.
david-lemasurier
approved these changes
Mar 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
solved #81