Skip to content

Commit 2d266d7

Browse files
led changes and speed nerf
1 parent a27dbc5 commit 2d266d7

11 files changed

Lines changed: 112 additions & 26 deletions

File tree

simgui.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,19 @@
3939
"/SmartDashboard/Auto Choices": "String Chooser"
4040
}
4141
},
42+
"NetworkTables": {
43+
"transitory": {
44+
"AdvantageKit": {
45+
"DashboardInputs": {
46+
"Tunables": {
47+
"open": true
48+
},
49+
"open": true
50+
},
51+
"open": true
52+
}
53+
}
54+
},
4255
"NetworkTables Info": {
4356
"visible": true
4457
}

src/main/java/frc/robot/BuildConstants.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ public final class BuildConstants {
55
public static final String MAVEN_GROUP = "";
66
public static final String MAVEN_NAME = "2024RobotCode";
77
public static final String VERSION = "unspecified";
8-
public static final int GIT_REVISION = 361;
9-
public static final String GIT_SHA = "126bd62e4eadeddbff158d35c227625365cfe515";
10-
public static final String GIT_DATE = "2024-12-10 19:23:32 EST";
8+
public static final int GIT_REVISION = 363;
9+
public static final String GIT_SHA = "a27dbc5a757b7f0fdf003be06873c4de1eadca2d";
10+
public static final String GIT_DATE = "2025-05-20 18:24:52 EDT";
1111
public static final String GIT_BRANCH = "tk-demo-mode";
12-
public static final String BUILD_DATE = "2025-05-20 18:20:14 EDT";
13-
public static final long BUILD_UNIX_TIME = 1747779614363L;
12+
public static final String BUILD_DATE = "2025-09-13 16:10:01 EDT";
13+
public static final long BUILD_UNIX_TIME = 1757794201901L;
1414
public static final int DIRTY = 1;
1515

1616
private BuildConstants() {}

src/main/java/frc/robot/Constants.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
package frc.robot;
1515

1616
import edu.wpi.first.math.util.Units;
17+
import frc.robot.util.LoggedTunableNumber;
1718

1819
/**
1920
* The Constants class provides a convenient place for teams to hold robot-wide numerical or boolean
@@ -124,7 +125,7 @@ public static class PivotConstants {
124125
public static final boolean CURRENT_LIMIT_ENABLED = true;
125126

126127
public static final double PODIUM_SETPOINT_DEG = 41.45;
127-
public static final double STOW_SETPOINT_DEG = 50.7;
128+
public static final double STOW_SETPOINT_DEG = 60;
128129
public static final double INTAKE_SETPOINT_DEG = 59.0;
129130
public static final double AMP_SETPOINT_DEG = 58.6;
130131
public static final double SUBWOOFER_SETPOINT_DEG = 62.0;
@@ -150,6 +151,8 @@ public static class LEDConstants {
150151
public static final double COLOR_RED = 0.61;
151152
public static final double COLOR_YELLOW = 0.66;
152153
public static final double COLOR_VIOLET = 0.91;
154+
public static final LoggedTunableNumber debugLEDIdx =
155+
new LoggedTunableNumber("debugLEDIdx", 50);
153156
}
154157

155158
public static enum NOTE_POSITIONS {

src/main/java/frc/robot/Robot.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
import com.ctre.phoenix6.SignalLogger;
1717
import com.pathplanner.lib.pathfinding.Pathfinding;
18+
import edu.wpi.first.math.filter.LinearFilter;
19+
import edu.wpi.first.wpilibj.RobotController;
1820
import edu.wpi.first.wpilibj2.command.Command;
1921
import edu.wpi.first.wpilibj2.command.CommandScheduler;
2022
import frc.robot.Constants.LED_STATE;
@@ -37,6 +39,9 @@ public class Robot extends LoggedRobot {
3739

3840
private Command autonomousCommand;
3941
private RobotContainer m_robotContainer;
42+
43+
private static final LinearFilter voltageFilter = LinearFilter.movingAverage(500);
44+
private static double filteredVoltage;
4045
/**
4146
* This function is run when the robot is first started up and should be used for any
4247
* initialization code.
@@ -110,12 +115,18 @@ public void robotPeriodic() {
110115
// This must be called from the robot's periodic block in order for anything in
111116
// the Command-based framework to work.
112117
CommandScheduler.getInstance().run();
118+
119+
filteredVoltage = voltageFilter.calculate(RobotController.getBatteryVoltage());
120+
}
121+
122+
public static double getFilteredVoltage() {
123+
return filteredVoltage;
113124
}
114125

115126
/** This function is called once when the robot is disabled. */
116127
@Override
117128
public void disabledInit() {
118-
m_robotContainer.getLED().setState(LED_STATE.FIRE);
129+
m_robotContainer.getLED().setState(LED_STATE.BLUE);
119130
m_robotContainer.getClimbStateMachine().setClimbState(CLIMB_STATES.NONE);
120131
}
121132

src/main/java/frc/robot/RobotContainer.java

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import edu.wpi.first.math.geometry.Pose2d;
1818
import edu.wpi.first.math.geometry.Rotation2d;
1919
import edu.wpi.first.wpilibj.GenericHID;
20+
import edu.wpi.first.wpilibj.RobotController;
2021
import edu.wpi.first.wpilibj.XboxController;
2122
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
2223
import edu.wpi.first.wpilibj2.command.Command;
@@ -478,6 +479,18 @@ private void configureButtonBindings() {
478479
}
479480

480481
private void demoControls() {
482+
// led.setDefaultCommand(new BatteryDisplay(led));
483+
// alternatively
484+
// new Trigger(() -> RobotController.getBatteryVoltage() < 11)
485+
// .onTrue(
486+
// new InstantCommand(() -> led.setState(LED_STATE.PURPLE))
487+
// .andThen(new WaitCommand(0.2))
488+
// .andThen(new InstantCommand(() -> led.setState(LED_STATE.YELLOW))));
489+
// alternatively alternatively
490+
new Trigger(() -> RobotController.getBatteryVoltage() < 11)
491+
.onTrue(new InstantCommand(() -> led.setState(LED_STATE.PURPLE)))
492+
.onFalse(new InstantCommand(() -> led.setState(LED_STATE.YELLOW)));
493+
481494
drive.setDefaultCommand(
482495
DriveCommands.joystickDrive(
483496
drive,
@@ -592,28 +605,28 @@ private void demoControls() {
592605
// new InstantCommand(() -> trapStateMachine.setTargetState(TRAP_STATES.PIVOT)),
593606
// new SetElevatorTarget(0, 1.5, elevator),
594607
new InstantCommand(() -> pivot.setShootState(SHOOT_STATE.PIVOT_PRESET)),
595-
new SetPivotTarget(45, pivot),
596-
new InstantCommand(() -> shooter.setFlywheelRPMs(1500, 1900))));
608+
new SetPivotTarget(60, pivot),
609+
new InstantCommand(() -> shooter.setFlywheelRPMs(1200, 1600))));
597610
driveController
598611
.b()
599612
.onFalse(
600613
new InstantCommand(() -> led.setState(LED_STATE.BLUE))
601614
.andThen(new InstantCommand(() -> shooter.stopFlywheels()))
602615
.andThen(new SetPivotTarget(Constants.PivotConstants.STOW_SETPOINT_DEG, pivot)));
603-
604-
driveController
605-
.a()
606-
.onTrue(
607-
new SequentialCommandGroup(
608-
new InstantCommand(() -> pivot.setShootState(SHOOT_STATE.PIVOT_PRESET)),
609-
new SetPivotTarget(45, pivot),
610-
new InstantCommand(() -> shooter.setFlywheelRPMs(5600, 6000))));
611-
driveController
612-
.a()
613-
.onFalse(
614-
new InstantCommand(() -> led.setState(LED_STATE.BLUE))
615-
.andThen(new InstantCommand(() -> shooter.stopFlywheels()))
616-
.andThen(new SetPivotTarget(Constants.PivotConstants.STOW_SETPOINT_DEG, pivot)));
616+
617+
// driveController
618+
// .a()
619+
// .onTrue(
620+
// new SequentialCommandGroup(
621+
// new InstantCommand(() -> pivot.setShootState(SHOOT_STATE.PIVOT_PRESET)),
622+
// new SetPivotTarget(60, pivot),
623+
// new InstantCommand(() -> shooter.setFlywheelRPMs(5600, 6000))));
624+
// driveController
625+
// .a()
626+
// .onFalse(
627+
// new InstantCommand(() -> led.setState(LED_STATE.BLUE))
628+
// .andThen(new InstantCommand(() -> shooter.stopFlywheels()))
629+
// .andThen(new SetPivotTarget(Constants.PivotConstants.STOW_SETPOINT_DEG, pivot)));
617630

618631
driveController.back().onTrue(new SetPivotTarget(95, pivot));
619632
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package frc.robot.commands;
2+
3+
import edu.wpi.first.wpilibj.RobotController;
4+
import edu.wpi.first.wpilibj2.command.Command;
5+
import frc.robot.Constants;
6+
import frc.robot.subsystems.led.LED;
7+
8+
public class BatteryDisplay extends Command {
9+
private final LED led;
10+
11+
public BatteryDisplay(LED led) {
12+
this.led = led;
13+
addRequirements(led);
14+
}
15+
16+
@Override
17+
public void execute() {
18+
led.setLEDs(226, 0, 0, 0, 33, 24);
19+
led.setLEDs(
20+
0, 226, 0, 0, 33, (int) (24 * normalize(RobotController.getBatteryVoltage(), 11.0, 12.5)));
21+
led.setLEDs(255, 255, 255, 0, (int) Constants.LEDConstants.debugLEDIdx.get(), 1);
22+
}
23+
24+
private double normalize(double x, double min, double max) {
25+
double result = (x - min) / (max - min);
26+
if (result > 1) {
27+
return 1;
28+
}
29+
if (result < 0) {
30+
return 0;
31+
}
32+
return result;
33+
}
34+
}

src/main/java/frc/robot/subsystems/drive/Drive.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@
6666
import org.littletonrobotics.junction.Logger;
6767

6868
public class Drive extends SubsystemBase {
69-
private static final double MAX_LINEAR_SPEED = Constants.SwerveConstants.MAX_LINEAR_SPEED * 0.4;
69+
private static final double MAX_LINEAR_SPEED = Constants.SwerveConstants.MAX_LINEAR_SPEED * 0.2;
7070
private static final double TRACK_WIDTH_X = Constants.SwerveConstants.TRACK_WIDTH_X;
7171
private static final double TRACK_WIDTH_Y = Constants.SwerveConstants.TRACK_WIDTH_Y;
7272
private static final double DRIVE_BASE_RADIUS = Constants.SwerveConstants.DRIVE_BASE_RADIUS;
73-
private static final double MAX_ANGULAR_SPEED = Constants.SwerveConstants.MAX_ANGULAR_SPEED;
73+
private static final double MAX_ANGULAR_SPEED = Constants.SwerveConstants.MAX_ANGULAR_SPEED * 0.4;
7474
private static double multiplier = 1.0;
7575
private static boolean toggle = false;
7676

@@ -200,6 +200,7 @@ public Drive(
200200
}
201201

202202
public void periodic() {
203+
203204
gyroIO.updateInputs(gyroInputs);
204205
visionIO.updateInputs(visionInputs);
205206
Logger.processInputs("Vision/Limelight", visionInputs);

src/main/java/frc/robot/subsystems/drive/Module.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public Module(ModuleIO io, int index) {
4545
case REAL:
4646
driveFeedforward = new SimpleMotorFeedforward(0.1, 0.13);
4747
driveFeedback = new PIDController(0.05, 0.0, 0.0);
48-
turnFeedback = new PIDController(7.0, 0.0, 0.0);
48+
turnFeedback = new PIDController(3.5, 0.0, 0.0);
4949
break;
5050
case REPLAY:
5151
driveFeedforward = new SimpleMotorFeedforward(0.1, 0.13);

src/main/java/frc/robot/subsystems/led/LED.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,8 @@ public void setState(LED_STATE state) {
3434
led.setLEDState(state);
3535
Logger.recordOutput("Set State", state);
3636
}
37+
38+
public void setLEDs(int r, int g, int b, int w, int startIdx, int count) {
39+
led.setLEDs(r, g, b, w, startIdx, count);
40+
}
3741
}

src/main/java/frc/robot/subsystems/led/LED_IO.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,6 @@ public default void updateInputs(LED_IOInputs inputs) {}
2121
public default void noBumpersPressed() {}
2222

2323
public default void setLEDState(LED_STATE state) {}
24+
25+
public default void setLEDs(int r, int g, int b, int w, int startIdx, int count) {}
2426
}

0 commit comments

Comments
 (0)