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

Shuffleboard abstraction #31

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
9d0ba93
`GRTShuffleboardLayout`, `.list()`, positions in code
ky28059 Mar 29, 2022
fa5b47e
Position and size methods for shuffleboard layout
ky28059 Mar 29, 2022
4bc05fd
Internals debugging and networktables
ky28059 Mar 30, 2022
ff0ca1a
Move `.addEntry()` to list-like `.at()` position syntax
ky28059 Mar 30, 2022
e329d83
Auton chooser, split up localize coordinate method
ky28059 Mar 30, 2022
8794024
2 ball auto + more debug networktables
ky28059 Mar 30, 2022
d9d2fba
Run intake in `DeployIntakeCommand`, `PlebAutonSequence` restructuring
ky28059 Mar 30, 2022
5a01184
Put hood and flywheel refs on shuffleboard, reset offsets on vision data
ky28059 Mar 30, 2022
e9aef3a
internals and turret tweaks
e3l Mar 30, 2022
6108af2
Separate driver and auto intake override, partially revert PlebAutonS…
ky28059 Mar 31, 2022
46639fc
Merge branch 'shuffleboard-abstraction' of https://github.com/grt192/…
ky28059 Mar 31, 2022
0a7c144
Jetson data pairing
ky28059 Mar 31, 2022
1c7d9a7
Shoot 2 balls at once, rtheta feedforward, turntable tolerance fix
ky28059 Apr 1, 2022
4f383e3
tweaked and tested shooter interpolation table
e3l Apr 1, 2022
0bba935
Two ball fixes
e3l Apr 1, 2022
58db64d
Only shoot two balls without delay when they are the same color
ky28059 Apr 1, 2022
d94c188
`.widget()`, better internals shuffleboard updating
ky28059 Apr 1, 2022
e3023e4
Intake shuffleboard organization
ky28059 Apr 4, 2022
207fa74
Climb shuffleboard organization
ky28059 Apr 4, 2022
827e399
Intake top limit switch + reset abstraction
e3l Apr 4, 2022
2c64a8c
Preliminary intake deploy tuning
ky28059 Apr 4, 2022
e53ea54
Intake tuning, shuffleboard manual zero
ky28059 Apr 6, 2022
76f28f3
Turret `setValue()` organization
ky28059 Apr 6, 2022
39fa9b6
Don't force if the turret is retracted
ky28059 Apr 6, 2022
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
32 changes: 16 additions & 16 deletions src/main/java/frc/robot/subsystems/TurretSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ public String toString() {
private Pose2d previousPosition = new Pose2d();
private double previousLoopTime = Timer.getFPGATimestamp();

private double R_FF = 0;
private double THETA_FF = 0;
private double R_FF = 0.2;
private double THETA_FF = 0.2;

// Motor state variables
private double desiredFlywheelRPM;
Expand Down Expand Up @@ -282,27 +282,27 @@ public TurretSubsystem(TankSubsystem tankSubsystem, JetsonConnection connection)

// Initialize Shuffleboard entries
shuffleboardTab = new GRTShuffleboardTab("Turret");;
flywheelVeloEntry = shuffleboardTab.addEntry("Flywheel vel", 0).at(2, 1);
flywheelRefEntry = shuffleboardTab.addEntry("Flywheel ref", 0).at(2, 0);
turntablePosEntry = shuffleboardTab.addEntry("Turntable pos", 0).at(3, 1);
turntableRefEntry = shuffleboardTab.addEntry("Turntable ref", 0).at(3, 0);
hoodPosEntry = shuffleboardTab.addEntry("Hood pos", 0).at(4, 1);
hoodRefEntry = shuffleboardTab.addEntry("Hood ref", 0).at(4, 0);
flywheelVeloEntry = shuffleboardTab.addEntry("Flywheel vel", 0).at(0, 4);
flywheelRefEntry = shuffleboardTab.addEntry("Flywheel ref", 0).at(0, 3);
turntablePosEntry = shuffleboardTab.addEntry("Turntable pos", 0).at(1, 4);
turntableRefEntry = shuffleboardTab.addEntry("Turntable ref", 0).at(1, 3);
hoodPosEntry = shuffleboardTab.addEntry("Hood pos", 0).at(2, 4);
hoodRefEntry = shuffleboardTab.addEntry("Hood ref", 0).at(2, 3);

rEntry = shuffleboardTab.addEntry("r", 0).at(0, 1);
thetaEntry = shuffleboardTab.addEntry("theta", 0).at(1, 1);
distOffsetEntry = shuffleboardTab.addEntry("r offset", 0).at(0, 0);
turnOffsetEntry = shuffleboardTab.addEntry("theta offset", 0).at(1, 0);

flyReadyEntry = shuffleboardTab.addEntry("Fly ready", false).at(2, 2);
turnReadyEntry = shuffleboardTab.addEntry("Turn ready", false).at(3, 2);
hoodReadyEntry = shuffleboardTab.addEntry("Hood ready", false).at(4, 2);
jetsonDetectedEntry = shuffleboardTab.addEntry("Jetson data", false).at(1, 2);
runFlywheelEntry = shuffleboardTab.addEntry("Run flywheel", false).at(2, 3);
driverOverrideEntry = shuffleboardTab.addEntry("Driver override flywheel", driverOverrideFlywheel).at(3, 3);
turretModeEntry = shuffleboardTab.addEntry("Turret mode", mode.toString()).at(1, 3);
flyReadyEntry = shuffleboardTab.addEntry("Fly ready", false).at(0, 2);
turnReadyEntry = shuffleboardTab.addEntry("Turn ready", false).at(1, 2);
hoodReadyEntry = shuffleboardTab.addEntry("Hood ready", false).at(2, 2);
jetsonDetectedEntry = shuffleboardTab.addEntry("Jetson data", false).at(3, 0);
runFlywheelEntry = shuffleboardTab.addEntry("Run flywheel", false).at(3, 1);
driverOverrideEntry = shuffleboardTab.addEntry("Driver override flywheel", driverOverrideFlywheel).at(4, 2);
turretModeEntry = shuffleboardTab.addEntry("Turret mode", mode.toString()).at(2, 1);

shuffleboardTab.addToggle("Jetson disabled", jetsonDisabled, this::setDisableJetson, 0, 2);
shuffleboardTab.addToggle("Jetson disabled", jetsonDisabled, this::setDisableJetson, 4, 0);
// shuffleboardTab.addListener("Freeze turret", frozen, this::setFreeze);

// If DEBUG_PID is set, allow for PID tuning on shuffleboard
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,21 @@ public void periodic() {
// Spin the top motor on a timer
exitTimer.start();
motorTop.set(0.5);
stagingExitBall = true;
Copy link
Member Author

Choose a reason for hiding this comment

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

So the way the two ball shot delay was fixed was to remove the final ball state entirely? Perhaps just commenting out the !stagingExitBall check on line 166 would be a better solution which still represents the ball count semi-accurately?

// TEST stagingExitBall = true;
}

/*if (stagingExitBall) {
motorTop.set(0.5);
}
*/

// shot requested, timer starts, while ball is in staging timer keeps
// starting, when ball exits staging 0.5
// seconds after shot is finished, if in that time period 0<t<0.5
// another ball is detected, timer *should* reset
// however if there is still 1 or 0 balls in internals, shot is
// finished and timer will not start again if ball is detected

// If 0.5 seconds have elapsed, mark the shot as finished
if (exitTimer.hasElapsed(0.5)) {
exitTimer.stop();
Expand All @@ -215,18 +227,18 @@ public void periodic() {

// Reset states
// If the only ball in the system is the one we just shot, mark the shot as completed
if (ballCount <= 1) shotRequested = false;
if (ballCount < 1) shotRequested = false;
rejectingChecked = 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.

This is a little more complicated. If we skip the stagingExitBall timer and don't wait the 0.5 seconds, rejection logic won't check the color of the second ball. If the two balls are of different colors, it will shoot both either rejecting or shooting (which is bad in both cases).

Copy link
Member Author

Choose a reason for hiding this comment

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

Perhaps a solution is to only skip the stagingExitBall check if the balls are of the same color? Might be a bit messy to implement

skipToleranceCheck = false;
stagingExitBall = false;
// TEST stagingExitBall = false;
}

// Set the ball count from staging, storage, and the transition state booleans.
ballCount = (entranceStorageBall ? 1 : 0)
+ (storageDetected ? 1 : 0)
+ (storageStagingBall ? 1 : 0)
+ (stagingDetected ? 1 : 0)
+ (stagingExitBall ? 1 : 0);
+ (stagingDetected ? 1 : 0) ;
// TEST + (stagingExitBall ? 1 : 0);
ballCountEntry.setValue(ballCount);

turretSubsystem.setBallReady(ballCount > 0);
Expand Down