-
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 |
---|---|---|
|
@@ -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; | ||
|
||
private boolean prevEntranceDetected = false; | ||
// private boolean prevStorageDetected = false; | ||
|
@@ -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; | ||
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. 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 |
||
} | ||
} | ||
|
||
@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; | ||
|
||
|
@@ -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; | ||
|
@@ -191,9 +199,9 @@ public void periodic() { | |
shotRequested = false; | ||
rejectingChecked = false; | ||
//stagingExitBallCount--; | ||
totalBallCount--; | ||
System.out.println("ball exited turret"); | ||
} | ||
|
||
} | ||
} | ||
} | ||
|
||
|
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.
Shouldn't
totalBallCount
be the sum ofentranceStorageBallCount
,storageStagingBallCount
, andstagingExitBallCount
or are those fields not used anymore?