Code Review: Critical Bugs Identified#1
Conversation
See PR comments for critical bugs identified during code review. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Critical Bug #1: IntakeIOHardware.java:17-18 - CAN IDs Swapped The leader motor is assigned the follower CAN ID and vice versa: // Current (BROKEN):
protected final SparkFlex m_pivotLeader = new SparkFlex(IntakeConstants.kPivotFollowerCAN, ...); // Wrong!
protected final SparkFlex m_pivotFollower = new SparkFlex(IntakeConstants.kPivotLeaderCAN, ...); // Wrong!Fix: Swap the CAN ID constants: protected final SparkFlex m_pivotLeader = new SparkFlex(IntakeConstants.kPivotLeaderCAN, ...);
protected final SparkFlex m_pivotFollower = new SparkFlex(IntakeConstants.kPivotFollowerCAN, ...); |
|
Critical Bug #3: ShooterIOHardware.java:97 - Wrong Controller for Hood
// Current (BROKEN):
public void setHoodPosition (double position) {
m_flywheelController.setSetpoint(position, ControlType.kPosition, ClosedLoopSlot.kSlot0);
}Fix: public void setHoodPosition (double position) {
m_hoodController.setSetpoint(position, ControlType.kPosition, ClosedLoopSlot.kSlot0);
} |
|
#4: Shooter.java:99 - Voltage Method Calls Percentage SysId routines call // Current (BROKEN):
public void setFlywheelVoltage(double magnitude) {
this.m_io.setFlywheelPercentage(magnitude); // Wrong!
}Fix: public void setFlywheelVoltage(double magnitude) {
this.m_io.setFlywheelVoltage(magnitude);
}Also need to implement @Override
public void setFlywheelVoltage(double voltage) {
m_flywheelLeader.setVoltage(voltage);
} |
|
Issue: Velocity Units Mismatch: RPM vs Rotations Per Second REV SparkFlex encoders return velocity in RPM by default, but WPILib's SysId RotationsPerSecond unit expects rotations per second. Current code: This only applies the gear ratio, not the RPM to RPS conversion. Expected: The /60.0 converts RPM to rotations per second (RPM ÷ 60 = RPS). Affected subsystems:
Impact: References:
|
issues Found
See inline review comments on the following files:
IntakeIOHardware.java- CAN ID swap & input overwrite bugsShooterIOHardware.java- Wrong controller used for hoodShooter.java- Voltage method calls percentage method