Skip to content

Commit 6b7be97

Browse files
committed
Merge branch 'statesDrivePractice' of https://github.com/strykeforce/reefscape into statesDrivePractice
2 parents 8e17707 + 8d1e57d commit 6b7be97

File tree

4 files changed

+49
-3
lines changed

4 files changed

+49
-3
lines changed

src/main/java/frc/robot/constants/LEDConstants.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,15 @@ public static final Color invertRedGreen(Color color) {
1313
public static final int kTotalStripLength = 51 + 10;
1414
public static final int kBottomStripLength = 34;
1515
public static final int kTopStripLength = 17;
16+
public static final int kFunnelStripLength = 10;
1617
public static final int kTopFirstIndex = kBottomStripLength;
18+
public static final int kFunnelFirstIndex = kTopFirstIndex + kTopStripLength;
1719
public static final int kAlgeaEnd = kBottomStripLength / 3 + 1;
1820

1921
public static final int kLevelStart = kTopFirstIndex;
2022
public static final int kPlaceStart = kTopFirstIndex + kTopStripLength / 3;
2123
public static final int kGetAlgeaStart = kTopFirstIndex + kTopStripLength / 3 * 2;
24+
public static final int kAlgeaHeightStart = kFunnelFirstIndex;
2225
public static final int kAutoPlacingStart = kBottomStripLength / 3 * 2 + 1;
2326

2427
public static final Color kAlmostBlack = new Color(0, 0, 1);
@@ -55,6 +58,10 @@ public static final Color invertRedGreen(Color color) {
5558
// HP Load Color
5659
public static final Color kLoadCoral = invertRedGreen(Color.kBlue);
5760

61+
// Algea Height Colors
62+
public static final Color kAlgeaLow = invertRedGreen(Color.kSaddleBrown);
63+
public static final Color kAlgeaHigh = invertRedGreen(Color.kDarkSlateBlue);
64+
5865
public static final Color[] kGameColors = {
5966
invertRedGreen(Color.kBlack), // a dummy color
6067
invertRedGreen(Color.kDarkRed),

src/main/java/frc/robot/constants/RobotStateConstants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class RobotStateConstants {
2020
public static final double kElevatorWaitRadius = 1.5;
2121

2222
// Super Cycle Constants
23-
public static final double kBiscuitSuperCycleSafeThres = 7; // 6 is max
23+
public static final double kBiscuitSuperCycleSafeThres = 8; // 6 is max
2424

2525
// Elevator good for climb, tolerates stuck coral
2626
public static final double kElevatorClimbMax = 11.4;

src/main/java/frc/robot/subsystems/led/LEDSubsystem.java

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import edu.wpi.first.wpilibj.LEDPattern;
66
import edu.wpi.first.wpilibj.util.Color;
77
import frc.robot.constants.LEDConstants;
8+
import frc.robot.subsystems.robotState.RobotStateSubsystem.AlgaeHeight;
89
import frc.robot.subsystems.robotState.RobotStateSubsystem.CoralLoc;
910
import frc.robot.subsystems.robotState.RobotStateSubsystem.ScoringLevel;
1011
import java.util.Map;
@@ -37,6 +38,11 @@ public class LEDSubsystem extends MeasurableSubsystem {
3738
Map.of(
3839
LEDConstants.kGetAlgeaStart / (double) LEDConstants.kTotalStripLength,
3940
LEDConstants.kNotGetAlgea));
41+
private LEDPattern algeaHeight =
42+
LEDPattern.steps(
43+
Map.of(
44+
LEDConstants.kAlgeaHeightStart / (double) LEDConstants.kTotalStripLength,
45+
LEDConstants.kAlgeaLow));
4046
private LEDPattern autoplace =
4147
LEDPattern.steps(
4248
Map.of(
@@ -57,6 +63,7 @@ public class LEDSubsystem extends MeasurableSubsystem {
5763
private ScoringLevel levelState = ScoringLevel.L4;
5864
private PlaceStates placeState = PlaceStates.MANUAL;
5965
private boolean shouldGetAlgae = false;
66+
private AlgaeHeight algaeHeight = AlgaeHeight.LOW;
6067
private boolean shouldLoadCoral = false;
6168
private boolean autoPlacing = false;
6269
private boolean isLimiting = false;
@@ -111,6 +118,11 @@ public void setGetAlgeaLights(boolean on) {
111118
buildBase();
112119
}
113120

121+
public void setAlgeaHeight(AlgaeHeight algaeHeight) {
122+
this.algaeHeight = algaeHeight;
123+
buildBase();
124+
}
125+
114126
public void setAutoPlacing(boolean isAutoPlacing) {
115127
autoPlacing = isAutoPlacing;
116128
buildBase();
@@ -147,6 +159,10 @@ public boolean getGetAlgeaLights() {
147159
return shouldGetAlgae;
148160
}
149161

162+
public AlgaeHeight getIsAlgeaHigh() {
163+
return algaeHeight;
164+
}
165+
150166
public boolean getAutoPlacing() {
151167
return autoPlacing;
152168
}
@@ -214,6 +230,19 @@ private void buildBase() {
214230
Map.of(
215231
LEDConstants.kGetAlgeaStart / (double) LEDConstants.kTotalStripLength,
216232
shouldGetAlgae ? LEDConstants.kGetAlgea : LEDConstants.kNotGetAlgea));
233+
switch (algaeHeight) {
234+
case HIGH -> algeaHeight =
235+
LEDPattern.steps(
236+
Map.of(
237+
LEDConstants.kAlgeaHeightStart / (double) LEDConstants.kTotalStripLength,
238+
LEDConstants.kAlgeaHigh));
239+
240+
case LOW -> algeaHeight =
241+
LEDPattern.steps(
242+
Map.of(
243+
LEDConstants.kAlgeaHeightStart / (double) LEDConstants.kTotalStripLength,
244+
LEDConstants.kAlgeaLow));
245+
}
217246
base = algae.overlayOn(coral);
218247
}
219248

@@ -227,7 +256,7 @@ private void buildBase() {
227256
if (shouldLoadCoral) {
228257
base = loadCoral.overlayOn(base);
229258
} else {
230-
base = getAlgea.overlayOn(place.overlayOn(level.overlayOn(base)));
259+
base = algeaHeight.overlayOn(getAlgea.overlayOn(place.overlayOn(level.overlayOn(base))));
231260
}
232261
}
233262

@@ -332,14 +361,22 @@ public Set<Measure> getMeasures() {
332361
"GetAlgea",
333362
"the current get algea state of the LEDSubsystem",
334363
() -> shouldGetAlgae ? 0 : 1),
364+
new Measure(
365+
"isAlgeaHigh",
366+
"The assumed Algea Height of the LEDSubsystem",
367+
() -> algaeHeight.ordinal()),
335368
new Measure(
336369
"autoPlacing",
337370
"the current autoPlacing state of the LEDSubsystem",
338371
() -> autoPlacing ? 0 : 1),
339372
new Measure(
340373
"currentLimiting",
341374
"the current currentLimiting state of the LEDSubsystem",
342-
() -> isLimiting ? 0 : 1));
375+
() -> isLimiting ? 0 : 1),
376+
new Measure(
377+
"isHPLoading",
378+
"the current HP Loading state of the LEDSubsystem",
379+
() -> shouldLoadCoral ? 0 : 1));
343380
}
344381

345382
public enum LEDStates {

src/main/java/frc/robot/subsystems/robotState/RobotStateSubsystem.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,12 @@ public void setScoreSide(ScoreSide scoreSide) {
238238

239239
public void setAlgaeHeight(AlgaeHeight algaeHeight) {
240240
this.algaeHeight = algaeHeight;
241+
ledSubsystem.setAlgeaHeight(algaeHeight);
241242
}
242243

243244
public void toggleAlgaeHeight() {
244245
algaeHeight = algaeHeight == AlgaeHeight.LOW ? AlgaeHeight.HIGH : AlgaeHeight.LOW;
246+
ledSubsystem.setAlgeaHeight(algaeHeight);
245247
}
246248

247249
public void setIsAutoPlacing(boolean isAutoPlacing) {

0 commit comments

Comments
 (0)