Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calibrate independently rather than both if any hit #102

Merged
merged 2 commits into from
Feb 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading