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

2-ball Internals #20

Merged
merged 7 commits into from
Feb 19, 2022
Merged
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public class InternalSubsystem extends GRTSubsystem {
private int entranceStorageBallCount = 0;
private int storageStagingBallCount = 0;
private int stagingExitBallCount = 0;
private int totalBallCount = 0;
Copy link
Member Author

Choose a reason for hiding this comment

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

Shouldn't totalBallCount be the sum of entranceStorageBallCount, storageStagingBallCount, and stagingExitBallCount or are those fields not used anymore?


private boolean prevEntranceDetected = false;
// private boolean prevStorageDetected = false;
Expand Down Expand Up @@ -99,24 +100,30 @@ public InternalSubsystem(TurretSubsystem turretSubsystem) {
case Blue: ALLIANCE_COLOR = BLUE; break;
default: ALLIANCE_COLOR = RED; break;
}

// if we are in auton we start with 1 ball
if (DriverStation.isAutonomous()) {
totalBallCount = 1;
Copy link
Member Author

Choose a reason for hiding this comment

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

If the "between two sensor" ball count ints are still used (they are still being set in periodic), this should set one of those ints to 1 instead of the total ball count, with total ball count just being a sum of the 3. If they're not used, probably deleting all 3 from periodic and the subsystem would be fine; just have getBallCount() return totalBallCount.

}
}

@Override
public void periodic() {

boolean entranceDetected = entrance.get() >= 0.4;
if (!prevEntranceDetected && entranceDetected) totalBallCount++;
prevEntranceDetected = entranceDetected;

Color storageColor = matchColor(colorSensorThread.getLastStorage());
boolean storageDetected = isBall(storageColor);
boolean stagingDetected = staging.get() >= 0.13;

boolean stagingDetected = staging.get() >= 0.13;

// Testing prints, Y = ball detected, X = no ball
System.out.println("Entrance: " + (prevEntranceDetected ? "Y" : "X") +
", Storage: " + (storageDetected ? "Y" : "X") +
", Staging: " + (stagingDetected ? "Y" : "X"));



if (driverOverride) return;

Expand All @@ -140,14 +147,15 @@ public void periodic() {
//storageStagingBallCount++;
System.out.println("ball moved from entrance to storage");
}

// If there is a ball between storage and staging and staging is empty, run the top and bottom motors
//old condition: (storageStagingBallCount > 0 && stagingExitBallCount == 0)
if (storageDetected && !stagingDetected && !shotRequested) {
// Spin the bottom and top motors on a timer
storageTimer.start();
motorTop.set(0.5);
motorBottom.set(0.3);

if (!rejectingChecked) {
rejecting = storageColor != ALLIANCE_COLOR;
rejectingChecked = true;
Expand Down Expand Up @@ -191,9 +199,9 @@ public void periodic() {
shotRequested = false;
rejectingChecked = false;
//stagingExitBallCount--;
totalBallCount--;
System.out.println("ball exited turret");
}

}
}
}

Expand Down