diff --git a/src/main/java/org/team5924/frc2025/BuildConstants.java b/src/main/java/org/team5924/frc2025/BuildConstants.java index 12067de..22bf7d0 100644 --- a/src/main/java/org/team5924/frc2025/BuildConstants.java +++ b/src/main/java/org/team5924/frc2025/BuildConstants.java @@ -21,13 +21,13 @@ public final class BuildConstants { public static final String MAVEN_GROUP = ""; public static final String MAVEN_NAME = "GoldenGateRobotics2025"; public static final String VERSION = "unspecified"; - public static final int GIT_REVISION = 284; - public static final String GIT_SHA = "95991a1e70b64e70023f2056ce1dd0e9a78f855f"; - public static final String GIT_DATE = "2025-04-05 18:55:27 EDT"; - public static final String GIT_BRANCH = "auto_align_branching_fix"; - public static final String BUILD_DATE = "2025-04-05 19:18:51 EDT"; - public static final long BUILD_UNIX_TIME = 1743895131176L; - public static final int DIRTY = 1; + public static final int GIT_REVISION = 291; + public static final String GIT_SHA = "cf6643bd2f22632c4ca95dbeed64be17df411994"; + public static final String GIT_DATE = "2025-04-05 20:39:13 EDT"; + public static final String GIT_BRANCH = "LED-code"; + public static final String BUILD_DATE = "2025-04-05 21:13:08 EDT"; + public static final long BUILD_UNIX_TIME = 1743901988846L; + public static final int DIRTY = 0; private BuildConstants() {} } diff --git a/src/main/java/org/team5924/frc2025/Constants.java b/src/main/java/org/team5924/frc2025/Constants.java index cb4c8c5..4cc8547 100644 --- a/src/main/java/org/team5924/frc2025/Constants.java +++ b/src/main/java/org/team5924/frc2025/Constants.java @@ -126,6 +126,9 @@ public static enum Mode { public static final boolean ALGAE_BRAKE = true; // Adjust value as needed public static final double ALGAE_REDUCTION = 1.0; // Adjust value as needed + /*Lights */ + public static final int CANDLE_ID = 41; + /* # Vision # */ public static String APRIL_TAG_LIMELIGHT_NAME_FRONTL = "limelight-frontl"; public static String APRIL_TAG_LIMELIGHT_NAME_FRONTR = "limelight-frontr"; diff --git a/src/main/java/org/team5924/frc2025/Robot.java b/src/main/java/org/team5924/frc2025/Robot.java index dd9981e..7f0e686 100644 --- a/src/main/java/org/team5924/frc2025/Robot.java +++ b/src/main/java/org/team5924/frc2025/Robot.java @@ -33,6 +33,8 @@ import org.littletonrobotics.junction.wpilog.WPILOGReader; import org.littletonrobotics.junction.wpilog.WPILOGWriter; import org.team5924.frc2025.generated.TunerConstantsGamma; +import org.team5924.frc2025.subsystems.lights.Lights; +import org.team5924.frc2025.subsystems.lights.Lights.LEDSegment; import org.team5924.frc2025.util.Elastic; /** @@ -142,7 +144,9 @@ public void disabledInit() {} /** This function is called periodically when disabled. */ @Override - public void disabledPeriodic() {} + public void disabledPeriodic() { + LEDSegment.MainStrip.setFadeAnimation(Lights.red, 0.5); + } /** This autonomous runs the autonomous command selected by your {@link RobotContainer} class. */ @Override diff --git a/src/main/java/org/team5924/frc2025/RobotContainer.java b/src/main/java/org/team5924/frc2025/RobotContainer.java index aa2cd0b..b41a64e 100644 --- a/src/main/java/org/team5924/frc2025/RobotContainer.java +++ b/src/main/java/org/team5924/frc2025/RobotContainer.java @@ -17,6 +17,7 @@ package org.team5924.frc2025; import static edu.wpi.first.units.Units.Seconds; +import static org.team5924.frc2025.Constants.CANDLE_ID; import com.pathplanner.lib.auto.AutoBuilder; import com.pathplanner.lib.auto.NamedCommands; @@ -36,6 +37,7 @@ import org.team5924.frc2025.commands.coralInAndOut.TeleopShoot; import org.team5924.frc2025.commands.drive.DriveCommands; import org.team5924.frc2025.commands.elevator.RunElevator; +import org.team5924.frc2025.commands.lights.SetLEDColorCommand; import org.team5924.frc2025.generated.TunerConstantsGamma; import org.team5924.frc2025.subsystems.climber.Climber; import org.team5924.frc2025.subsystems.climber.ClimberIO; @@ -50,6 +52,7 @@ import org.team5924.frc2025.subsystems.elevator.Elevator; import org.team5924.frc2025.subsystems.elevator.ElevatorIO; import org.team5924.frc2025.subsystems.elevator.ElevatorIOTalonFXGamma; +import org.team5924.frc2025.subsystems.lights.LEDSubsystem; import org.team5924.frc2025.subsystems.rollers.CoralInAndOut.CoralInAndOut; import org.team5924.frc2025.subsystems.rollers.CoralInAndOut.CoralInAndOut.CoralState; import org.team5924.frc2025.subsystems.rollers.CoralInAndOut.CoralInAndOutIO; @@ -72,6 +75,8 @@ public class RobotContainer { private final CoralInAndOut coralInAndOut; private final Elevator elevator; private final Vision vision; + // private final Lights lights; + private final LEDSubsystem ledSubsystem; // Controller private final CommandXboxController driveController = new CommandXboxController(0); @@ -97,6 +102,8 @@ public RobotContainer() { coralInAndOut = new CoralInAndOut(new CoralInAndOutIOKrakenFOC()); elevator = new Elevator(new ElevatorIOTalonFXGamma() {}); vision = new Vision(new VisionIOLimelight()); + ledSubsystem = new LEDSubsystem(CANDLE_ID); + // lights = new Lights(); break; case SIM: @@ -112,6 +119,8 @@ public RobotContainer() { coralInAndOut = new CoralInAndOut(new CoralInAndOutIOSim()); elevator = new Elevator(new ElevatorIO() {}); vision = new Vision(new VisionIO() {}); + ledSubsystem = new LEDSubsystem(CANDLE_ID); + // lights = new Lights(); break; default: @@ -127,6 +136,8 @@ public RobotContainer() { coralInAndOut = new CoralInAndOut(new CoralInAndOutIO() {}); elevator = new Elevator(new ElevatorIO() {}); vision = new Vision(new VisionIO() {}); + ledSubsystem = new LEDSubsystem(CANDLE_ID); + // lights = new Lights(); break; } @@ -321,6 +332,12 @@ private void configureButtonBindings() { .pov(180) .or(driveController.pov(0)) .onFalse(Commands.runOnce(() -> climber.handleNoInputState())); + + // lights.defaultCommand(); + ledSubsystem.setDefaultCommand( + new SetLEDColorCommand( + ledSubsystem, 240, 74, 0) // default: golden gate international orange + ); } /** diff --git a/src/main/java/org/team5924/frc2025/commands/lights/LEDStatus.java b/src/main/java/org/team5924/frc2025/commands/lights/LEDStatus.java new file mode 100644 index 0000000..aac7d62 --- /dev/null +++ b/src/main/java/org/team5924/frc2025/commands/lights/LEDStatus.java @@ -0,0 +1,56 @@ +/* + * LEDStatus.java + */ + +/* + * Copyright (C) 2024-2025 Team 5924 - Golden Gate Robotics and/or its affiliates. + * + * This file, and the associated project, are offered under the GNU General + * Public License v3.0. A copy of this license can be found in LICENSE.md + * at the root of this project. + * + * If this file has been separated from the original project, you should have + * received a copy of the GNU General Public License along with it. + * If you did not, see . + */ + +package org.team5924.frc2025.commands.lights; + +import edu.wpi.first.wpilibj2.command.Command; +import org.team5924.frc2025.RobotState; +import org.team5924.frc2025.subsystems.lights.Lights; + +public class LEDStatus extends Command { + /** Creates a new LEDstatus. */ + private Lights leds; + + double limeErrorTolerance = 1.5; // in degrees + + public LEDStatus(Lights leds) { + this.leds = leds; + // addRequirements(leds); + } + + // Called when the command is initially scheduled. + @Override + public void initialize() {} + + // Called every time the scheduler runs while the command is scheduled. + @Override + public void execute() { + switch (RobotState.getInstance().getElevatorState()) { + case L3 -> Lights.LEDSegment.MainStrip.setColor(Lights.blue); + default -> Lights.LEDSegment.MainStrip.disableLEDs(); + } + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) {} + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return false; + } +} diff --git a/src/main/java/org/team5924/frc2025/commands/lights/SetLEDColorCommand.java b/src/main/java/org/team5924/frc2025/commands/lights/SetLEDColorCommand.java new file mode 100644 index 0000000..77bc893 --- /dev/null +++ b/src/main/java/org/team5924/frc2025/commands/lights/SetLEDColorCommand.java @@ -0,0 +1,43 @@ +/* + * SetLEDColorCommand.java + */ + +/* + * Copyright (C) 2024-2025 Team 5924 - Golden Gate Robotics and/or its affiliates. + * + * This file, and the associated project, are offered under the GNU General + * Public License v3.0. A copy of this license can be found in LICENSE.md + * at the root of this project. + * + * If this file has been separated from the original project, you should have + * received a copy of the GNU General Public License along with it. + * If you did not, see . + */ + +package org.team5924.frc2025.commands.lights; + +import edu.wpi.first.wpilibj2.command.Command; +import org.team5924.frc2025.subsystems.lights.LEDSubsystem; + +public class SetLEDColorCommand extends Command { + private final LEDSubsystem led; + private final int r, g, b; + + public SetLEDColorCommand(LEDSubsystem led, int r, int g, int b) { + this.led = led; + this.r = r; + this.g = g; + this.b = b; + addRequirements(led); + } + + @Override + public void initialize() { + led.setColor(r, g, b); + } + + @Override + public boolean isFinished() { + return true; // run once and done + } +} diff --git a/src/main/java/org/team5924/frc2025/subsystems/Lights/LEDSubsystem.java b/src/main/java/org/team5924/frc2025/subsystems/Lights/LEDSubsystem.java new file mode 100644 index 0000000..e23f6e5 --- /dev/null +++ b/src/main/java/org/team5924/frc2025/subsystems/Lights/LEDSubsystem.java @@ -0,0 +1,37 @@ +/* + * LEDSubsystem.java + */ + +/* + * Copyright (C) 2024-2025 Team 5924 - Golden Gate Robotics and/or its affiliates. + * + * This file, and the associated project, are offered under the GNU General + * Public License v3.0. A copy of this license can be found in LICENSE.md + * at the root of this project. + * + * If this file has been separated from the original project, you should have + * received a copy of the GNU General Public License along with it. + * If you did not, see . + */ + +package org.team5924.frc2025.subsystems.lights; + +import com.ctre.phoenix.led.CANdle; +import com.ctre.phoenix.led.CANdleConfiguration; + +import edu.wpi.first.wpilibj2.command.SubsystemBase; + +public class LEDSubsystem extends SubsystemBase { + private final CANdle candle; + + public LEDSubsystem(int canId) { + candle = new CANdle(canId); + + CANdleConfiguration config = new CANdleConfiguration(); + + } + + public void setColor(int r, int g, int b) { + candle.setLEDs(r, g, b); + } +} diff --git a/src/main/java/org/team5924/frc2025/subsystems/Lights/Lights.java b/src/main/java/org/team5924/frc2025/subsystems/Lights/Lights.java new file mode 100644 index 0000000..9520270 --- /dev/null +++ b/src/main/java/org/team5924/frc2025/subsystems/Lights/Lights.java @@ -0,0 +1,173 @@ +/* + * Lights.java + */ + +/* + * Copyright (C) 2024-2025 Team 5924 - Golden Gate Robotics and/or its affiliates. + * + * This file, and the associated project, are offered under the GNU General + * Public License v3.0. A copy of this license can be found in LICENSE.md + * at the root of this project. + * + * If this file has been separated from the original project, you should have + * received a copy of the GNU General Public License along with it. + * If you did not, see . + */ + +package org.team5924.frc2025.subsystems.lights; + +import com.ctre.phoenix.led.Animation; +import com.ctre.phoenix.led.CANdle; +import com.ctre.phoenix.led.CANdle.LEDStripType; +import com.ctre.phoenix.led.CANdle.VBatOutputMode; +import com.ctre.phoenix.led.CANdleConfiguration; +import com.ctre.phoenix.led.ColorFlowAnimation; +import com.ctre.phoenix.led.ColorFlowAnimation.Direction; +import com.ctre.phoenix.led.LarsonAnimation; +import com.ctre.phoenix.led.LarsonAnimation.BounceMode; +import com.ctre.phoenix.led.RainbowAnimation; +import com.ctre.phoenix.led.SingleFadeAnimation; +import com.ctre.phoenix.led.StrobeAnimation; +import edu.wpi.first.wpilibj2.command.Command; +import edu.wpi.first.wpilibj2.command.SubsystemBase; +import org.team5924.frc2025.Constants; +import org.team5924.frc2025.util.Color; + +public class Lights extends SubsystemBase { + private static final CANdle candle = new CANdle(Constants.CANDLE_ID); + + /* Standard Colors */ + public static final Color white = new Color(255, 230, 220); + public static final Color red = new Color(255, 0, 0); + public static final Color orange = new Color(255, 165, 0); + public static final Color yellow = new Color(255, 255, 0); + public static final Color green = new Color(0, 255, 0); + public static final Color blue = new Color(0, 0, 255); + public static final Color purple = new Color(148, 0, 211); + public static final Color black = new Color(0, 0, 0); + + /* Team-specific Colors */ + public static final Color international_orange = new Color(255, 79, 0); + public static final Color primary_red = new Color(192, 54, 44); + + public Lights() { + CANdleConfiguration candleConfiguration = new CANdleConfiguration(); + candleConfiguration.statusLedOffWhenActive = true; + candleConfiguration.disableWhenLOS = false; + candleConfiguration.stripType = LEDStripType.RGB; + candleConfiguration.vBatOutputMode = VBatOutputMode.Modulated; + candle.configAllSettings(candleConfiguration, 100); + + setDefaultCommand(defaultCommand()); + } + + public void setBrightness(double percent) { + candle.configBrightnessScalar(percent, 100); + } + + public Command defaultCommand() { + return runOnce( + () -> { + LEDSegment.MainStrip.setColor(international_orange); + }); + } + + public Command clearSegmentCommand(LEDSegment segment) { + return runOnce( + () -> { + segment.clearAnimation(); + segment.disableLEDs(); + }); + } + + public static enum LEDSegment { + MainStrip(0, 300, 2); + + public final int startIndex; + public final int segmentSize; + public final int animationSlot; + + private LEDSegment(int startIndex, int segmentSize, int animationSlot) { + this.startIndex = startIndex; + this.segmentSize = segmentSize; + this.animationSlot = animationSlot; + } + + public void setColor(Color color) { + clearAnimation(); + candle.setLEDs(color.getRed(), color.getGreen(), color.getBlue(), 0, startIndex, segmentSize); + } + + private void setAnimation(Animation animation) { + candle.animate(animation, animationSlot); + } + + public void fullClear() { + clearAnimation(); + disableLEDs(); + } + + public void clearAnimation() { + candle.clearAnimation(animationSlot); + } + + public void disableLEDs() { + setColor(black); + } + + public void setFlowAnimation(Color color, double speed) { + setAnimation( + new ColorFlowAnimation( + color.getRed(), + color.getGreen(), + color.getBlue(), + 0, + speed, + segmentSize, + Direction.Forward, + startIndex)); + } + + public void setFadeAnimation(Color color, double speed) { + setAnimation( + new SingleFadeAnimation( + color.getRed(), + color.getGreen(), + color.getBlue(), + 0, + speed, + segmentSize, + startIndex)); + } + + public void setBandAnimation(Color color, double speed) { + setAnimation( + new LarsonAnimation( + color.getRed(), + color.getGreen(), + color.getBlue(), + 0, + speed, + segmentSize, + BounceMode.Front, + 3, + startIndex)); + } + + public void setStrobeAnimation(Color color, double speed) { + setAnimation( + new StrobeAnimation( + color.getRed(), + color.getGreen(), + color.getBlue(), + 0, + speed, + segmentSize, + startIndex)); + } + + public void setRainbowAnimation(double speed) { + setAnimation(new RainbowAnimation(1, speed, segmentSize, false, startIndex)); + } + } +} diff --git a/src/main/java/org/team5924/frc2025/subsystems/Lights/LightsIO.java b/src/main/java/org/team5924/frc2025/subsystems/Lights/LightsIO.java new file mode 100644 index 0000000..cdde6c6 --- /dev/null +++ b/src/main/java/org/team5924/frc2025/subsystems/Lights/LightsIO.java @@ -0,0 +1,24 @@ +/* + * LightsIO.java + */ + +/* + * Copyright (C) 2024-2025 Team 5924 - Golden Gate Robotics and/or its affiliates. + * + * This file, and the associated project, are offered under the GNU General + * Public License v3.0. A copy of this license can be found in LICENSE.md + * at the root of this project. + * + * If this file has been separated from the original project, you should have + * received a copy of the GNU General Public License along with it. + * If you did not, see . + */ + +package org.team5924.frc2025.subsystems.lights; + +public interface LightsIO { + /* Pfft I have no clue what goes here :D */ + public default void setBrightness() {} + + public default void setColor() {} +} diff --git a/src/main/java/org/team5924/frc2025/util/Color.java b/src/main/java/org/team5924/frc2025/util/Color.java new file mode 100644 index 0000000..5b7bc49 --- /dev/null +++ b/src/main/java/org/team5924/frc2025/util/Color.java @@ -0,0 +1,43 @@ +/* + * Color.java + */ + +/* + * Copyright (C) 2024-2025 Team 5924 - Golden Gate Robotics and/or its affiliates. + * + * This file, and the associated project, are offered under the GNU General + * Public License v3.0. A copy of this license can be found in LICENSE.md + * at the root of this project. + * + * If this file has been separated from the original project, you should have + * received a copy of the GNU General Public License along with it. + * If you did not, see . + */ + +package org.team5924.frc2025.util; + +/** Add your docs here. */ +public class Color { + + private int red; + private int blue; + private int green; + + public Color(int red, int blue, int green) { + this.red = red; + this.green = green; + this.blue = blue; + } + + public int getRed() { + return red; + } + + public int getGreen() { + return green; + } + + public int getBlue() { + return blue; + } +} diff --git a/vendordeps/Phoenix5-5.35.1.json b/vendordeps/Phoenix5-5.35.1.json new file mode 100644 index 0000000..2190f40 --- /dev/null +++ b/vendordeps/Phoenix5-5.35.1.json @@ -0,0 +1,171 @@ +{ + "fileName": "Phoenix5-5.35.1.json", + "name": "CTRE-Phoenix (v5)", + "version": "5.35.1", + "frcYear": "2025", + "uuid": "ab676553-b602-441f-a38d-f1296eff6537", + "mavenUrls": [ + "https://maven.ctr-electronics.com/release/" + ], + "jsonUrl": "https://maven.ctr-electronics.com/release/com/ctre/phoenix/Phoenix5-frc2025-latest.json", + "requires": [ + { + "uuid": "e995de00-2c64-4df5-8831-c1441420ff19", + "errorMessage": "Phoenix 5 requires low-level libraries from Phoenix 6. Please add the Phoenix 6 vendordep before adding Phoenix 5.", + "offlineFileName": "Phoenix6-frc2025-latest.json", + "onlineUrl": "https://maven.ctr-electronics.com/release/com/ctre/phoenix6/latest/Phoenix6-frc2025-latest.json" + } + ], + "conflictsWith": [ + { + "uuid": "e7900d8d-826f-4dca-a1ff-182f658e98af", + "errorMessage": "Users must use the Phoenix 5 replay vendordep when using the Phoenix 6 replay vendordep.", + "offlineFileName": "Phoenix6-replay-frc2025-latest.json" + }, + { + "uuid": "fbc886a4-2cec-40c0-9835-71086a8cc3df", + "errorMessage": "Users cannot have both the replay and regular Phoenix 5 vendordeps in their robot program.", + "offlineFileName": "Phoenix5-replay-frc2025-latest.json" + } + ], + "javaDependencies": [ + { + "groupId": "com.ctre.phoenix", + "artifactId": "api-java", + "version": "5.35.1" + }, + { + "groupId": "com.ctre.phoenix", + "artifactId": "wpiapi-java", + "version": "5.35.1" + } + ], + "jniDependencies": [ + { + "groupId": "com.ctre.phoenix", + "artifactId": "cci", + "version": "5.35.1", + "isJar": false, + "skipInvalidPlatforms": true, + "validPlatforms": [ + "windowsx86-64", + "linuxx86-64", + "linuxarm64", + "linuxathena" + ], + "simMode": "hwsim" + }, + { + "groupId": "com.ctre.phoenix.sim", + "artifactId": "cci-sim", + "version": "5.35.1", + "isJar": false, + "skipInvalidPlatforms": true, + "validPlatforms": [ + "windowsx86-64", + "linuxx86-64", + "linuxarm64", + "osxuniversal" + ], + "simMode": "swsim" + } + ], + "cppDependencies": [ + { + "groupId": "com.ctre.phoenix", + "artifactId": "wpiapi-cpp", + "version": "5.35.1", + "libName": "CTRE_Phoenix_WPI", + "headerClassifier": "headers", + "sharedLibrary": true, + "skipInvalidPlatforms": true, + "binaryPlatforms": [ + "windowsx86-64", + "linuxx86-64", + "linuxarm64", + "linuxathena" + ], + "simMode": "hwsim" + }, + { + "groupId": "com.ctre.phoenix", + "artifactId": "api-cpp", + "version": "5.35.1", + "libName": "CTRE_Phoenix", + "headerClassifier": "headers", + "sharedLibrary": true, + "skipInvalidPlatforms": true, + "binaryPlatforms": [ + "windowsx86-64", + "linuxx86-64", + "linuxarm64", + "linuxathena" + ], + "simMode": "hwsim" + }, + { + "groupId": "com.ctre.phoenix", + "artifactId": "cci", + "version": "5.35.1", + "libName": "CTRE_PhoenixCCI", + "headerClassifier": "headers", + "sharedLibrary": true, + "skipInvalidPlatforms": true, + "binaryPlatforms": [ + "windowsx86-64", + "linuxx86-64", + "linuxarm64", + "linuxathena" + ], + "simMode": "hwsim" + }, + { + "groupId": "com.ctre.phoenix.sim", + "artifactId": "wpiapi-cpp-sim", + "version": "5.35.1", + "libName": "CTRE_Phoenix_WPISim", + "headerClassifier": "headers", + "sharedLibrary": true, + "skipInvalidPlatforms": true, + "binaryPlatforms": [ + "windowsx86-64", + "linuxx86-64", + "linuxarm64", + "osxuniversal" + ], + "simMode": "swsim" + }, + { + "groupId": "com.ctre.phoenix.sim", + "artifactId": "api-cpp-sim", + "version": "5.35.1", + "libName": "CTRE_PhoenixSim", + "headerClassifier": "headers", + "sharedLibrary": true, + "skipInvalidPlatforms": true, + "binaryPlatforms": [ + "windowsx86-64", + "linuxx86-64", + "linuxarm64", + "osxuniversal" + ], + "simMode": "swsim" + }, + { + "groupId": "com.ctre.phoenix.sim", + "artifactId": "cci-sim", + "version": "5.35.1", + "libName": "CTRE_PhoenixCCISim", + "headerClassifier": "headers", + "sharedLibrary": true, + "skipInvalidPlatforms": true, + "binaryPlatforms": [ + "windowsx86-64", + "linuxx86-64", + "linuxarm64", + "osxuniversal" + ], + "simMode": "swsim" + } + ] +}