import edu.wpi.first.wpilibj2.command.InstantCommand;
import frc.robot.commands.DoNothing;
import frc.robot.commands.drive_comm.DefaultDriveCommand;
+import frc.robot.commands.led_comm.LEDDefaultCommand;
import frc.robot.commands.vision.ShutdownAllPis;
import frc.robot.constants.AutoConstants;
import frc.robot.constants.Constants;
import frc.robot.controls.PS5ControllerDriverConfig;
import frc.robot.subsystems.Climb.LinearClimb;
import frc.robot.subsystems.Intake.Intake;
+import frc.robot.subsystems.LED.LED;
import frc.robot.subsystems.drivetrain.Drivetrain;
import frc.robot.subsystems.drivetrain.GyroIOPigeon2;
import frc.robot.util.PathGroupLoader;
private Operator operator = null;
private LinearClimb linearClimb = null;
private Intake intake = null;
+ private LED led = null;
// Auto Command selection
private final SendableChooser<Command> autoChooser = new SendableChooser<>();
break;
case TestBed2:
+ led = new LED();
+ led.setDefaultCommand(new LEDDefaultCommand(led));
break;
default:
private String gameData = DriverStation.getGameSpecificMessage();
- public LEDDefaultCommand(LED led, Drivetrain drivetrain, Vision vision, PS5Controller controller) {
+ public LEDDefaultCommand(LED led) {
this.led = led;
// this.outtake = outtake;
- this.drivetrain = drivetrain;
- this.vision = vision;
- this.controller = controller;
addRequirements(led);
}
@Override
public void execute() {
double matchTime = DriverStation.getMatchTime();
- if (vision.oneCameraDisconnected()) {
- // flash if camera disconnected
- led.setStrobeLights(255, 100, 0);
- } else if (fiveSecondsBeforeChange() && allianceIsRed) {
+ // if (vision.oneCameraDisconnected()) {
+ // // flash if camera disconnected
+ // led.setStrobeLights(255, 100, 0);
+ // } else
+ if (fiveSecondsBeforeChange() && allianceIsRed) {
// blink alliance color and rumble if red alliance 5 seconds before hub shifts
led.setStrobeLights(255, 0, 0);
controller.setRumble(GenericHID.RumbleType.kBothRumble, 1.0);
// blink alliance color and rumble if blue alliance 5 seconds before hub shifts
led.setStrobeLights(0, 0, 255);
controller.setRumble(GenericHID.RumbleType.kBothRumble, 1.0);
- } else if (playingDefense()) {
- // When playing defense
- led.defenseLights();
- } else if (DriverStation.isAutonomous() && allianceIsRed){
+ } else
+ // if (playingDefense()) {
+ // // When playing defense
+ // // TODO Need to remake defense lights, for some reason not there anymore
+ // // led.defenseLights();
+ // led.alternate(255, 0, 0, 0, 0, 255, 4, 0, 67);
+ // } else
+ if (DriverStation.isAutonomous() && allianceIsRed){
// Dimmer light for auto in red alliance
led.setLEDs(100, 0, 0);
} else if (DriverStation.isAutonomous()){
led.setLEDs(0, 0, 0);
} else if (allianceIsRed) {
// Red alliance
- led.setTwoColorWave(255, 0, 0, 255, 255, 255);
+ // TODO need to fix 2 color wave
+ //led.setTwoColorWave(255, 0, 0, 255, 255, 255);
+ led.setLEDs(255, 0, 0);
} else {
// Blue alliance
- led.setTwoColorWave(0, 0, 255, 255, 255, 255);
+ // led.setTwoColorWave(0, 0, 255, 255, 255, 255);
+ // TODO remake 2 color wave
+ led.setLEDs(0, 0, 255);
}
}
- private boolean playingDefense() {
- double xCoordinate = drivetrain.getPose().getX();
- double xCoordinateHalfway = 50;
- if (allianceIsRed) {
- return xCoordinate > xCoordinateHalfway;
- } else if (!allianceIsRed) {
- return xCoordinate < xCoordinateHalfway;
- }
- return false;
- }
+ // private boolean playingDefense() {
+ // double xCoordinate = drivetrain.getPose().getX();
+ // double xCoordinateHalfway = 50;
+ // if (allianceIsRed) {
+ // return xCoordinate > xCoordinateHalfway;
+ // } else if (!allianceIsRed) {
+ // return xCoordinate < xCoordinateHalfway;
+ // }
+ // return false;
+ // }
private boolean fiveSecondsBeforeChange() {
double time = DriverStation.getMatchTime();
package frc.robot.subsystems.LED;
+import com.ctre.phoenix.led.RainbowAnimation;
import com.ctre.phoenix6.configs.CANdleConfigurator;
import com.ctre.phoenix6.configs.CANdleFeaturesConfigs;
import com.ctre.phoenix6.configs.LEDConfigs;
import com.ctre.phoenix6.controls.ControlRequest;
import com.ctre.phoenix6.controls.SolidColor;
+import com.ctre.phoenix6.controls.StrobeAnimation;
import com.ctre.phoenix6.hardware.CANdle;
import com.ctre.phoenix6.signals.Enable5VRailValue;
import com.ctre.phoenix6.signals.LossOfSignalBehaviorValue;
private CANdle candle;
public static final int stripLength = 67;
+ private double counter = 0;
// Constructor
public LED() {
* @param blue Blue value (0-255)
*/
public void setStrobeLights(int red, int green, int blue) {
-
+ counter++;
+ if (counter == 1) {
+ setLEDs(red, green, blue);
+ } else if (counter == 20) {
+ setLEDs(0, 0, 0);
+ } else if (counter >= 40) {
+ counter = 0;
+ }
}
/**