Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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 @@ -94,6 +94,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
20 changes: 18 additions & 2 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import frc.robot.commands.ManualAlignCommands;
import frc.robot.commands.controllers.JoystickInputController;
import frc.robot.commands.controllers.SpeedLevelController;
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 @@ -79,7 +80,6 @@
* subsystems, commands, and button mappings) should be declared here.
*/
public class RobotContainer {

// Subsystems
private final Drive drive;
private final AprilTagVision vision;
Expand All @@ -92,6 +92,8 @@ public class RobotContainer {

private final Hang hang;

private final AddressableLEDSubsystem lights;

// Controller
private final CommandXboxController driverController = new CommandXboxController(0);
private final CommandXboxController operatorController = new CommandXboxController(1);
Expand Down Expand Up @@ -126,6 +128,8 @@ public class RobotContainer {

/** The container for the robot. Contains subsystems, IO devices, and commands. */
public RobotContainer() {
final boolean lightsAreFake;

switch (Constants.getRobot()) {
case COMP_BOT_2025:
// Real robot (Competition bot with mechanisms), instantiate hardware IO implementations
Expand All @@ -148,6 +152,8 @@ public RobotContainer() {
hang = new Hang(new HangIOHardware(HangConstants.HANG_CONFIG));
coralWrist = new Wrist(new WristIOHardware(WristConstants.WRIST_CONFIG));
coralIntake = new Intake(new IntakeIOHardware(IntakeConstants.CORAL_INTAKE_CONFIG));

lightsAreFake = false;
break;

case WOOD_BOT_TWO_2025:
Expand All @@ -164,6 +170,8 @@ public RobotContainer() {
hang = new Hang(new HangIO() {});
coralWrist = new Wrist(new WristIO() {});
coralIntake = new Intake(new IntakeIO() {});

lightsAreFake = false;
break;

case T_SHIRT_CANNON_CHASSIS:
Expand All @@ -180,6 +188,8 @@ public RobotContainer() {
elevator = new Elevator(new ElevatorIO() {});
coralWrist = new Wrist(new WristIO() {});
coralIntake = new Intake(new IntakeIO() {});

lightsAreFake = true;
break;

case CRESCENDO_CHASSIS_2024:
Expand All @@ -199,6 +209,7 @@ public RobotContainer() {

coralIntake = new Intake(new IntakeIO() {});

lightsAreFake = true;
break;

case SIM_BOT:
Expand All @@ -221,6 +232,8 @@ public RobotContainer() {
elevator = new Elevator(new ElevatorIOSim());
coralWrist = new Wrist(new WristIOSim(WristConstants.WRIST_CONFIG));
coralIntake = new Intake(new IntakeIOSim());

lightsAreFake = true;
break;

default:
Expand All @@ -238,11 +251,14 @@ public RobotContainer() {
coralWrist = new Wrist(new WristIO() {});
coralIntake = new Intake(new IntakeIO() {});

lightsAreFake = true;
break;
}

lights = new AddressableLEDSubsystem(lightsAreFake);

// Superstructure
superstructure = new Superstructure(elevator, coralWrist, coralIntake);
superstructure = new Superstructure(elevator, coralWrist, coralIntake, lights);

// Vision setup
// vision.setLastRobotPoseSupplier(drive::getRobotPose);
Expand Down
1 change: 0 additions & 1 deletion src/main/java/frc/robot/commands/DriveCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ public static Command joystickDriveWithSlowdown(
DoubleSupplier omegaSupplier,
DoubleSupplier elevatorHeightSupplier,
BooleanSupplier useFieldRelativeSupplier) {

Runnable drive =
() -> {
Translation2d translation = translationSupplier.get();
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