Skip to content

Commit 2926bca

Browse files
committed
Merge branch 'kraken' of https://github.com/Nins97/Competition2024 into kraken
2 parents 45299e0 + 979b5f3 commit 2926bca

File tree

5 files changed

+58
-10
lines changed

5 files changed

+58
-10
lines changed

src/main/java/frc/robot/Constants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ public static class LEDConstants {
316316
public static final int PWM_PORT = 0;
317317
public static final int FRONT_LEFT_SIZE = 12;
318318
public static final int FRONT_RIGHT_SIZE = 12;
319+
public static final int STATUS_DEDICATED_SIZE = 2;
319320
public static final int BACK_LEFT_SIZE = 14;
320321
public static final int BACK_RIGHT_SIZE = 14;
321322

src/main/java/frc/robot/RobotContainer.java

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ public class RobotContainer {
7676
private final ListenableSendableChooser<Command> driveCommandChooser =
7777
new ListenableSendableChooser<>();
7878

79+
private final AtomicBoolean signalHumanPlayer = new AtomicBoolean(false);
80+
7981
public RobotContainer() {
8082
configureDriverBindings();
8183
configureOperatorBindings();
@@ -88,6 +90,30 @@ public RobotContainer() {
8890
}
8991

9092
private void configureLEDs() {
93+
// Default state for homing lights
94+
ledSubsystem.setStatusLight(0, Color.kRed);
95+
ledSubsystem.setStatusLight(1, Color.kRed);
96+
97+
// Set homing lights to state
98+
new Trigger(slapdownSuperstructure.getSlapdownRotationSubsystem()::isHomed).onFalse(
99+
Commands.runOnce(() -> {
100+
ledSubsystem.setStatusLight(0, Color.kRed);
101+
}).ignoringDisable(true).withName("SlapdownLEDStatusFalse")
102+
).onTrue(
103+
Commands.runOnce(() -> {
104+
ledSubsystem.setStatusLight(0, Color.kGreen);
105+
}).ignoringDisable(true).withName("SlapdownLEDStatusTrue")
106+
);
107+
new Trigger(elevatorSubsystem::isHomed).onFalse(
108+
Commands.runOnce(() -> {
109+
ledSubsystem.setStatusLight(1, Color.kRed);
110+
}).ignoringDisable(true).withName("ElevatorLEDStatusFalse")
111+
).onTrue(
112+
Commands.runOnce(() -> {
113+
ledSubsystem.setStatusLight(1, Color.kGreen);
114+
}).ignoringDisable(true).withName("ElevatorLEDStatusTrue")
115+
);
116+
91117
AtomicBoolean shouldBlink = new AtomicBoolean();
92118
new Trigger(transportSubsystem::atSensor)
93119
.onTrue(
@@ -98,16 +124,20 @@ private void configureLEDs() {
98124

99125
List<LEDState> ledStates =
100126
List.of(
127+
new LEDState(
128+
signalHumanPlayer::get,
129+
new AlternatePattern(0.5, Color.kOrange, Color.kBlack)),
101130
// Red blink if we have any faults
102131
new LEDState(
103132
() -> Alert.getDefaultGroup().hasAnyErrors(),
104133
new AlternatePattern(2.0, Color.kRed, Color.kBlack)),
134+
// Green if we can go under the stage
105135
new LEDState(
106136
shouldBlink::get, new AlternatePattern(0.5, Color.kAliceBlue, Color.kBlack)),
107137
new LEDState(
108138
() ->
109139
DriverStation.isTeleopEnabled()
110-
&& elevatorSubsystem.atBottomLimit()
140+
&& elevatorSubsystem.atBottom()
111141
&& wristSubsystem.atBottom(),
112142
new SolidPattern(Color.kGreen)),
113143
// Default disabled pattern
@@ -140,9 +170,14 @@ private void configureDriverBindings() {
140170
.whileTrue(
141171
Commands.parallel(
142172
IntakingCommands.intakeUntilDetected(
143-
intakeSubsystem, slapdownSuperstructure, transportSubsystem)));
144-
driverController.rightTrigger().onFalse(slapdownSuperstructure.setUpCommand());
173+
intakeSubsystem, slapdownSuperstructure, transportSubsystem))).onFalse(
174+
slapdownSuperstructure.setUpCommand()
175+
);
145176
driverController.circle().whileTrue(new LockModulesCommand(driveSubsystem).repeatedly());
177+
178+
driverController.a().onTrue(Commands.runOnce(() -> signalHumanPlayer.set(true))).onFalse(
179+
Commands.sequence(Commands.waitSeconds(1.5), Commands.runOnce(() -> signalHumanPlayer.set(false)))
180+
);
146181
}
147182

148183
private void configureOperatorBindings() {
@@ -151,7 +186,7 @@ private void configureOperatorBindings() {
151186
.onTrue(
152187
Commands.parallel(
153188
ScoringCommands.shootSetpointAmpCommand(shooterSubsystem),
154-
transportSubsystem.setVoltageCommand(12)));
189+
transportSubsystem.setVoltageCommand(10)));
155190
operatorController
156191
.triangle()
157192
.onTrue(

src/main/java/frc/robot/subsystems/elevator/ElevatorSubsystem.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,10 @@ public boolean atGoal() {
195195
return controller.atGoal();
196196
}
197197

198+
public boolean atBottom() {
199+
return controller.getGoal().position == ELEVATOR_MIN_HEIGHT && atGoal();
200+
}
201+
198202
public Command setFollowerCommand(double voltage) {
199203
return this.run(() -> elevatorMotorFollower.setVoltage(voltage));
200204
}

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

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public class LEDSubsystem extends SubsystemBase {
1717
private final ParentAddressableLEDBuffer ledBuffer = new ParentAddressableLEDBuffer(TOTAL_SIZE);
1818
private final RaiderAddressableLEDBuffer[] splitBuffers;
1919
private final Pattern[] patterns;
20+
private final RaiderAddressableLEDBuffer statusDedicatedBuffer;
2021
private double patternStartTime = 0.0;
2122

2223
public LEDSubsystem() {
@@ -29,21 +30,24 @@ public LEDSubsystem() {
2930
}
3031
i += FRONT_LEFT_SIZE;
3132

32-
splitBuffers[1] = ledBuffer.split(i, i + BACK_LEFT_SIZE);
33-
splitBuffers[1] = splitBuffers[1].reversed();
33+
int effectiveBackLeftSize = BACK_LEFT_SIZE - STATUS_DEDICATED_SIZE;
34+
// Pre-concatenate a buffer for the status dedicated LEDs so it appears the saem as the rest
35+
splitBuffers[1] = ledBuffer.split(i, i + effectiveBackLeftSize).reversed().preConcatenate(new FakeLEDBuffer(STATUS_DEDICATED_SIZE));
3436
if (BACK_LEFT_SIZE < MAX_SIZE) {
3537
splitBuffers[1] = splitBuffers[1].concatenate(new FakeLEDBuffer(MAX_SIZE - BACK_LEFT_SIZE));
3638
}
37-
i += BACK_LEFT_SIZE;
39+
i += effectiveBackLeftSize;
40+
41+
statusDedicatedBuffer = ledBuffer.split(i, i + STATUS_DEDICATED_SIZE);
42+
i += STATUS_DEDICATED_SIZE;
3843

3944
splitBuffers[2] = ledBuffer.split(i, i + BACK_RIGHT_SIZE);
4045
if (BACK_RIGHT_SIZE < MAX_SIZE) {
4146
splitBuffers[2] = splitBuffers[2].concatenate(new FakeLEDBuffer(MAX_SIZE - BACK_RIGHT_SIZE));
4247
}
4348
i += BACK_RIGHT_SIZE;
4449

45-
splitBuffers[3] = ledBuffer.split(i, i + FRONT_RIGHT_SIZE);
46-
splitBuffers[3] = splitBuffers[3].reversed();
50+
splitBuffers[3] = ledBuffer.split(i, i + FRONT_RIGHT_SIZE).reversed();
4751
if (FRONT_RIGHT_SIZE < MAX_SIZE) {
4852
splitBuffers[3] = splitBuffers[3].concatenate(new FakeLEDBuffer(MAX_SIZE - FRONT_RIGHT_SIZE));
4953
}
@@ -59,6 +63,10 @@ public LEDSubsystem() {
5963
led.start();
6064
}
6165

66+
public void setStatusLight(int i, Color color) {
67+
statusDedicatedBuffer.setLED(i, color);
68+
}
69+
6270
public void setAllPattern(Pattern pattern, boolean forceRestart) {
6371
setPatterns(forceRestart, pattern, pattern, pattern, pattern);
6472
}

src/main/java/frc/robot/subsystems/slapdown/SlapdownRotationSubsystem.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ private boolean atLimit() {
146146
return !rotationLimitSwitch.get();
147147
}
148148

149-
private boolean isHomed() {
149+
public boolean isHomed() {
150150
return isHomed;
151151
}
152152

0 commit comments

Comments
 (0)