Skip to content

Commit

Permalink
Calibrate independently rather than both if any hit (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rongrrz authored Feb 17, 2024
1 parent 04334f0 commit 636210b
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/main/java/competition/subsystems/arm/ArmSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -369,17 +369,16 @@ public void armEncoderTicksUpdate() {
}


// Update the offset of the arm when it touches either forward/reverse limit switches for the first time.
// Update the offset of the arm when it touches reverse limit switches for the first time.
// Both arms calibrate independently
public void calibrateArmOffset() {
// For now keeping the concept of left/right having independent calibration,
// but for simplicity, hitting either limit will calibrate both for now.
if ((!hasCalibratedLeft || !hasCalibratedRight)
&& (getLimitState(armMotorLeft) == LimitState.LOWER_LIMIT_HIT
|| getLimitState(armMotorRight) == LimitState.LOWER_LIMIT_HIT))
{
if (!hasCalibratedLeft && getLimitState(armMotorLeft) == LimitState.LOWER_LIMIT_HIT) {
hasCalibratedLeft = true;
hasCalibratedRight = true;
armMotorLeftRevolutionOffset = -armMotorLeft.getPosition();
}

if (!hasCalibratedRight && getLimitState(armMotorRight) == LimitState.LOWER_LIMIT_HIT) {
hasCalibratedRight = true;
armMotorRightRevolutionOffset = -armMotorRight.getPosition();
}
}
Expand Down

0 comments on commit 636210b

Please sign in to comment.