-
Notifications
You must be signed in to change notification settings - Fork 4
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
2-ball Internals #20
Changes from 1 commit
04d4f47
1496eef
90cd7e1
9d44eba
0ce8e27
d65ad69
cd2ccc2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,11 +101,17 @@ public InternalSubsystem(TurretSubsystem turretSubsystem) { | |
public void periodic() { | ||
// Check sensors for incoming and exiting balls and update ball counts accordingly | ||
boolean entranceDetected = entrance.get() >= 0.4; | ||
if (!prevEntranceDetected && entranceDetected) entranceStorageBallCount++; | ||
if (!prevEntranceDetected && entranceDetected) { | ||
entranceStorageBallCount++; | ||
System.out.println("entrance ball detected"); | ||
//TODO shouldn't this set rejectingChecked to false? | ||
} | ||
prevEntranceDetected = entranceDetected; | ||
|
||
Color storageColor = matchColor(colorSensorThread.getLastStorage()); | ||
//System.out.println("storage color:: " + colorToString(storageColor)); | ||
boolean storageDetected = isBall(storageColor); | ||
if (storageDetected) System.out.println("storage ball detected"); | ||
if (!prevStorageDetected && storageDetected) { | ||
// If we haven't already checked rejection logic, reject the ball if it doesn't match alliance color | ||
if (!rejectingChecked) { | ||
|
@@ -114,13 +120,17 @@ public void periodic() { | |
} | ||
entranceStorageBallCount--; | ||
storageStagingBallCount++; | ||
System.out.println(); | ||
System.out.println("new storage detected, - entrance + storage from prev storage detected"); | ||
} | ||
prevStorageDetected = storageDetected; | ||
|
||
boolean stagingDetected = staging.get() >= 0.2; | ||
boolean stagingDetected = staging.get() >= 0.13; | ||
if (stagingDetected) System.out.println("staging ball detected"); | ||
if (!prevStagingDetected && stagingDetected) { | ||
storageStagingBallCount--; | ||
stagingExitBallCount++; | ||
System.out.println("ball moved from storage to staging"); | ||
} | ||
prevStagingDetected = stagingDetected; | ||
|
||
|
@@ -145,20 +155,28 @@ public void periodic() { | |
if (shotRequested /* && turretSubsystem.getState() == TurretSubsystem.ModuleState.HIGH_TOLERANCE | ||
|| rejecting && turretSubsystem.getState() == TurretSubsystem.ModuleState.LOW_TOLERANCE */) { | ||
// Spin the top motor on a timer | ||
exitTimer.start(); | ||
motorTop.set(0.5); | ||
|
||
// If 1.5 seconds have elapsed, mark the shot as finished | ||
if (exitTimer.hasElapsed(1.5)) { | ||
exitTimer.stop(); | ||
exitTimer.reset(); | ||
motorTop.set(0); | ||
|
||
// Reset states | ||
if (!stagingDetected) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We shouldn't set |
||
shotRequested = false; | ||
rejectingChecked = false; | ||
stagingExitBallCount--; | ||
System.out.println("false alarm"); | ||
} else { | ||
exitTimer.start(); | ||
motorTop.set(0.5); | ||
|
||
// If 1.5 seconds have elapsed, mark the shot as finished | ||
if (exitTimer.hasElapsed(1.5)) { | ||
exitTimer.stop(); | ||
exitTimer.reset(); | ||
motorTop.set(0); | ||
|
||
// Reset states | ||
shotRequested = false; | ||
rejectingChecked = false; | ||
stagingExitBallCount--; | ||
System.out.println("ball exited"); | ||
} | ||
} | ||
|
||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should not, because we only want to tell the turret to reject based on the color of the first ball. That's why
rejectingChecked
exists in the first place -- to not have a second ball in storage override the rejection logic for the first ball.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oop i thought i deleted that TODO but yes, i did follow that logic