Skip to content

Shooter config#101

Merged
david-lemasurier merged 8 commits intomainfrom
ShooterConfig
Mar 21, 2026
Merged

Shooter config#101
david-lemasurier merged 8 commits intomainfrom
ShooterConfig

Conversation

@Team5962Programming
Copy link
Contributor

solved #81

@Team5962Programming Team5962Programming requested a review from a team as a code owner March 19, 2026 00:28
private SparkMax followerMotor2;
private RelativeEncoder followerEncoder2;
private SparkMaxConfig followerConfig2;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 david-lemasurier merged commit ed5401f into main Mar 21, 2026
2 of 4 checks passed
@cardinal778 cardinal778 deleted the ShooterConfig branch March 21, 2026 18:24
@Kfir-bot Kfir-bot restored the ShooterConfig branch March 21, 2026 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants