From 242610d4dfaae0593a4d75bdd26fa29165427528 Mon Sep 17 00:00:00 2001 From: Liam Sykes <78829557+trixydevs@users.noreply.github.com> Date: Tue, 6 Feb 2024 20:12:21 -0600 Subject: [PATCH 1/6] Light stuff --- src/main/java/frc/robot/RobotContainer.java | 2 + .../frc/robot/commands/IndicatorLights.java | 41 +++++++++++++++++++ .../robot/subsystems/DrivetrainSubsystem.java | 7 +--- .../java/frc/robot/subsystems/Lights.java | 19 ++++----- .../java/frc/robot/subsystems/RobotState.java | 19 +++++++++ 5 files changed, 72 insertions(+), 16 deletions(-) create mode 100644 src/main/java/frc/robot/commands/IndicatorLights.java create mode 100644 src/main/java/frc/robot/subsystems/RobotState.java diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 40574cda..5689617a 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -33,6 +33,7 @@ import frc.robot.settings.Constants.Field; import frc.robot.commands.IndexCommand; +import frc.robot.commands.IndicatorLights; import frc.robot.settings.Constants; import frc.robot.settings.Constants.ClimberConstants; import frc.robot.settings.Constants.DriveConstants; @@ -208,6 +209,7 @@ private void limelightInit() { } private void lightsInst() { lights = new Lights(Constants.LED_COUNT-1); + lights.setDefaultCommand(new IndicatorLights(lights)); } diff --git a/src/main/java/frc/robot/commands/IndicatorLights.java b/src/main/java/frc/robot/commands/IndicatorLights.java new file mode 100644 index 00000000..5a5de147 --- /dev/null +++ b/src/main/java/frc/robot/commands/IndicatorLights.java @@ -0,0 +1,41 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +package frc.robot.commands; + +import edu.wpi.first.wpilibj2.command.Command; +import frc.robot.subsystems.Lights; +public class IndicatorLights extends Command { + + Lights lights; + + public IndicatorLights(Lights lights) { + addRequirements(lights); + this.lights = lights; + } + + + @Override + public void initialize() {} + + @Override + public void execute() { + + lights.setSectionOne(255,192,203); + lights.setSectionTwo(255,0,255); + lights.dataSetter(); + } + + + @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/frc/robot/subsystems/DrivetrainSubsystem.java b/src/main/java/frc/robot/subsystems/DrivetrainSubsystem.java index 49eb98a6..e3ac8757 100644 --- a/src/main/java/frc/robot/subsystems/DrivetrainSubsystem.java +++ b/src/main/java/frc/robot/subsystems/DrivetrainSubsystem.java @@ -292,11 +292,8 @@ public double calculateSpeakerAngle(){ } speakerDist = Math.sqrt(Math.pow(deltaX, 2) + Math.pow(deltaY, 2)); SmartDashboard.putNumber("dist to speakre", speakerDist); - if(speakerDist Date: Thu, 8 Feb 2024 20:08:19 -0600 Subject: [PATCH 2/6] Hooking up light subsystem stuff --- src/main/java/frc/robot/RobotContainer.java | 2 +- .../java/frc/robot/commands/IndexCommand.java | 27 +++++++++++++------ .../robot/subsystems/DrivetrainSubsystem.java | 13 ++------- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 5689617a..01b1239b 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -169,7 +169,7 @@ private void climbSpotChooserInit() { SmartDashboard.putData(climbSpotChooser); } private void driveTrainInst() { - driveTrain = new DrivetrainSubsystem(lights, lightsExist); + driveTrain = new DrivetrainSubsystem(); defaultDriveCommand = new Drive( driveTrain, () -> driverController.getL1Button(), diff --git a/src/main/java/frc/robot/commands/IndexCommand.java b/src/main/java/frc/robot/commands/IndexCommand.java index 86bb0091..4b40926f 100644 --- a/src/main/java/frc/robot/commands/IndexCommand.java +++ b/src/main/java/frc/robot/commands/IndexCommand.java @@ -15,6 +15,7 @@ import frc.robot.subsystems.DrivetrainSubsystem; import frc.robot.subsystems.IndexerSubsystem; import frc.robot.subsystems.IntakeSubsystem; +import frc.robot.subsystems.RobotState; import frc.robot.subsystems.ShooterSubsystem; @@ -72,20 +73,30 @@ public void execute() { shooter.shootThing(ShooterConstants.SHOOTER_AMP_POWER); } } - if (shootIfReadySupplier.getAsBoolean()) { - if((angleShooterSubsytem.calculateSpeakerAngleDifference() Date: Sat, 10 Feb 2024 13:20:20 -0600 Subject: [PATCH 3/6] made some more code for th elights singlegton --- src/main/java/frc/robot/RobotContainer.java | 2 ++ src/main/java/frc/robot/subsystems/DrivetrainSubsystem.java | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 01b1239b..fc3215f3 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -57,6 +57,7 @@ import frc.robot.subsystems.IndexerSubsystem; import frc.robot.subsystems.IntakeSubsystem; import frc.robot.subsystems.Limelight; +import frc.robot.subsystems.RobotState; import frc.robot.subsystems.ShooterSubsystem; import edu.wpi.first.wpilibj.smartdashboard.SendableChooser; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; @@ -340,6 +341,7 @@ public void teleopPeriodic() { driveTrain.calculateSpeakerAngle(); if(useDetectorLimelight) { SmartDashboard.putNumber("Is Note Seen?", limelight.getNeuralDetectorValues().ta); + RobotState.getInstance().IsNoteSeen = limelight.getNeuralDetectorValues().isResultValid; } } diff --git a/src/main/java/frc/robot/subsystems/DrivetrainSubsystem.java b/src/main/java/frc/robot/subsystems/DrivetrainSubsystem.java index 5f71f69a..c2790015 100644 --- a/src/main/java/frc/robot/subsystems/DrivetrainSubsystem.java +++ b/src/main/java/frc/robot/subsystems/DrivetrainSubsystem.java @@ -288,7 +288,7 @@ public double calculateSpeakerAngle(){ speakerDist = Math.sqrt(Math.pow(deltaX, 2) + Math.pow(deltaY, 2)); SmartDashboard.putNumber("dist to speakre", speakerDist); - RobotState.getInstance().ShooterInRange = speakerDist Date: Mon, 12 Feb 2024 16:58:58 -0600 Subject: [PATCH 4/6] added code to show the booleans that RobotState is tracking on SmartDashboard during teleop --- src/main/java/frc/robot/RobotContainer.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index fc3215f3..afb50f94 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -343,6 +343,9 @@ public void teleopPeriodic() { SmartDashboard.putNumber("Is Note Seen?", limelight.getNeuralDetectorValues().ta); RobotState.getInstance().IsNoteSeen = limelight.getNeuralDetectorValues().isResultValid; } + SmartDashboard.putBoolean("is note seen", RobotState.getInstance().IsNoteSeen); + SmartDashboard.putBoolean("shooter in range", RobotState.getInstance().ShooterInRange); + SmartDashboard.putBoolean("shooter ready", RobotState.getInstance().ShooterReady); } public void disabledPeriodic() { From 84724512ce66964c1c7f4fbb083ce91f8f474a39 Mon Sep 17 00:00:00 2001 From: NoMythic <2491nomythic@gmail.com> Date: Tue, 13 Feb 2024 19:20:17 -0600 Subject: [PATCH 5/6] Lights almost done --- src/main/java/frc/robot/commands/IndicatorLights.java | 7 ++++--- src/main/java/frc/robot/settings/Constants.java | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/frc/robot/commands/IndicatorLights.java b/src/main/java/frc/robot/commands/IndicatorLights.java index 5a5de147..e8af3f25 100644 --- a/src/main/java/frc/robot/commands/IndicatorLights.java +++ b/src/main/java/frc/robot/commands/IndicatorLights.java @@ -22,15 +22,16 @@ public void initialize() {} @Override public void execute() { - lights.setSectionOne(255,192,203); - lights.setSectionTwo(255,0,255); + lights.setSectionOne(50,0,50); + lights.setSectionTwo(0,50,0); lights.dataSetter(); } @Override public void end(boolean interrupted) { - + lights.lightsOut(); + lights.dataSetter(); } // Returns true when the command should end. diff --git a/src/main/java/frc/robot/settings/Constants.java b/src/main/java/frc/robot/settings/Constants.java index afec2b1e..41bb6931 100644 --- a/src/main/java/frc/robot/settings/Constants.java +++ b/src/main/java/frc/robot/settings/Constants.java @@ -33,7 +33,7 @@ public final class Constants { private Constants () {} - public static final int LED_COUNT = 52; + public static final int LED_COUNT = 24; public static final class DriveConstants { public static final double ALLOWED_ERROR = 1; From 061b17a985606b070279fb217fb32e0d49f80bd5 Mon Sep 17 00:00:00 2001 From: NoMythic <2491nomythic@gmail.com> Date: Tue, 13 Feb 2024 19:34:10 -0600 Subject: [PATCH 6/6] Lights are done --- .../java/frc/robot/commands/IndicatorLights.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main/java/frc/robot/commands/IndicatorLights.java b/src/main/java/frc/robot/commands/IndicatorLights.java index e8af3f25..0b997678 100644 --- a/src/main/java/frc/robot/commands/IndicatorLights.java +++ b/src/main/java/frc/robot/commands/IndicatorLights.java @@ -6,6 +6,7 @@ import edu.wpi.first.wpilibj2.command.Command; import frc.robot.subsystems.Lights; +import frc.robot.subsystems.RobotState; public class IndicatorLights extends Command { Lights lights; @@ -21,9 +22,18 @@ public void initialize() {} @Override public void execute() { - - lights.setSectionOne(50,0,50); - lights.setSectionTwo(0,50,0); + if (RobotState.getInstance().IsNoteSeen) { + lights.setSectionOne(50,40,0); + } else { + lights.setSectionOne(50, 0, 50); + } + if (RobotState.getInstance().ShooterInRange && RobotState.getInstance().ShooterReady){ + lights.setSectionTwo(0,50,0); + } else if (RobotState.getInstance().ShooterInRange){ + lights.setSectionTwo(50, 50, 0); + } else { + lights.setSectionTwo(50, 0, 50); + } lights.dataSetter(); }