-
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
Conversation
Needs testing.
// If there is a ball in the entrance or between storage and staging *and* staging is empty, run the bottom motor. | ||
// This serves to bring the first ball properly from storage to staging. For the second ball, the right hand side | ||
// of the condition will evaluate to false so it will be stopped when the ball reaches storage. | ||
motorBottom.set(entranceStorageBallCount > 0 || (stagingExitBallCount == 0 && storageStagingBallCount > 0) |
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.
what if there's a ball already in storage?
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.
Intake should prevent this. I could add another &&
though.
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.
Is it possible to have a ball in storage without intake running?
(like at the start of the match)
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.
yes, we will have one at the start of the match. we can code for that and just assume at the beginning/initialization our count is 1.
and for the motors, we have tested that before, if we redeploy code with a ball in storage or staging (where the motors will be off anyways) it doesn't mess anything up.
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.
If we could make the logic resilient enough so that when we run the intake in autonomous to pick up a second (and therefore run the bottom roller), the ball in the robot hits storage before the second passes thru the entrance sensor and the software can recognize that. that would be pretty neat but not necessary probably
if (shotRequested /* && turretSubsystem.getState() == TurretSubsystem.ModuleState.READY | ||
|| rejecting && turretSubsystem.getState() == TurretSubsystem.ModuleState.ALMOST */) { | ||
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); |
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.
won't this and line 134 potentially cause jittering? might be best to use booleans/doubles till the very end
if (!prevEntranceDetected && entranceDetected) { | ||
entranceStorageBallCount++; | ||
System.out.println("entrance ball detected"); | ||
//TODO shouldn't this set rejectingChecked to false? |
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
motorTop.set(0); | ||
|
||
// Reset states | ||
if (!stagingDetected) { |
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.
We shouldn't set shotRequested
to false if there's not a ball in staging. The idea of shotRequested
is that the driver tells internals to shoot by setting the boolean to true, and internals will fire the ball as soon as everything is ready; shotRequested
is just a way of saying "please shoot the next ball you get". Setting it to false if there's not a staging ball would break being able to press it when internals isn't fully ready yet.
I think hardcoding timer durations is in general a more "hacky" solution than using sensors to track the balls, but if jittering is unpreventable then I guess this can work. Timer durations would also need to be retuned if, for example, mech changes compression or motor gear ratio. |
@@ -47,6 +47,7 @@ | |||
private int entranceStorageBallCount = 0; | |||
private int storageStagingBallCount = 0; | |||
private int stagingExitBallCount = 0; | |||
private int totalBallCount = 0; |
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 of entranceStorageBallCount
, storageStagingBallCount
, and stagingExitBallCount
or are those fields not used anymore?
|
||
// 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 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
.
* 2-ball internals code, turret enum renaming Needs testing. * Fix motor conditions * Testing code Testing on Monday or Tuesday! * Fix infinite storage state updates * more print statements + failsafes, will probably rewrite but just to save * internals, but now on transition timers * auton 1-ball start & total ball count Co-authored-by: eggaskin <[email protected]>
Needs testing and review from others. Borrows Ethan's idea of using
int
s to represent the current state of internals (in terms of ball locations) and updating motor powers based on that information.