Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JW/RX - LEDController + Rainbow LEDs #174

Open
wants to merge 45 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
3dbe69d
made LED abstract class
jowalkup Mar 31, 2023
7ac1bb7
wrote LED commands and rainbow color
jowalkup Mar 31, 2023
9cdacd9
fixed auton files and made rainbow command
jowalkup Apr 1, 2023
e9cc3ff
deleted test folder, worked on rainbow
jowalkup Apr 2, 2023
2ca6b4e
LEDRainbow shows LEDS!
Keobkeig Apr 3, 2023
175537f
.
Keobkeig Apr 3, 2023
9ede47f
Add LEDSetPulseRed! (WIP to be used in autons)
Keobkeig Apr 3, 2023
00a592c
Add LEDPulseColor() with any colour, SLColor util
Keobkeig Apr 3, 2023
288f6cf
stuff
naowalrahman Apr 3, 2023
efb07a6
Merge branch 'jw-rx/LED-controller' of github.com:StuyPulse/Jim into …
naowalrahman Apr 3, 2023
0824c64
Made LEDSet take LEDInstruction- pls check this !!
jowalkup Apr 5, 2023
6f1392b
Cleaned up LED + auton code, made Richie mode
naowalrahman Apr 5, 2023
ceaf554
Cleaned up LED + auton code, made Richie mode
naowalrahman Apr 5, 2023
68f8135
Merge branch 'jw-rx/LED-controller' of github.com:StuyPulse/Jim into …
naowalrahman Apr 5, 2023
85c028d
- remove unused imports
vincentw921 Apr 6, 2023
1f6306b
simplify pulse color logic
vincentw921 Apr 6, 2023
6cd9fd3
clean rainbow led
vincentw921 Apr 6, 2023
768574f
Merge branch 'robot/nyny' of github.com:StuyPulse/Jim into jw-rx/LED-…
Keobkeig Apr 7, 2023
9aa79ea
Add 3 piece with low first piece
Apr 10, 2023
760d05c
Remove NYC function, add theoretical y values
BenG49 Apr 10, 2023
aa0ca1c
Revert X alignment poses to pre-NYC values
BenG49 Apr 10, 2023
18e62bf
Fix typo
BenG49 Apr 10, 2023
9bc4e6c
Three piece W Low changes
vincentw921 Apr 10, 2023
e1f0f9f
Increase robot score wrist voltage
Apr 10, 2023
4d34453
Update pathplannerlib
Apr 10, 2023
57c3b12
Adjust 3 piece w low path and prep for arm jig
Apr 10, 2023
47f8970
Tune wrist and shoulder zero angle
vincentw921 Apr 10, 2023
e0cbe15
Tune stuff
vincentw921 Apr 10, 2023
5a3f0a7
Tune one piece mobility dock
vincentw921 Apr 10, 2023
4b96190
Tune 2 piece wire
vincentw921 Apr 10, 2023
bc671ba
Comment out old autos
vincentw921 Apr 10, 2023
05d62b2
BOOM THREE PIECE
vincentw921 Apr 10, 2023
e3a0924
Three piece wire (sad)
vincentw921 Apr 10, 2023
36bd6cf
Align against grid detection (#183)
vincentw921 Apr 10, 2023
730da45
Merge branch 'se/apr10' of https://github.com/StuyPulse/Jim into jw-r…
vincentw921 Apr 10, 2023
c0d51cc
LED code cleanup + LEDController periodic fix
naowalrahman Apr 13, 2023
f365c25
Merge branch 'main' into jw-rx/LED-controller
Keobkeig Dec 11, 2023
aa3daf5
Add AddressableLED sim
Keobkeig Dec 13, 2023
9092837
Add LEDSection
Keobkeig Dec 13, 2023
31fd6bc
Delete SLColor, use awt.Color instead
Keobkeig Dec 13, 2023
235225e
Fix errors in LEDInstruction implementations
Keobkeig Dec 13, 2023
2c9f6f4
INSANELY SMOOTH LEDRAINBOW
Keobkeig Dec 14, 2023
fc851c5
Greatly simplified LEDController subsystem
Keobkeig Dec 16, 2023
6d06715
Revamped LED subsystem
Keobkeig Dec 23, 2023
70ceec7
Prep SLColor for StuyLib
Keobkeig Dec 23, 2023
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
8 changes: 1 addition & 7 deletions src/main/java/com/stuypulse/robot/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
package com.stuypulse.robot;

import com.stuypulse.robot.constants.Settings;
import com.stuypulse.robot.test.Testbot;
import com.stuypulse.robot.test.TestbotContainer;
import com.stuypulse.stuylib.util.StopWatch;
import com.stuypulse.robot.Robot;

Expand All @@ -19,10 +17,6 @@ private Main() {}

public static void main(String... args) {
StopWatch.setDefaultEngine(StopWatch.kFPGAEngine);
if (Settings.ROBOT == Settings.Robot.BLAY_MODE) {
RobotBase.startRobot(Testbot::new);
} else {
RobotBase.startRobot(Robot::new);
}
RobotBase.startRobot(Robot::new);
}
}
4 changes: 4 additions & 0 deletions src/main/java/com/stuypulse/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
package com.stuypulse.robot;

import com.stuypulse.robot.commands.TeleopInit;
import com.stuypulse.robot.commands.leds.LEDSet;
import com.stuypulse.robot.commands.leds.LEDSetRainbow;
import com.stuypulse.robot.util.LEDColor;

import edu.wpi.first.wpilibj.DataLogManager;
import edu.wpi.first.wpilibj.DriverStation;
Expand Down Expand Up @@ -47,6 +50,7 @@ public void robotInit() {

@Override
public void robotPeriodic() {
//new LEDSetRainbow();
scheduler.run();
}

Expand Down
15 changes: 10 additions & 5 deletions src/main/java/com/stuypulse/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
import com.stuypulse.robot.commands.wing.*;
import com.stuypulse.robot.commands.intake.*;
import com.stuypulse.robot.commands.leds.LEDSet;
import com.stuypulse.robot.commands.leds.LEDSetRainbow;
import com.stuypulse.robot.subsystems.*;
import com.stuypulse.robot.subsystems.arm.*;
import com.stuypulse.robot.subsystems.intake.*;
import com.stuypulse.robot.subsystems.leds.LEDController;
import com.stuypulse.robot.subsystems.odometry.*;
import com.stuypulse.robot.subsystems.swerve.*;
import com.stuypulse.robot.subsystems.vision.*;
Expand All @@ -34,7 +36,6 @@
import com.stuypulse.stuylib.streams.booleans.BStream;
import com.stuypulse.stuylib.streams.booleans.filters.BDebounce;
import com.stuypulse.stuylib.streams.booleans.filters.BFilter;
import com.stuypulse.robot.util.BootlegXbox;
import com.stuypulse.stuylib.input.Gamepad;
import com.stuypulse.stuylib.input.gamepads.*;

Expand Down Expand Up @@ -150,7 +151,9 @@ private void configureDriverBindings() {
driver.getDPadRight().onTrue(new OdometryRealign(Rotation2d.fromDegrees(90)));

// plant
driver.getRightButton().onTrue(new PlantEngage());
//driver.getRightButton().onTrue(new PlantEngage());

driver.getRightButton().whileTrue(new LEDSetRainbow());
driver.getRightBumper().onTrue(new PlantDisengage());

new Trigger(intake::hasCone)
Expand Down Expand Up @@ -191,9 +194,11 @@ private void configureOperatorBindings() {
.andThen(new ManagerValidateState())
.andThen(new ArmReady()));

operator.getRightButton()
.onTrue(new IntakeScore())
.onFalse(new IntakeStop());
// operator.getRightButton()
// .onTrue(new IntakeScore())
// .onFalse(new IntakeStop());

operator.getRightButton().onTrue(new LEDSetRainbow());

// set level to score at
operator.getDPadDown().onTrue(new ManagerSetNodeLevel(NodeLevel.LOW));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@
import com.stuypulse.robot.commands.arm.routines.*;
import com.stuypulse.robot.commands.intake.*;
import com.stuypulse.robot.commands.leds.LEDSet;
import com.stuypulse.robot.commands.leds.LEDSetRainbow;
import com.stuypulse.robot.commands.manager.*;
import com.stuypulse.robot.commands.plant.PlantEngage;
import com.stuypulse.robot.commands.swerve.*;
import com.stuypulse.robot.commands.swerve.balance.SwerveDriveBalanceBlay;
import com.stuypulse.robot.subsystems.Manager.*;
import com.stuypulse.robot.subsystems.leds.LEDRainbow;
import com.stuypulse.robot.util.ArmState;
import com.stuypulse.robot.util.ArmTrajectory;
import com.stuypulse.robot.util.DebugSequentialCommandGroup;
import com.stuypulse.robot.util.LEDColor;

import edu.wpi.first.wpilibj.AddressableLEDBuffer;
import edu.wpi.first.wpilibj2.command.ParallelDeadlineGroup;
import edu.wpi.first.wpilibj2.command.WaitCommand;

Expand All @@ -37,6 +40,8 @@ protected ArmTrajectory getTrajectory(ArmState src, ArmState dest) {
private static final double INTAKE_ACQUIRE_TIME = 0.8;
private static final double ENGAGE_TIME = 10.0;

private AddressableLEDBuffer ledsBuffer;

private static final PathConstraints DOCK = new PathConstraints(1.8, 2.5);

public OnePieceDock() {
Expand Down Expand Up @@ -76,7 +81,7 @@ public OnePieceDock() {
);

addCommands(
new LEDSet(LEDColor.RAINBOW),
new LEDSetRainbow(),

new SwerveDriveBalanceBlay()
.withMaxSpeed(0.6)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.stuypulse.robot.commands.arm.routines.*;
import com.stuypulse.robot.commands.intake.*;
import com.stuypulse.robot.commands.leds.LEDSet;
import com.stuypulse.robot.commands.leds.LEDSetRainbow;
import com.stuypulse.robot.commands.manager.*;
import com.stuypulse.robot.commands.plant.PlantEngage;
import com.stuypulse.robot.commands.swerve.*;
Expand All @@ -15,6 +16,7 @@
import com.stuypulse.robot.util.DebugSequentialCommandGroup;
import com.stuypulse.robot.util.LEDColor;

import edu.wpi.first.wpilibj.AddressableLEDBuffer;
import edu.wpi.first.wpilibj2.command.ParallelDeadlineGroup;
import edu.wpi.first.wpilibj2.command.WaitCommand;

Expand All @@ -38,6 +40,8 @@ protected ArmTrajectory getTrajectory(ArmState src, ArmState dest) {
private static final double REF_REACTION_TIME = 0.8;
private static final double ENGAGE_TIME = 10.0;

private AddressableLEDBuffer ledsBuffer;

private static final PathConstraints OVER_CHARGE = new PathConstraints(1, 2);
private static final PathConstraints DOCK = new PathConstraints(1, 2);

Expand Down Expand Up @@ -90,7 +94,7 @@ public OnePieceMobilityDock() {
);

addCommands(
new LEDSet(LEDColor.RAINBOW),
new LEDSetRainbow(),

new SwerveDriveBalanceBlay()
.withMaxSpeed(0.6)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.stuypulse.robot.commands.arm.routines.*;
import com.stuypulse.robot.commands.intake.*;
import com.stuypulse.robot.commands.leds.LEDSet;
import com.stuypulse.robot.commands.leds.LEDSetRainbow;
import com.stuypulse.robot.commands.manager.*;
import com.stuypulse.robot.commands.plant.PlantEngage;
import com.stuypulse.robot.commands.swerve.*;
Expand All @@ -15,6 +16,7 @@
import com.stuypulse.robot.util.DebugSequentialCommandGroup;
import com.stuypulse.robot.util.LEDColor;

import edu.wpi.first.wpilibj.AddressableLEDBuffer;
import edu.wpi.first.wpilibj2.command.ParallelCommandGroup;
import edu.wpi.first.wpilibj2.command.ParallelDeadlineGroup;
import edu.wpi.first.wpilibj2.command.PrintCommand;
Expand All @@ -30,6 +32,8 @@ public class OnePiecePickupDock extends DebugSequentialCommandGroup {
private static final double ACQUIRE_WAIT_TIME = 0.4;
private static final double ENGAGE_TIME = 10.0;

private AddressableLEDBuffer ledsBuffer;

private static final PathConstraints INTAKE_PIECE = new PathConstraints(2, 2);
private static final PathConstraints DOCK = new PathConstraints(1, 2);

Expand Down Expand Up @@ -102,7 +106,7 @@ public OnePiecePickupDock() {
);

addCommands(
new LEDSet(LEDColor.RAINBOW),
new LEDSetRainbow(),

new SwerveDriveBalanceBlay()
.withMaxSpeed(0.7)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.stuypulse.robot.commands.arm.routines.*;
import com.stuypulse.robot.commands.intake.*;
import com.stuypulse.robot.commands.leds.LEDSet;
import com.stuypulse.robot.commands.leds.LEDSetRainbow;
import com.stuypulse.robot.commands.manager.*;
import com.stuypulse.robot.commands.plant.PlantEngage;
import com.stuypulse.robot.commands.swerve.*;
Expand All @@ -15,6 +16,7 @@
import com.stuypulse.robot.util.DebugSequentialCommandGroup;
import com.stuypulse.robot.util.LEDColor;

import edu.wpi.first.wpilibj.AddressableLEDBuffer;
import edu.wpi.first.wpilibj2.command.ParallelCommandGroup;
import edu.wpi.first.wpilibj2.command.ParallelDeadlineGroup;
import edu.wpi.first.wpilibj2.command.PrintCommand;
Expand All @@ -31,6 +33,8 @@ public class OnePiecePickupDockWire extends DebugSequentialCommandGroup {
private static final double ENGAGE_TIME = 10.0;
private static final double ACQUIRE_WAIT_TIME = 0.4;

private AddressableLEDBuffer ledsBuffer;

private static final PathConstraints INTAKE_PIECE = new PathConstraints(3, 2);
private static final PathConstraints DOCK = new PathConstraints(1, 2);

Expand Down Expand Up @@ -103,7 +107,7 @@ public OnePiecePickupDockWire() {
);

addCommands(
new LEDSet(LEDColor.RAINBOW),
new LEDSetRainbow(),

new SwerveDriveBalanceBlay()
.withMaxSpeed(0.5)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
import com.stuypulse.robot.commands.arm.routines.*;
import com.stuypulse.robot.commands.intake.*;
import com.stuypulse.robot.commands.leds.LEDSet;
import com.stuypulse.robot.commands.leds.LEDSetRainbow;
import com.stuypulse.robot.commands.manager.*;
import com.stuypulse.robot.commands.swerve.*;
import com.stuypulse.robot.subsystems.Manager.*;
import com.stuypulse.robot.subsystems.arm.Arm;
import com.stuypulse.robot.util.DebugSequentialCommandGroup;
import com.stuypulse.robot.util.LEDColor;

import edu.wpi.first.wpilibj.AddressableLEDBuffer;
import edu.wpi.first.wpilibj2.command.ParallelCommandGroup;
import edu.wpi.first.wpilibj2.command.WaitCommand;

Expand All @@ -22,6 +24,8 @@ public class TwoPiece extends DebugSequentialCommandGroup {
private static final double INTAKE_WAIT_TIME = 2.0;
private static final double ACQUIRE_WAIT_TIME = 0.4;

private AddressableLEDBuffer ledsBuffer;

private static final PathConstraints INTAKE_PIECE_CONSTRAINTS = new PathConstraints(1.7, 2);
private static final PathConstraints SCORE_PIECE_CONSTRAINTS = new PathConstraints(2, 2);

Expand Down Expand Up @@ -106,7 +110,7 @@ public TwoPiece () {
);

addCommands(
new LEDSet(LEDColor.RAINBOW),
new LEDSetRainbow(),
new SwerveDriveFollowTrajectory(
paths.get("Back Away"))
.fieldRelative()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
import com.stuypulse.robot.commands.arm.routines.*;
import com.stuypulse.robot.commands.intake.*;
import com.stuypulse.robot.commands.leds.LEDSet;
import com.stuypulse.robot.commands.leds.LEDSetRainbow;
import com.stuypulse.robot.commands.manager.*;
import com.stuypulse.robot.commands.swerve.*;
import com.stuypulse.robot.subsystems.Manager.*;
import com.stuypulse.robot.subsystems.arm.Arm;
import com.stuypulse.robot.util.DebugSequentialCommandGroup;
import com.stuypulse.robot.util.LEDColor;

import edu.wpi.first.wpilibj.AddressableLEDBuffer;
import edu.wpi.first.wpilibj2.command.ParallelCommandGroup;
import edu.wpi.first.wpilibj2.command.ParallelDeadlineGroup;
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup;
Expand All @@ -26,6 +28,8 @@ public class TwoPieceWire extends DebugSequentialCommandGroup {
private static final double ACQUIRE_WAIT_TIME = 0.4;
private static final double READY_WAIT_TIME = 0.5;

private AddressableLEDBuffer ledsBuffer;

private static final PathConstraints INTAKE_PIECE_CONSTRAINTS = new PathConstraints(2, 2);
private static final PathConstraints SCORE_PIECE_CONSTRAINTS = new PathConstraints(2, 2);

Expand Down Expand Up @@ -110,7 +114,7 @@ public TwoPieceWire() {
);

addCommands(
new LEDSet(LEDColor.RAINBOW),
new LEDSetRainbow(),
new SwerveDriveFollowTrajectory(
paths.get("Back Away"))
.withStop()
Expand Down
25 changes: 24 additions & 1 deletion src/main/java/com/stuypulse/robot/commands/leds/LEDSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,21 @@
/* This work is licensed under the terms of the MIT license. */
/****************************************************************/

/*-
* Contains:
* - commands for LEDs
* @author Richie Xue
* @author Jo Walkup
*/

package com.stuypulse.robot.commands.leds;

import com.stuypulse.robot.subsystems.LEDController;
import com.stuypulse.robot.util.LEDColor;

import com.stuypulse.robot.constants.Settings;
//import com.stuypulse.robot.constants.Ports.LEDController;
import com.stuypulse.robot.subsystems.leds.*;
import com.stuypulse.robot.subsystems.leds.LEDControllerImpl;

import edu.wpi.first.wpilibj2.command.InstantCommand;

Expand All @@ -17,19 +26,33 @@ public class LEDSet extends InstantCommand {
private LEDColor color;
private double updateTime;
private LEDController controller;
private LEDInstruction instruction;

public LEDSet(LEDColor color, double updateTime) {
this.controller = LEDController.getInstance();
this.updateTime = updateTime;
this.color = color;
}

public LEDSet(LEDInstruction instruction, double updateTime) {
this.controller = LEDController.getInstance();
this.updateTime = updateTime;
this.instruction = instruction;
}

public LEDSet(LEDColor color) {
this(color, Settings.LED.MANUAL_UPDATE_TIME);
//System.out.println("LEDSet was called!!!");
}

public LEDSet(LEDInstruction instruction) {
this(instruction, Settings.LED.MANUAL_UPDATE_TIME);
//System.out.println("LEDSet was called!!!");
}

@Override
public void initialize() {
System.out.println("LEDSet was called!!!");
controller.setColor(color, updateTime);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.stuypulse.robot.commands.leds;

import com.stuypulse.robot.constants.Settings;
import com.stuypulse.robot.subsystems.leds.LEDController;
import com.stuypulse.robot.util.LEDColor;

import edu.wpi.first.wpilibj2.command.InstantCommand;

public class LEDSetPulseRed extends InstantCommand {
private LEDController controller;

naowalrahman marked this conversation as resolved.
Show resolved Hide resolved
public LEDSetPulseRed(double updateTime) {
this.controller = LEDController.getInstance();
}

public LEDSetPulseRed() {
this(Settings.LED.MANUAL_UPDATE_TIME);
}

@Override
public void initialize() {
controller.forceSetLED(LEDColor.PULSE_RED);
}
}
Loading