Skip to content
Closed
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
6421de4
Add initial AddressableLED subsystem implementation
RobotLeopard86 Feb 25, 2025
fa8e40a
Fix missing imports and improper record access
RobotLeopard86 Feb 25, 2025
8b27e76
Add missing @Override declarations and add Javadoc
RobotLeopard86 Feb 25, 2025
b26a7b9
Merge branch 'main' into addressable-led
RobotLeopard86 Feb 25, 2025
b51bcd3
Merge branch 'main' into addressable-led
RobotLeopard86 Feb 26, 2025
e827996
Address code review feedback for AddressableLED subsystem and add sca…
RobotLeopard86 Feb 27, 2025
fad22db
Add AddressableLED testing command
RobotLeopard86 Feb 27, 2025
74fb53f
Actually apply the patterns for the AddressableLED test
RobotLeopard86 Feb 27, 2025
0cc78fe
Run Spotless!
RobotLeopard86 Feb 27, 2025
40c06ef
Merge branch 'main' into addressable-led
RobotLeopard86 Feb 27, 2025
7f0147c
Add Javadocs for AddressableLED subsystem
RobotLeopard86 Feb 27, 2025
13ba9fe
Merge branch 'addressable-led' of https://github.com/redshiftrobotics…
RobotLeopard86 Feb 27, 2025
6cf0918
Clarify separation between Blinkin and AddressableLED subsystems
RobotLeopard86 Mar 1, 2025
fd39f56
Main -> addressable-led merge
RobotLeopard86 Mar 1, 2025
e9c44d4
Fix Wrist build error resulting from main merge
RobotLeopard86 Mar 1, 2025
d3c6e7b
Add superstructure LED patterns
RobotLeopard86 Mar 1, 2025
9efff02
Fix errors
RobotLeopard86 Mar 1, 2025
650ee6b
Merge branch 'main' into addressable-led
RobotLeopard86 Mar 1, 2025
79bca46
Remove redundant null check
RobotLeopard86 Mar 1, 2025
0b9126f
Add appropriate Javadoc for subsystem
RobotLeopard86 Mar 1, 2025
ebcae4c
Run autoformatting
bforcum Mar 1, 2025
cead75c
Refactor LED pattern manipulation to be within subsystems instead of …
RobotLeopard86 Mar 1, 2025
e6fedd3
Merge branch 'main' into addressable-led
MichaelLesirge Mar 4, 2025
8fcde4c
Merge branch 'main' into addressable-led
MichaelLesirge Mar 4, 2025
b5dda59
fix build
MichaelLesirge Mar 4, 2025
d3ffd09
Merge branch 'main' into addressable-led
AceiusRedshift Mar 12, 2025
21a0484
fix
AceiusRedshift Mar 12, 2025
f2ed688
Integrate LEDs into robot container and superstructure
AceiusRedshift Mar 12, 2025
ed4e9b5
ok good enough
AceiusRedshift Mar 12, 2025
ea88276
Merge branch 'main' into addressable-led
RobotLeopard86 Mar 13, 2025
b545f59
Fix incorrect AddressableLED test end check and clarify Range record …
RobotLeopard86 Mar 13, 2025
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
5 changes: 5 additions & 0 deletions src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ private static RobotType determineRobotType() {
return null;
}

/**
* Set this to true to completely disable usage of the AddressableLED subsystem, no matter what
*/
public static boolean MASTER_LED_DISABLE = false;

private static final Alert wrongRobotTypeAlertReal =
new Alert(
String.format(
Expand Down
26 changes: 20 additions & 6 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import edu.wpi.first.wpilibj.RobotBase;
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj.util.Color;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.CommandScheduler;
import edu.wpi.first.wpilibj2.command.Commands;
Expand All @@ -30,6 +31,7 @@
import frc.robot.commands.controllers.SpeedLevelController;
import frc.robot.commands.intake.SetIntakeSpeed;
import frc.robot.commands.wrist.SetWrist;
import frc.robot.subsystems.addressableled.AddressableLEDSubsystem;
import frc.robot.subsystems.dashboard.DriverDashboard;
import frc.robot.subsystems.drive.Drive;
import frc.robot.subsystems.drive.DriveConstants;
Expand Down Expand Up @@ -86,6 +88,7 @@ public class RobotContainer {
private final Wrist wrist;
private final AlgaeIntake algaeIntake;
private final CoralIntake coralIntake;
private final AddressableLEDSubsystem led;

private final Hang hang;

Expand Down Expand Up @@ -145,6 +148,7 @@ public RobotContainer() {
elevator = new Elevator(new ElevatorIOHardwareFollow(ElevatorConstants.ELEVATOR_CONFIG));
hang = new Hang(new HangIOHardwareRelative(HangConstants.HANG_CONFIG));
wrist = new Wrist(new WristIO() {});
led = new AddressableLEDSubsystem(false);

// algaeIntake =
// new AlgaeIntake(
Expand Down Expand Up @@ -181,6 +185,7 @@ public RobotContainer() {

algaeIntake = new AlgaeIntake(new IntakeIO() {});
coralIntake = new CoralIntake(new IntakeIO() {});
led = new AddressableLEDSubsystem(true);

break;

Expand All @@ -201,6 +206,7 @@ public RobotContainer() {

algaeIntake = new AlgaeIntake(new IntakeIO() {});
coralIntake = new CoralIntake(new IntakeIO() {});
led = new AddressableLEDSubsystem(true);

break;

Expand All @@ -221,6 +227,7 @@ public RobotContainer() {

algaeIntake = new AlgaeIntake(new IntakeIO() {});
coralIntake = new CoralIntake(new IntakeIO() {});
led = new AddressableLEDSubsystem(true);

break;

Expand All @@ -245,6 +252,7 @@ public RobotContainer() {
wrist = new Wrist(new WristIOSim());
algaeIntake = new AlgaeIntake(new IntakeIOSim());
coralIntake = new CoralIntake(new IntakeIOSim());
led = new AddressableLEDSubsystem(true);
break;

default:
Expand All @@ -264,12 +272,13 @@ public RobotContainer() {

algaeIntake = new AlgaeIntake(new IntakeIO() {});
coralIntake = new CoralIntake(new IntakeIO() {});
led = new AddressableLEDSubsystem(true);

break;
}

// Superstructure
superstructure = new Superstructure(elevator, wrist);
superstructure = new Superstructure(elevator, wrist, led);

// Vision setup
// vision.setLastRobotPoseSupplier(drive::getRobotPose);
Expand Down Expand Up @@ -504,18 +513,23 @@ private void configureDriverControllerBindings(boolean includeAutoAlign) {
private void configureOperatorControllerBindings() {
operatorController.back().onTrue(drive.runOnce(drive::stop).withName("CANCEL and stop"));

configureOperatorControllerBindingLevel(operatorController.y(), Superstructure.State.L4);
configureOperatorControllerBindingLevel(operatorController.x(), Superstructure.State.L3);
configureOperatorControllerBindingLevel(operatorController.b(), Superstructure.State.L2);
configureOperatorControllerBindingLevel(operatorController.a(), Superstructure.State.L1);
configureOperatorControllerBindingLevel(
operatorController.y(), Superstructure.State.L4, Color.kAqua);
configureOperatorControllerBindingLevel(
operatorController.x(), Superstructure.State.L3, Color.kGold);
configureOperatorControllerBindingLevel(
operatorController.b(), Superstructure.State.L2, Color.kLime);
configureOperatorControllerBindingLevel(
operatorController.a(), Superstructure.State.L1, Color.kPurple);

operatorController.leftBumper().whileTrue(hang.set(+0.5).withName("Hang Arm Up"));
operatorController.rightBumper().whileTrue(hang.set(-0.5).withName("Hang Arm Down"));
}

private void configureOperatorControllerBindingLevel(
Trigger trigger, Superstructure.State state) {
Trigger trigger, Superstructure.State state, Color color) {
trigger.onTrue(superstructure.setNextPrepare(state));

trigger.and(operatorController.rightTrigger()).onTrue(superstructure.runPrepare(state));
}

Expand Down
57 changes: 57 additions & 0 deletions src/main/java/frc/robot/commands/SetAddressableLEDPattern.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package frc.robot.commands;

import edu.wpi.first.wpilibj.LEDPattern;
import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.subsystems.addressableled.AddressableLEDSubsystem;

public class SetAddressableLEDPattern extends Command {
private final AddressableLEDSubsystem ledSystem;

/**
* @apiNote If this is empty, that means that this command is targeting the whole strip
*/
private final int[] sections;

private final LEDPattern pattern;

/**
* @param led Addressable LED subsystem to use
* @param pattern Pattern to apply when command run
* @param section Section of LED strip to apply pattern to (index into
* AddressableLEDConstants.SECTIONS)
*/
public SetAddressableLEDPattern(
AddressableLEDSubsystem ledSystem, LEDPattern pattern, int... sections) {
this.sections = sections;
this.pattern = pattern;
this.ledSystem = ledSystem;
addRequirements(ledSystem);
}

/**
* @param led Addressable LED subsystem to use
* @param pattern Pattern to apply when command run
*/
public SetAddressableLEDPattern(AddressableLEDSubsystem ledSystem, LEDPattern pattern) {
sections = new int[0];
this.pattern = pattern;
this.ledSystem = ledSystem;
addRequirements(ledSystem);
}

@Override
public void execute() {
if (sections.length <= 0) {
ledSystem.applyPattern(pattern);
} else {
for (int i = 0; i < sections.length; i++) {
ledSystem.applySectionedPattern(pattern, sections[i]);
}
}
}

@Override
public boolean isFinished() {
return true;
}
}
43 changes: 43 additions & 0 deletions src/main/java/frc/robot/commands/SetBlinkinLEDPattern.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package frc.robot.commands;

import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.subsystems.blinkinled.BlinkinLEDSubsystem;

public class SetBlinkinLEDPattern extends Command {
private BlinkinLEDSubsystem ledSystem;
private double pattern;

/**
* @apiNote If this is -1, that means that this command is targeting the whole strip
*/
private int section;

private boolean invalid;

public SetBlinkinLEDPattern(BlinkinLEDSubsystem ledSystem, int section, double pattern) {
invalid = (section < -1 || section >= ledSystem.stripCount);
this.section = section;
this.ledSystem = ledSystem;
this.pattern = pattern;
}

public SetBlinkinLEDPattern(BlinkinLEDSubsystem led, double pattern) {
this(led, -1, pattern);
}

@Override
public void initialize() {
if (invalid) return;
if (section == -1) {
ledSystem.applyPatternToAll(pattern);
} else {
ledSystem.applyPatternTo(section, pattern);
}
}

// Since executing the command is a one-time thing, we always report being done instantly
@Override
public boolean isFinished() {
return true;
}
}
46 changes: 0 additions & 46 deletions src/main/java/frc/robot/commands/SetLightPattern.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package frc.robot.commands.test;

import static edu.wpi.first.units.Units.MetersPerSecond;
import static edu.wpi.first.units.Units.Seconds;

import edu.wpi.first.wpilibj.LEDPattern;
import edu.wpi.first.wpilibj.util.Color;
import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.subsystems.addressableled.AddressableLEDConstants;
import frc.robot.subsystems.addressableled.AddressableLEDSubsystem;

public class AddressableLEDTestCommand extends Command {
private final AddressableLEDSubsystem ledSystem;
private LEDPattern currentPattern;
private int ticker = 0;
private int testCount = 0;

public AddressableLEDTestCommand(AddressableLEDSubsystem ledSystem) {
this.ledSystem = ledSystem;
addRequirements(ledSystem);
}

@Override
public void initialize() {
ticker = 0;
testCount = 0;
currentPattern =
LEDPattern.rainbow(255, 128)
.scrollAtAbsoluteSpeed(MetersPerSecond.of(1), AddressableLEDConstants.LED_DENSITY);
}

@Override
public void execute() {
if (ticker < 500) {
ticker++;
} else {
ticker = 0;
ledSystem.applySectionedPattern(LEDPattern.kOff, testCount);
testCount++;
if (testCount == AddressableLEDConstants.SECTIONS.length) {
currentPattern = LEDPattern.solid(Color.kLimeGreen).breathe(Seconds.of(2));
ledSystem.applyPattern(currentPattern);
} else {
ledSystem.applySectionedPattern(currentPattern, testCount);
}
}
}

@Override
public boolean isFinished() {
return testCount < (AddressableLEDConstants.SECTIONS.length + 1);
}

@Override
public void end(boolean interrupted) {
ledSystem.applyPattern(LEDPattern.kOff);
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package frc.robot.commands.test;

import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.subsystems.led.LEDConstants;
import frc.robot.subsystems.led.LEDSubsystem;
import frc.robot.subsystems.blinkinled.BlinkinLEDConstants;
import frc.robot.subsystems.blinkinled.BlinkinLEDSubsystem;

public class LEDTestCommand extends Command {
private LEDSubsystem ledSystem;
public class BlinkinLEDTestCommand extends Command {
private BlinkinLEDSubsystem ledSystem;

private double currentPattern;

Expand All @@ -17,14 +17,14 @@ public class LEDTestCommand extends Command {
* @param time Time in robot updates to wait between changes (each update is 20ms, so 50 updates
* is 1 second)
*/
public LEDTestCommand(LEDSubsystem led, int time) {
public BlinkinLEDTestCommand(BlinkinLEDSubsystem led, int time) {
ledSystem = led;
delay = time;
}

@Override
public void initialize() {
currentPattern = LEDConstants.LEDPatterns.BLACK;
currentPattern = BlinkinLEDConstants.Patterns.BLACK;
ticker = 0;
}

Expand All @@ -39,11 +39,11 @@ public void execute() {

@Override
public boolean isFinished() {
return currentPattern <= LEDConstants.LEDPatterns.HOT_PINK;
return currentPattern <= BlinkinLEDConstants.Patterns.HOT_PINK;
}

@Override
public void end(boolean interrupted) {
currentPattern = LEDConstants.LEDPatterns.BLACK;
currentPattern = BlinkinLEDConstants.Patterns.BLACK;
}
}
Loading