Skip to content

Commit

Permalink
Reimplement follower motor configuration better
Browse files Browse the repository at this point in the history
  • Loading branch information
anivanchen committed Jan 26, 2024
1 parent 492e18b commit ae54f0f
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/main/java/com/stuypulse/robot/constants/Motors.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,23 +90,20 @@ public static class CANSparkMaxConfig {
public final IdleMode IDLE_MODE;
public final int CURRENT_LIMIT_AMPS;
public final double OPEN_LOOP_RAMP_RATE;
public final CANSparkMax FOLLOWS;

public CANSparkMaxConfig(
boolean inverted,
IdleMode idleMode,
int currentLimitAmps,
double openLoopRampRate,
CANSparkMax follows) {
double openLoopRampRate) {
this.INVERTED = inverted;
this.IDLE_MODE = idleMode;
this.CURRENT_LIMIT_AMPS = currentLimitAmps;
this.OPEN_LOOP_RAMP_RATE = openLoopRampRate;
this.FOLLOWS = follows;
}

public CANSparkMaxConfig(boolean inverted, IdleMode idleMode, int currentLimitAmps) {
this(inverted, idleMode, currentLimitAmps, 0.0, null);
this(inverted, idleMode, currentLimitAmps, 0.0);
}

public CANSparkMaxConfig(boolean inverted, IdleMode idleMode) {
Expand All @@ -118,9 +115,16 @@ public void configure(CANSparkMax motor) {
motor.setIdleMode(IDLE_MODE);
motor.setSmartCurrentLimit(CURRENT_LIMIT_AMPS);
motor.setOpenLoopRampRate(OPEN_LOOP_RAMP_RATE);
if (FOLLOWS != null) motor.follow(FOLLOWS);
motor.burnFlash();
}

public void configureAsFollower(CANSparkMax motor, CANSparkMax follows) {
motor.setInverted(INVERTED);
motor.setIdleMode(IDLE_MODE);
motor.setSmartCurrentLimit(CURRENT_LIMIT_AMPS);
motor.setOpenLoopRampRate(OPEN_LOOP_RAMP_RATE);
motor.follow(follows);
motor.burnFlash();
}

}
}

0 comments on commit ae54f0f

Please sign in to comment.