-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSuperstructure.java.diff
More file actions
166 lines (159 loc) · 7.35 KB
/
Superstructure.java.diff
File metadata and controls
166 lines (159 loc) · 7.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
diff --git a/src/main/java/frc/robot/subsystems/Superstructure.java b/src/main/java/frc/robot/subsystems/Superstructure.java
index e558150..8456e4b 100644
--- a/src/main/java/frc/robot/subsystems/Superstructure.java
+++ b/src/main/java/frc/robot/subsystems/Superstructure.java
@@ -10,6 +10,7 @@ import edu.wpi.first.math.kinematics.ChassisSpeeds;
import edu.wpi.first.math.util.Units;
import edu.wpi.first.wpilibj.DriverStation;
import edu.wpi.first.wpilibj.DriverStation.Alliance;
+import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc.robot.Constants.SuperstructureConstants;
import frc.robot.FieldConstants.Reef;
@@ -145,6 +146,8 @@ private boolean requestPrevClimberState = false;
private boolean requestPostAlgaeIdle = false;
private boolean spinIntakeInAuto = true;
+ private Timer l1BarButtonHysterisis = new Timer();
+
private static final LoggedTunableNumber NET_PRE_PLACE_HEIGHT =
new LoggedTunableNumber("Net/PrePlaceHeight", 10.4);
private static final LoggedTunableNumber NET_PRE_PLACE_ANGLE =
@@ -303,7 +306,6 @@ private static final LoggedTunableNumber L1_PROJECTION_DISTANCE =
if (requestHome) {
nextSystemState = SuperstructureState.HOMING;
} else if (requestIntake) {
- requestL1IntakeHold = false;
nextSystemState = SuperstructureState.INTAKING_CORAL_PREPARE;
} else if (requestGrabAlgae) {
nextSystemState = SuperstructureState.GRABBING_ALGAE_L3;
@@ -510,69 +512,30 @@ private static final LoggedTunableNumber L1_PROJECTION_DISTANCE =
nextSystemState = SuperstructureState.SCORE_PROCESSOR;
}
} else if (systemState == SuperstructureState.INTAKING_CORAL_PREPARE) {
- // Rotation2d targetAngle = Rotation2d.fromDegrees(83.3203125);
- // double currentElevatorHeight = elevatorPivot.getElevatorHeight();
-
- // if (elevatorPivot.atPivotSetpoint(targetAngle)) {
- // elevatorPivot.requestPursueSetpoint(Units.inchesToMeters(7.4), targetAngle);
- // } else {
- // elevatorPivot.requestPursueSetpoint(currentElevatorHeight, targetAngle);
- // }
elevatorPivot.requestPursueSetpoint(Units.inchesToMeters(7.461260815952846), Rotation2d.fromDegrees(92.109375));
- if (!bypassIntakeControl) {
- intake.requestIntakeWithSpin();
- }
indexer.requestIntake();
endeffector.requestIntakeCoral();
+ boolean l1SelectButtonState = RobotContainer.driver.getRightStickButton();
+ // NOTE: These 'stateful' released/pressed checks can only
+ // be used from one place in the code for each button!
+ if (RobotContainer.driver.getRightStickButtonReleased()) {
+ l1BarButtonHysterisis.reset();
+ l1BarButtonHysterisis.start();
+ }
+ // Override the button state to still be pressed if the timer hasn't hit yet
+ if (!l1BarButtonHysterisis.hasElapsed(0.2)) {
+ l1SelectButtonState = true;
+ }
- // if (requestManualUnjam) {
- // nextSystemState = SuperstructureState.MANUAL_UNJAM;
- // }
-
- // if (RobotContainer.hasGutPiece() && endeffector.hasCoral()) {
- // nextSystemState = SuperstructureState.UNJAM_GUT;
- // }
-
-
-
- // if (requestManualUnjam) {
- // nextSystemState = SuperstructureState.MANUAL_UNJAM;
- // } else if (RobotContainer.hasGutPiece() && endeffector.hasCoral()) {
- // nextSystemState = SuperstructureState.UNJAM_GUT;
- // } else if (requestHome) {
- // nextSystemState = SuperstructureState.HOMING;
- // } else if (RobotContainer.hasGutPiece()) {
- // nextSystemState = SuperstructureState.INTAKING_CORAL_GUT;
- // } else if (!requestIntake) {
- // if (RobotContainer.numpad.getSelectedLevel() == Level.L1 && !endeffector.hasCoral()) {
- // nextSystemState = SuperstructureState.L1_INTAKE_HOLD;
- // requestL1IntakeHold = true;
- // } else if (endeffector.hasCoral()) {
- // nextSystemState = getIdleStateBasedOnGamePieces();
- // } else {
- // nextSystemState = getIdleStateBasedOnGamePieces();
- // }
- // }
+ if (!bypassIntakeControl && requestIntake) {
+ if (l1SelectButtonState) {
+ intake.requestL1Intake();
+ } else {
+ intake.requestIntakeWithSpin();
+ }
+ }
- // if (RobotContainer.hasGutPiece() && !endeffector.hasCoral()) {
- // nextSystemState = SuperstructureState.INTAKING_CORAL_GUT;
- // } else if (RobotContainer.hasGutPiece() && endeffector.hasCoral()) {
- // nextSystemState = SuperstructureState.UNJAM_GUT;
- // } else if (requestManualUnjam) {
- // nextSystemState = SuperstructureState.MANUAL_UNJAM;
- // } else if (requestHome) {
- // nextSystemState = SuperstructureState.HOMING;
- // } else if (!requestIntake) {
- // if (RobotContainer.numpad.getSelectedLevel() == Level.L1 && !endeffector.hasCoral()) {
- // nextSystemState = SuperstructureState.L1_INTAKE_HOLD;
- // requestL1IntakeHold = true;
- // } else if (endeffector.hasCoral()) {
- // nextSystemState = getIdleStateBasedOnGamePieces();
- // } else {
- // nextSystemState = getIdleStateBasedOnGamePieces();
- // }
- // }\
if (RobotContainer.hasGutPiece() && !endeffector.hasCoral()) {
nextSystemState = SuperstructureState.INTAKING_CORAL_GUT;
} else if (RobotContainer.hasGutPiece() && endeffector.hasCoral()) {
@@ -584,9 +547,8 @@ private static final LoggedTunableNumber L1_PROJECTION_DISTANCE =
} else if (endeffector.hasCoral() && DriverStation.isAutonomous()) {
nextSystemState = getIdleStateBasedOnGamePieces();
} else if (!requestIntake) {
- if ((RobotContainer.numpad.getSelectedLevel() == Level.L1 || RobotContainer.driver.getRightStickButton()) && !endeffector.hasCoral()) {
+ if (l1SelectButtonState && !endeffector.hasCoral()) {
nextSystemState = SuperstructureState.L1_INTAKE_HOLD;
- requestL1IntakeHold = true;
} else if (endeffector.hasCoral()) {
nextSystemState = getIdleStateBasedOnGamePieces();
} else {
@@ -1375,13 +1337,17 @@ boolean timeCondition = stateElapsedTime > 0.5;
} else if (!requestL1IntakeHold) {
nextSystemState = getIdleStateBasedOnGamePieces();
}
- }
- else if (systemState == SuperstructureState.L1_SPIT_PIECE) {
+ }
+ else if (systemState == SuperstructureState.L1_SPIT_PIECE) {
intake.requestL1Spit();
indexer.requestIdle();
endeffector.requestIdle();
double stateElapsedTime = BreadUtil.getFPGATimeSeconds() - stateStartTime;
+
+ if (stateElapsedTime > 5.0) {
+ requestL1Spit = false;
+ }
if (requestManualUnjam) {
nextSystemState = SuperstructureState.MANUAL_UNJAM;
@@ -1391,16 +1357,8 @@ boolean timeCondition = stateElapsedTime > 0.5;
} else {
nextSystemState = getIdleStateBasedOnGamePieces();
}
- } else if (stateElapsedTime > 5.0) {
- requestL1Spit = false;
- if (requestL1IntakeHold) {
- nextSystemState = SuperstructureState.L1_INTAKE_HOLD;
- } else {
- nextSystemState = getIdleStateBasedOnGamePieces();
- }
}
- }
-
+ }
if (systemState != nextSystemState) {
stateStartTime = BreadUtil.getFPGATimeSeconds();