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

2-ball Internals #20

merged 7 commits into from
Feb 19, 2022

Conversation

ky28059
Copy link
Member

@ky28059 ky28059 commented Feb 18, 2022

Needs testing and review from others. Borrows Ethan's idea of using ints to represent the current state of internals (in terms of ball locations) and updating motor powers based on that information.

// 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)
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link

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)

Copy link
Contributor

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.

Copy link
Contributor

@e3l e3l Feb 18, 2022

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);
Copy link
Contributor

@e3l e3l Feb 18, 2022

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?
Copy link
Member Author

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.

Copy link
Contributor

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) {
Copy link
Member Author

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.

@ky28059
Copy link
Member Author

ky28059 commented Feb 19, 2022

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.

@eggaskin eggaskin merged commit a047ae2 into develop Feb 19, 2022
@eggaskin eggaskin deleted the internals branch February 19, 2022 23:31
@@ -47,6 +47,7 @@
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?


// 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.

@ky28059 ky28059 mentioned this pull request Feb 20, 2022
e3l pushed a commit that referenced this pull request Mar 5, 2022
* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants