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

Bling #47

Merged
merged 3 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 18 additions & 0 deletions docs/mkdocs/docs/library/commands/bling/noalliancewaiting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# No Alliance Waiting Command

A command that displays a warning animation when no alliance color has been selected. The command automatically terminates once an alliance is selected in the Driver Station.

## Required Subsystems
- [Bling Subsystem](/5152_Template/library/subsystems/bling)

## Constructor Parameters
```java
public NoAllianceWaiting(BlingSubsystem blingSubsystem)
```
- `blingSubsystem`: The bling subsystem instance to control

## Configuration Requirements
None - uses predefined NO_ALLIANCE_ANIMATION from BlingConstants

## Reference Documentation
[No Alliance Waiting Command Javadoc](/5152_Template/javadoc/frc/alotobots/library/subsystems/bling/commands/package-summary.html)
18 changes: 18 additions & 0 deletions docs/mkdocs/docs/library/commands/bling/settoalliancecolor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Set To Alliance Color Command

A command that sets the LED colors to match the current alliance color (red or blue) selected in the Driver Station. This provides a clear visual indicator of which alliance the robot is assigned to.

## Required Subsystems
- [Bling Subsystem](/5152_Template/library/subsystems/bling)

## Constructor Parameters
```java
public SetToAllianceColor(BlingSubsystem blingSubsystem)
```
- `blingSubsystem`: The bling subsystem instance to control

## Configuration Requirements
None - uses predefined RED_ALLIANCE_COLOR and BLUE_ALLIANCE_COLOR from BlingConstants

## Reference Documentation
[Set To Alliance Color Command Javadoc](/5152_Template/javadoc/frc/alotobots/library/subsystems/bling/commands/package-summary.html)
29 changes: 29 additions & 0 deletions docs/mkdocs/docs/library/subsystems/bling.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Bling Subsystem

The Bling subsystem controls the robot's LED lighting system using the CTRE CANdle device. It provides visual feedback about robot state through different colors and animations.

## Constructor

```java
public BlingSubsystem(BlingIO io)
```

- `io`: The BlingIO implementation to use (either BlingIOReal for hardware or BlingIOSim for simulation)

## Commands Using This Subsystem

- [No Alliance Waiting Command](/5152_Template/library/commands/bling/noalliancewaiting)
- [Set To Alliance Color Command](/5152_Template/library/commands/bling/settoalliancecolor)

## Configuration Requirements

1. CANdle CAN ID must be set in Constants file
2. LED strip configuration in BlingConstants:
- Number of LEDs (NUM_LEDS)
- LED strip type (LED_TYPE)
- Maximum brightness (MAX_LED_BRIGHTNESS)
- LED offset (LED_OFFSET)
- Status LED state (DISABLE_STATUS_LED)

## Reference Documentation
[Bling Subsystem Javadoc](/5152_Template/javadoc/frc/alotobots/library/subsystems/bling/package-summary.html)
4 changes: 4 additions & 0 deletions docs/mkdocs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@ nav:
- Drive Facing Angle: library/commands/swerve/drivefacingangle.md
- Drive Facing Pose: library/commands/swerve/drivefacingpose.md
- Characterization: library/commands/swerve/characterization.md
- Bling:
- Set To Alliance Color: library/commands/bling/settoalliancecolor.md
- No Alliance Waiting: library/commands/bling/noalliancewaiting.md
- Vision:
- Object Detection:
- Drive Facing Best Object: library/commands/vision/objectdetection/drivefacingbestobject.md
- Pathfind to Best Object: library/commands/vision/objectdetection/pathfindtobestobject.md
- Subsystems:
- Swerve: library/subsystems/swerve.md
- Bling: library/subsystems/bling.md
- Vision:
- Object Detection: library/subsystems/vision/objectdetection.md
- AprilTag: library/subsystems/vision/apriltag.md
Expand Down
92 changes: 92 additions & 0 deletions simgui-ds.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"keyboardJoysticks": [
{
"axisConfig": [
{
"decKey": 65,
"incKey": 68
},
{
"decKey": 87,
"incKey": 83
},
{
"decKey": 69,
"decayRate": 0.0,
"incKey": 82,
"keyRate": 0.009999999776482582
}
],
"axisCount": 3,
"buttonCount": 4,
"buttonKeys": [
90,
88,
67,
86
],
"povConfig": [
{
"key0": 328,
"key135": 323,
"key180": 322,
"key225": 321,
"key270": 324,
"key315": 327,
"key45": 329,
"key90": 326
}
],
"povCount": 1
},
{
"axisConfig": [
{
"decKey": 74,
"incKey": 76
},
{
"decKey": 73,
"incKey": 75
}
],
"axisCount": 2,
"buttonCount": 4,
"buttonKeys": [
77,
44,
46,
47
],
"povCount": 0
},
{
"axisConfig": [
{
"decKey": 263,
"incKey": 262
},
{
"decKey": 265,
"incKey": 264
}
],
"axisCount": 2,
"buttonCount": 6,
"buttonKeys": [
260,
268,
266,
261,
269,
267
],
"povCount": 0
},
{
"axisCount": 0,
"buttonCount": 0,
"povCount": 0
}
]
}
2 changes: 1 addition & 1 deletion src/main/java/frc/alotobots/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* (log replay from a file).
*/
public final class Constants {
public static final Mode simMode = Mode.REPLAY;
public static final Mode simMode = Mode.SIM;
public static final Mode currentMode = RobotBase.isReal() ? Mode.REAL : simMode;

public static enum Mode {
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/frc/alotobots/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
import com.pathplanner.lib.auto.AutoBuilder;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.sysid.SysIdRoutine;
import frc.alotobots.library.subsystems.bling.BlingSubsystem;
import frc.alotobots.library.subsystems.bling.commands.NoAllianceWaiting;
import frc.alotobots.library.subsystems.bling.commands.SetToAllianceColor;
import frc.alotobots.library.subsystems.bling.io.BlingIO;
import frc.alotobots.library.subsystems.bling.io.BlingIOReal;
import frc.alotobots.library.subsystems.bling.io.BlingIOSim;
import frc.alotobots.library.subsystems.swervedrive.ModulePosition;
import frc.alotobots.library.subsystems.swervedrive.SwerveDriveSubsystem;
import frc.alotobots.library.subsystems.swervedrive.commands.DefaultDrive;
Expand Down Expand Up @@ -49,6 +55,7 @@ public class RobotContainer {
private final SwerveDriveSubsystem swerveDriveSubsystem;
private final AprilTagSubsystem aprilTagSubsystem;
private final ObjectDetectionSubsystem objectDetectionSubsystem;
private final BlingSubsystem blingSubsystem;

// Dashboard inputs
private final LoggedDashboardChooser<Command> autoChooser;
Expand All @@ -74,6 +81,7 @@ public RobotContainer() {
new ObjectDetectionSubsystem(
swerveDriveSubsystem::getPose,
new ObjectDetectionIOPhotonVision(ObjectDetectionConstants.CAMERA_CONFIGS[0]));
blingSubsystem = new BlingSubsystem(new BlingIOReal());
break;

case SIM:
Expand All @@ -95,6 +103,7 @@ public RobotContainer() {
// Sim support for object detection doesn't exist yet, so use a no-op
objectDetectionSubsystem =
new ObjectDetectionSubsystem(swerveDriveSubsystem::getPose, new ObjectDetectionIO() {});
blingSubsystem = new BlingSubsystem(new BlingIOSim());
break;

default:
Expand All @@ -114,6 +123,7 @@ public RobotContainer() {
new AprilTagIO() {});
objectDetectionSubsystem =
new ObjectDetectionSubsystem(swerveDriveSubsystem::getPose, new ObjectDetectionIO() {});
blingSubsystem = new BlingSubsystem(new BlingIO() {});
break;
}

Expand Down Expand Up @@ -147,6 +157,8 @@ public RobotContainer() {
private void configureDefaultCommands() {

swerveDriveSubsystem.setDefaultCommand(new DefaultDrive(swerveDriveSubsystem).getCommand());
blingSubsystem.setDefaultCommand(
new NoAllianceWaiting(blingSubsystem).andThen(new SetToAllianceColor(blingSubsystem)));
// Add other subsystem default commands here as needed
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* ALOTOBOTS - FRC Team 5152
https://github.com/5152Alotobots
* Copyright (C) 2024 ALOTOBOTS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Source code must be publicly available on GitHub or an alternative web accessible site
*/
package frc.alotobots.library.subsystems.bling;

import com.ctre.phoenix.led.Animation;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc.alotobots.library.subsystems.bling.io.BlingIO;
import frc.alotobots.library.subsystems.bling.io.BlingIOInputsAutoLogged;
import org.littletonrobotics.junction.Logger;

/**
* Subsystem for controlling robot LED lighting effects. Manages LED animations and solid colors for
* visual feedback.
*/
public class BlingSubsystem extends SubsystemBase {
/** The IO interface for LED control */
private final BlingIO io;

/** Logged inputs for monitoring LED state */
private final BlingIOInputsAutoLogged inputs = new BlingIOInputsAutoLogged();

/**
* Creates a new BlingSubsystem.
*
* @param io The BlingIO implementation to use for LED control
*/
public BlingSubsystem(BlingIO io) {
this.io = io;
}

@Override
public void periodic() {
// Update inputs
io.updateInputs(inputs);
Logger.processInputs("Bling", inputs);
if (this.getCurrentCommand() != null) {
Logger.recordOutput("Bling/CurrentCommand", this.getCurrentCommand().getName());
} else {
Logger.recordOutput("Bling/CurrentCommand", "None");
}
}

/**
* Sets the LEDs to display a solid color.
*
* @param color The color to display
*/
public void setSolidColor(BlingIO.LoggedColor color) {
io.setSolidColor(color);
}

/**
* Sets the LEDs to display an animation pattern.
*
* @param animation The animation pattern to display
*/
public void setAnimation(Animation animation) {
io.setAnimation(animation);
}

/** Clears all LED effects, turning off animations and solid colors. */
public void clear() {
io.clearAnimation();
io.clearSolidColor();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* ALOTOBOTS - FRC Team 5152
https://github.com/5152Alotobots
* Copyright (C) 2024 ALOTOBOTS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Source code must be publicly available on GitHub or an alternative web accessible site
*/
package frc.alotobots.library.subsystems.bling.commands;

import static frc.alotobots.library.subsystems.bling.constants.BlingConstants.Animations.NO_ALLIANCE_ANIMATION;

import edu.wpi.first.wpilibj.DriverStation;
import edu.wpi.first.wpilibj2.command.Command;
import frc.alotobots.library.subsystems.bling.BlingSubsystem;

/**
* Command that displays an animation while waiting for alliance selection. Automatically terminates
* once an alliance is selected.
*/
public class NoAllianceWaiting extends Command {
/** The bling subsystem to control */
private BlingSubsystem blingSubsystem;

/**
* Creates a new NoAllianceWaiting command.
*
* @param blingSubsystem The bling subsystem to use
*/
public NoAllianceWaiting(BlingSubsystem blingSubsystem) {
this.blingSubsystem = blingSubsystem;
addRequirements(blingSubsystem);
}

@Override
public void initialize() {
blingSubsystem.setAnimation(NO_ALLIANCE_ANIMATION);
}

@Override
public boolean isFinished() {
// Exit once we have an alliance
return DriverStation.getAlliance().isPresent();
}

@Override
public void end(boolean interrupted) {
blingSubsystem.clear();
}

@Override
public boolean runsWhenDisabled() {
return true;
}
}
Loading
Loading