From 69009e021e5f628b89d4149b2d2b45b30b3a3456 Mon Sep 17 00:00:00 2001 From: sMyn42 <35532863+sMyn42@users.noreply.github.com> Date: Sat, 16 Mar 2019 09:31:36 -0400 Subject: [PATCH 1/3] Added LEDs --- src/main/java/frc/team4909/robot/Robot.java | 4 + .../intake/commands/CargoIntakeIn.java | 4 +- .../intake/commands/CargoIntakeOut.java | 3 + .../commands/HatchPanelIntakeClose.java | 3 + .../intake/commands/HatchPanelIntakeOpen.java | 5 +- .../robot/subsystems/led/RGBStrip.java | 74 +++++++++++++++++++ 6 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 src/main/java/frc/team4909/robot/subsystems/led/RGBStrip.java diff --git a/src/main/java/frc/team4909/robot/Robot.java b/src/main/java/frc/team4909/robot/Robot.java index 39a51a1..5e3ddc2 100644 --- a/src/main/java/frc/team4909/robot/Robot.java +++ b/src/main/java/frc/team4909/robot/Robot.java @@ -5,6 +5,7 @@ import edu.wpi.first.wpilibj.TimedRobot; import edu.wpi.first.wpilibj.buttons.POVButton; import edu.wpi.first.wpilibj.command.Scheduler; +import edu.wpi.first.wpilibj.command.Subsystem; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import edu.wpi.first.wpilibj.DriverStation; import frc.team4909.robot.operator.controllers.BionicF310; @@ -40,6 +41,7 @@ import frc.team4909.robot.subsystems.intake.commands.CargoIntakeIn; import frc.team4909.robot.subsystems.intake.commands.CargoIntakeOut; import frc.team4909.robot.subsystems.intake.commands.HatchPanelIntakeOpen; +import frc.team4909.robot.subsystems.led.RGBStrip; import frc.team4909.robot.subsystems.climber.commands.ZeroStilts; import frc.team4909.robot.subsystems.elevator.commands.ZeroElevator; @@ -93,6 +95,7 @@ public class Robot extends TimedRobot { // Sensors public static LidarLitePWM lidar; + public static RGBStrip LEDs; /** * This function is run when the robot is first started up and should be used @@ -119,6 +122,7 @@ public void robotInit() { elevatorSubsystem = new ElevatorSubsystem(); elevatorArmSubsystem = new ElevatorArmSubsystem(); climberSubsystem = new ClimberSubsystem(); + LEDs = new RGBStrip(2, 3, 4); // Sensors lidar = new LidarLitePWM(RobotMap.lidarPort); diff --git a/src/main/java/frc/team4909/robot/subsystems/intake/commands/CargoIntakeIn.java b/src/main/java/frc/team4909/robot/subsystems/intake/commands/CargoIntakeIn.java index 08792c1..7cbd72c 100644 --- a/src/main/java/frc/team4909/robot/subsystems/intake/commands/CargoIntakeIn.java +++ b/src/main/java/frc/team4909/robot/subsystems/intake/commands/CargoIntakeIn.java @@ -1,17 +1,19 @@ package frc.team4909.robot.subsystems.intake.commands; import edu.wpi.first.wpilibj.command.Command; +import frc.team4909.robot.subsystems.led.RGBStrip.Color; import frc.team4909.robot.Robot; import frc.team4909.robot.RobotConstants; public class CargoIntakeIn extends Command { public CargoIntakeIn() { requires(Robot.intakeSubsystem); + requires(Robot.LEDs); } protected void execute() { Robot.intakeSubsystem.setCargoIntakeSpeed(RobotConstants.cargoIntakeInSpeed); - + Robot.LEDs.set(Color.Red); } @Override diff --git a/src/main/java/frc/team4909/robot/subsystems/intake/commands/CargoIntakeOut.java b/src/main/java/frc/team4909/robot/subsystems/intake/commands/CargoIntakeOut.java index df228c7..7ff2e19 100644 --- a/src/main/java/frc/team4909/robot/subsystems/intake/commands/CargoIntakeOut.java +++ b/src/main/java/frc/team4909/robot/subsystems/intake/commands/CargoIntakeOut.java @@ -3,14 +3,17 @@ import edu.wpi.first.wpilibj.command.Command; import frc.team4909.robot.Robot; import frc.team4909.robot.RobotConstants; +import frc.team4909.robot.subsystems.led.RGBStrip.Color; public class CargoIntakeOut extends Command { public CargoIntakeOut() { requires(Robot.intakeSubsystem); + requires(Robot.LEDs); } protected void execute() { Robot.intakeSubsystem.setCargoIntakeSpeed(RobotConstants.cargoIntakeOutSpeed); + Robot.LEDs.set(Color.Lime); } @Override diff --git a/src/main/java/frc/team4909/robot/subsystems/intake/commands/HatchPanelIntakeClose.java b/src/main/java/frc/team4909/robot/subsystems/intake/commands/HatchPanelIntakeClose.java index 484eadf..e424ad7 100644 --- a/src/main/java/frc/team4909/robot/subsystems/intake/commands/HatchPanelIntakeClose.java +++ b/src/main/java/frc/team4909/robot/subsystems/intake/commands/HatchPanelIntakeClose.java @@ -1,15 +1,18 @@ package frc.team4909.robot.subsystems.intake.commands; import edu.wpi.first.wpilibj.command.InstantCommand; +import frc.team4909.robot.subsystems.led.RGBStrip.Color; import frc.team4909.robot.Robot; public class HatchPanelIntakeClose extends InstantCommand { public HatchPanelIntakeClose() { requires(Robot.intakeSubsystem); + requires(Robot.LEDs); } protected void initialize() { Robot.intakeSubsystem.hatchPanelIntakeClose(); + Robot.LEDs.set(Color.Lime); } } \ No newline at end of file diff --git a/src/main/java/frc/team4909/robot/subsystems/intake/commands/HatchPanelIntakeOpen.java b/src/main/java/frc/team4909/robot/subsystems/intake/commands/HatchPanelIntakeOpen.java index df37a57..675d8d0 100644 --- a/src/main/java/frc/team4909/robot/subsystems/intake/commands/HatchPanelIntakeOpen.java +++ b/src/main/java/frc/team4909/robot/subsystems/intake/commands/HatchPanelIntakeOpen.java @@ -2,15 +2,18 @@ import edu.wpi.first.wpilibj.command.Command; import frc.team4909.robot.subsystems.intake.commands.HatchPanelIntakeClose; +import frc.team4909.robot.subsystems.led.RGBStrip.Color; import frc.team4909.robot.Robot; public class HatchPanelIntakeOpen extends Command { public HatchPanelIntakeOpen() { requires(Robot.intakeSubsystem); + requires(Robot.LEDs); } - protected void execute() { + protected void execute() { Robot.intakeSubsystem.hatchPanelIntakeOpen(); + Robot.LEDs.set(Color.Yellow); } protected void end() { diff --git a/src/main/java/frc/team4909/robot/subsystems/led/RGBStrip.java b/src/main/java/frc/team4909/robot/subsystems/led/RGBStrip.java new file mode 100644 index 0000000..5928bf1 --- /dev/null +++ b/src/main/java/frc/team4909/robot/subsystems/led/RGBStrip.java @@ -0,0 +1,74 @@ +package frc.team4909.robot.subsystems.led; + +import edu.wpi.first.wpilibj.DriverStation; +import edu.wpi.first.wpilibj.Solenoid; +import edu.wpi.first.wpilibj.command.Subsystem; +import edu.wpi.first.wpilibj.command.InstantCommand; + +public class RGBStrip extends Subsystem{ + private final Solenoid red, green, blue; + private Color currentColor = Color.Black; + + public enum Color { + Black(false, false, false), + White(true, true, true), + Red(true, false, false), + Lime(false, true, false), + Blue(false, false, true), + Yellow(true, true, false), + Cyan(false, true, true), + Magenta(true, false, true); + + public final boolean red; + public final boolean green; + public final boolean blue; + + Color(boolean red, boolean green, boolean blue) { + this.red = red; + this.green = green; + this.blue = blue; + } + } + + public RGBStrip(int redChannel, int greenChannel, int blueChannel) { + red = new Solenoid(redChannel); + green = new Solenoid(greenChannel); + blue = new Solenoid(blueChannel); + } + + public Color getCurrentColor(){ + return currentColor; + } + + public void setColor(Color color){ + currentColor = color; + + red.set(color.red); + green.set(color.green); + blue.set(color.blue); + } + + public void reset(){ + setColor(Color.Black); + } + + public InstantCommand set(Color color) { + return new SetColor(color); + } + private class SetColor extends InstantCommand { + Color color; + + public SetColor(Color color){ + this.color = color; + } + + public void initialize(){ + setColor(color); + } + } + + @Override + protected void initDefaultCommand() { + this.set(Color.Lime); + } +} \ No newline at end of file From 7d5b2295ab4a6bce6bb01907654fb5e50b11efc0 Mon Sep 17 00:00:00 2001 From: sMyn42 <35532863+sMyn42@users.noreply.github.com> Date: Sat, 16 Mar 2019 09:50:07 -0400 Subject: [PATCH 2/3] Fixed Robot.java --- src/main/java/frc/team4909/robot/Robot.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/frc/team4909/robot/Robot.java b/src/main/java/frc/team4909/robot/Robot.java index 5e3ddc2..171a3e0 100644 --- a/src/main/java/frc/team4909/robot/Robot.java +++ b/src/main/java/frc/team4909/robot/Robot.java @@ -5,7 +5,6 @@ import edu.wpi.first.wpilibj.TimedRobot; import edu.wpi.first.wpilibj.buttons.POVButton; import edu.wpi.first.wpilibj.command.Scheduler; -import edu.wpi.first.wpilibj.command.Subsystem; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import edu.wpi.first.wpilibj.DriverStation; import frc.team4909.robot.operator.controllers.BionicF310; From 693221bcf50a4c108598d32101fe43251aa51811 Mon Sep 17 00:00:00 2001 From: sMyn42 <35532863+sMyn42@users.noreply.github.com> Date: Sat, 16 Mar 2019 12:42:32 -0400 Subject: [PATCH 3/3] Added color for when cargo is held --- .../frc/team4909/robot/subsystems/intake/IntakeSubsystem.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/frc/team4909/robot/subsystems/intake/IntakeSubsystem.java b/src/main/java/frc/team4909/robot/subsystems/intake/IntakeSubsystem.java index e0b3835..117f009 100644 --- a/src/main/java/frc/team4909/robot/subsystems/intake/IntakeSubsystem.java +++ b/src/main/java/frc/team4909/robot/subsystems/intake/IntakeSubsystem.java @@ -12,6 +12,7 @@ import frc.team4909.robot.RobotMap; import frc.team4909.robot.subsystems.intake.commands.CargoIntakeHold; import frc.team4909.robot.subsystems.intake.commands.HatchPanelIntakeClose; +import frc.team4909.robot.subsystems.led.RGBStrip.Color; public class IntakeSubsystem extends Subsystem { DoubleSolenoid hatchPanelSolenoid; @@ -49,6 +50,7 @@ public void holdCargoIntake(){ public void setCargoIntakeSpeed(double speed) { if(hasCargo() && speed > 0){ speed = RobotConstants.cargoIntakeHoldSpeed; + Robot.LEDs.set(Color.Red); } cargoIntakeMotor.set(-speed);