From 0964af787974f0efe33f7e4d3ee6fefbf1937a7f Mon Sep 17 00:00:00 2001 From: Nora Date: Thu, 5 Dec 2024 17:13:57 -0800 Subject: [PATCH] Code ready for outreach --- src/main/java/frc/robot/RobotContainer.java | 29 ++--------- .../frc/robot/subsystems/RGBSubsystem.java | 4 +- .../robot/subsystems/flywheels/Flywheels.java | 2 +- .../GenericSuperstructureIOTalonFX.java | 19 ++++--- .../superstructure/pivot/Pivot.java | 2 +- .../frc/robot/subsystems/swerve/Drive.java | 6 +-- vendordeps/Phoenix5.json | 52 +++++++++++++------ 7 files changed, 56 insertions(+), 58 deletions(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index d49a407..5260013 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -4,13 +4,10 @@ package frc.robot; -import edu.wpi.first.wpilibj.DriverStation; -import edu.wpi.first.wpilibj.DriverStation.Alliance; import edu.wpi.first.wpilibj2.command.FunctionalCommand; import edu.wpi.first.wpilibj2.command.InstantCommand; import edu.wpi.first.wpilibj2.command.WaitCommand; import edu.wpi.first.wpilibj2.command.button.CommandXboxController; -import edu.wpi.first.wpilibj2.command.button.Trigger; import frc.robot.Constants.Mode; import frc.robot.subsystems.RGBSubsystem; import frc.robot.subsystems.flywheels.Flywheels; @@ -37,7 +34,6 @@ import frc.robot.subsystems.swerve.GyroIOPigeon2; import frc.robot.subsystems.swerve.ModuleIO; import frc.robot.subsystems.swerve.ModuleIOTalonFX; -import java.util.function.DoubleSupplier; /** * This class is where the bulk of the robot should be declared. Since Command-based is a @@ -156,13 +152,6 @@ private void configureBindings() { interrupted -> rollers.setTargetState(RollerState.IDLE), () -> rollers.serializerDetected(), rollers)) - .andThen( - new InstantCommand( - () -> - rgbSubsystem.showMessage( - RGBSubsystem.Lights.Colors.RED, - RGBSubsystem.PatternTypes.STROBE, - RGBSubsystem.MessagePriority.F_NOTE_IN_ROBOT))) .andThen( new InstantCommand(() -> rollers.setTargetState(RollerState.AMP_EJECT), rollers) .withTimeout(0.6)) @@ -186,13 +175,6 @@ private void configureBindings() { interrupted -> rollers.setTargetState(RollerState.IDLE), () -> rollers.serializerDetected(), rollers)) - .andThen( - new InstantCommand( - () -> - rgbSubsystem.showMessage( - RGBSubsystem.Lights.Colors.RED, - RGBSubsystem.PatternTypes.STROBE, - RGBSubsystem.MessagePriority.F_NOTE_IN_ROBOT))) .andThen( new InstantCommand(() -> rollers.setTargetState(RollerState.AMP_EJECT), rollers) .withTimeout(0.6)) @@ -240,8 +222,7 @@ private void configureBindings() { flywheels.setVelocityTarget(Flywheels.VelocityTarget.IDLE); superstructure.setTargetState(SuperstructureState.STOW); } - })) - .andThen(new InstantCommand(() -> rgbSubsystem.expireCurrent()))); + }))); driverB .rightBumper() .onTrue( @@ -264,9 +245,7 @@ private void configureBindings() { flywheels.setVelocityTarget(Flywheels.VelocityTarget.IDLE); superstructure.setTargetState(SuperstructureState.STOW); } - })) - .andThen(new InstantCommand(() -> rgbSubsystem.expireCurrent()))); - + }))); // transfer note to shooter driverB .b() @@ -390,7 +369,7 @@ private void configureBindings() { // flywheels.setVelocityTarget(VelocityTarget.IDLE); // }, // flywheels)); - + // cancel everything driverB .x() @@ -423,7 +402,7 @@ private void configureBindings() { .onTrue(new InstantCommand(() -> superstructure.setTargetState(SuperstructureState.STOW))); driverB .povUp() - .onTrue(new InstantCommand(() -> superstructure.setTargetState(SuperstructureState.AMP))); + .onTrue(new InstantCommand(() -> superstructure.setTargetState(SuperstructureState.AMP))); } private void configureAutos() {} diff --git a/src/main/java/frc/robot/subsystems/RGBSubsystem.java b/src/main/java/frc/robot/subsystems/RGBSubsystem.java index 1584406..0641070 100644 --- a/src/main/java/frc/robot/subsystems/RGBSubsystem.java +++ b/src/main/java/frc/robot/subsystems/RGBSubsystem.java @@ -19,7 +19,7 @@ public class RGBSubsystem extends SubsystemBase { public static final class Lights { public static final int CANDLE_ID = 34; - public static final int NUM_LEDS = 227; // 8 in candle + public static final int NUM_LEDS = 226; // 8 in candle public static final class Colors { public static final RGBColor YELLOW = new RGBColor(255, 107, 0); @@ -194,7 +194,7 @@ public void showMessage(RGBMessage message) { } private void showRainbow() { - candle.animate(new RainbowAnimation(0.3, 0.5, Lights.NUM_LEDS)); + candle.animate(new RainbowAnimation(1, 0.5, Lights.NUM_LEDS)); lastAppliedAnimation = Optional.of(CurrentAnimationTypes.RAINBOW); lastAppliedColor = Optional.empty(); } diff --git a/src/main/java/frc/robot/subsystems/flywheels/Flywheels.java b/src/main/java/frc/robot/subsystems/flywheels/Flywheels.java index cd6a5f5..6120ea2 100644 --- a/src/main/java/frc/robot/subsystems/flywheels/Flywheels.java +++ b/src/main/java/frc/robot/subsystems/flywheels/Flywheels.java @@ -9,7 +9,7 @@ public class Flywheels extends SubsystemBase { // RPM public enum VelocityTarget { IDLE(0, 0), - SHOOT(5000, 5000), + SHOOT(2000, 2000), SLOW(1200, 1200); private int topVelocity, bottomVelocity; diff --git a/src/main/java/frc/robot/subsystems/superstructure/GenericSuperstructureIOTalonFX.java b/src/main/java/frc/robot/subsystems/superstructure/GenericSuperstructureIOTalonFX.java index 9b9640f..3ba39e7 100644 --- a/src/main/java/frc/robot/subsystems/superstructure/GenericSuperstructureIOTalonFX.java +++ b/src/main/java/frc/robot/subsystems/superstructure/GenericSuperstructureIOTalonFX.java @@ -11,21 +11,25 @@ import com.ctre.phoenix6.controls.VoltageOut; import com.ctre.phoenix6.hardware.CANcoder; import com.ctre.phoenix6.hardware.TalonFX; -import com.ctre.phoenix6.signals.AbsoluteSensorRangeValue; import com.ctre.phoenix6.signals.GravityTypeValue; import com.ctre.phoenix6.signals.InvertedValue; import com.ctre.phoenix6.signals.NeutralModeValue; import com.ctre.phoenix6.signals.SensorDirectionValue; +import edu.wpi.first.units.measure.Angle; +import edu.wpi.first.units.measure.AngularVelocity; +import edu.wpi.first.units.measure.Current; +import edu.wpi.first.units.measure.Temperature; +import edu.wpi.first.units.measure.Voltage; import java.util.Optional; public class GenericSuperstructureIOTalonFX implements GenericSuperstructureIO { private final TalonFX talon; - private final StatusSignal positionRotations; - private final StatusSignal velocityRPS; - private final StatusSignal appliedVolts; - private final StatusSignal supplyCurrent; - private final StatusSignal temp; + private final StatusSignal positionRotations; + private final StatusSignal velocityRPS; + private final StatusSignal appliedVolts; + private final StatusSignal supplyCurrent; + private final StatusSignal temp; private final VoltageOut voltageOutput = new VoltageOut(0).withUpdateFreqHz(0); private final NeutralOut neutralOutput = new NeutralOut(); @@ -61,7 +65,6 @@ public GenericSuperstructureIOTalonFX( new CANcoderConfiguration() .withMagnetSensor( new MagnetSensorConfigs() - .withAbsoluteSensorRange(AbsoluteSensorRangeValue.Unsigned_0To1) .withSensorDirection(SensorDirectionValue.Clockwise_Positive) .withMagnetOffset(0))); @@ -73,7 +76,7 @@ public GenericSuperstructureIOTalonFX( talon.setPosition(0); talon.setNeutralMode(NeutralModeValue.Brake); - velocityRPS = talon.getClosedLoopError(); + velocityRPS = talon.getVelocity(); appliedVolts = talon.getMotorVoltage(); supplyCurrent = talon.getSupplyCurrent(); temp = talon.getDeviceTemp(); diff --git a/src/main/java/frc/robot/subsystems/superstructure/pivot/Pivot.java b/src/main/java/frc/robot/subsystems/superstructure/pivot/Pivot.java index 869b8c9..b50f2f1 100644 --- a/src/main/java/frc/robot/subsystems/superstructure/pivot/Pivot.java +++ b/src/main/java/frc/robot/subsystems/superstructure/pivot/Pivot.java @@ -6,7 +6,7 @@ public class Pivot extends GenericSuperstructure { public enum PivotTarget implements GenericSuperstructure.PositionTarget { STOW(0), ZERO(0), - SUBWOOF_SHOT(53), + SUBWOOF_SHOT(70), SHUTTLE(45); private double position; diff --git a/src/main/java/frc/robot/subsystems/swerve/Drive.java b/src/main/java/frc/robot/subsystems/swerve/Drive.java index 0f36eaa..eb5be9e 100644 --- a/src/main/java/frc/robot/subsystems/swerve/Drive.java +++ b/src/main/java/frc/robot/subsystems/swerve/Drive.java @@ -3,7 +3,6 @@ import static frc.robot.subsystems.swerve.DriveConstants.DRIVE_CONFIG; import static frc.robot.subsystems.swerve.DriveConstants.KINEMATICS; -import edu.wpi.first.math.MathUtil; import edu.wpi.first.math.controller.PIDController; import edu.wpi.first.math.geometry.Rotation2d; import edu.wpi.first.math.kinematics.ChassisSpeeds; @@ -12,8 +11,8 @@ import edu.wpi.first.wpilibj.DriverStation; import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.SubsystemBase; -import frc.robot.Util; import frc.robot.Constants; +import frc.robot.Util; import frc.robot.subsystems.swerve.controllers.TeleopController; import org.littletonrobotics.junction.AutoLogOutput; import org.littletonrobotics.junction.Logger; @@ -74,9 +73,6 @@ public void periodic() { targetSpeeds = teleopController.update(arbitraryYaw); } case TRAJECTORY -> {} - case ANGLE -> { - targetSpeeds = teleopTargetSpeeds; - } } // run modules diff --git a/vendordeps/Phoenix5.json b/vendordeps/Phoenix5.json index ff7359e..65dfcff 100644 --- a/vendordeps/Phoenix5.json +++ b/vendordeps/Phoenix5.json @@ -1,43 +1,56 @@ { - "fileName": "Phoenix5.json", + "fileName": "Phoenix5-frc2025-beta-latest.json", "name": "CTRE-Phoenix (v5)", - "version": "5.33.1", - "frcYear": 2024, + "version": "5.34.0-beta-3", + "frcYear": "2025", "uuid": "ab676553-b602-441f-a38d-f1296eff6537", "mavenUrls": [ "https://maven.ctr-electronics.com/release/" ], - "jsonUrl": "https://maven.ctr-electronics.com/release/com/ctre/phoenix/Phoenix5-frc2024-latest.json", + "jsonUrl": "https://maven.ctr-electronics.com/release/com/ctre/phoenix/Phoenix5-frc2025-beta-latest.json", "requires": [ { "uuid": "e995de00-2c64-4df5-8831-c1441420ff19", "errorMessage": "Phoenix 5 requires low-level libraries from Phoenix 6. Please add the Phoenix 6 vendordep before adding Phoenix 5.", - "offlineFileName": "Phoenix6.json", - "onlineUrl": "https://maven.ctr-electronics.com/release/com/ctre/phoenix6/latest/Phoenix6-frc2024-latest.json" + "offlineFileName": "Phoenix6-frc2025-beta-latest.json", + "onlineUrl": "https://maven.ctr-electronics.com/release/com/ctre/phoenix6/latest/Phoenix6-frc2025-beta-latest.json" + } + ], + "conflictsWith": [ + { + "uuid": "e7900d8d-826f-4dca-a1ff-182f658e98af", + "errorMessage": "Users must use the Phoenix 5 replay vendordep when using the Phoenix 6 replay vendordep.", + "offlineFileName": "Phoenix6-replay-frc2025-beta-latest.json" + }, + { + "uuid": "fbc886a4-2cec-40c0-9835-71086a8cc3df", + "errorMessage": "Users cannot have both the replay and regular Phoenix 5 vendordeps in their robot program.", + "offlineFileName": "Phoenix5-replay-frc2025-beta-latest.json" } ], "javaDependencies": [ { "groupId": "com.ctre.phoenix", "artifactId": "api-java", - "version": "5.33.1" + "version": "5.34.0-beta-3" }, { "groupId": "com.ctre.phoenix", "artifactId": "wpiapi-java", - "version": "5.33.1" + "version": "5.34.0-beta-3" } ], "jniDependencies": [ { "groupId": "com.ctre.phoenix", "artifactId": "cci", - "version": "5.33.1", + "version": "5.34.0-beta-3", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ "windowsx86-64", "linuxx86-64", + "linuxarm64", "linuxathena" ], "simMode": "hwsim" @@ -45,12 +58,13 @@ { "groupId": "com.ctre.phoenix.sim", "artifactId": "cci-sim", - "version": "5.33.1", + "version": "5.34.0-beta-3", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ "windowsx86-64", "linuxx86-64", + "linuxarm64", "osxuniversal" ], "simMode": "swsim" @@ -60,7 +74,7 @@ { "groupId": "com.ctre.phoenix", "artifactId": "wpiapi-cpp", - "version": "5.33.1", + "version": "5.34.0-beta-3", "libName": "CTRE_Phoenix_WPI", "headerClassifier": "headers", "sharedLibrary": true, @@ -68,6 +82,7 @@ "binaryPlatforms": [ "windowsx86-64", "linuxx86-64", + "linuxarm64", "linuxathena" ], "simMode": "hwsim" @@ -75,7 +90,7 @@ { "groupId": "com.ctre.phoenix", "artifactId": "api-cpp", - "version": "5.33.1", + "version": "5.34.0-beta-3", "libName": "CTRE_Phoenix", "headerClassifier": "headers", "sharedLibrary": true, @@ -83,6 +98,7 @@ "binaryPlatforms": [ "windowsx86-64", "linuxx86-64", + "linuxarm64", "linuxathena" ], "simMode": "hwsim" @@ -90,7 +106,7 @@ { "groupId": "com.ctre.phoenix", "artifactId": "cci", - "version": "5.33.1", + "version": "5.34.0-beta-3", "libName": "CTRE_PhoenixCCI", "headerClassifier": "headers", "sharedLibrary": true, @@ -98,6 +114,7 @@ "binaryPlatforms": [ "windowsx86-64", "linuxx86-64", + "linuxarm64", "linuxathena" ], "simMode": "hwsim" @@ -105,7 +122,7 @@ { "groupId": "com.ctre.phoenix.sim", "artifactId": "wpiapi-cpp-sim", - "version": "5.33.1", + "version": "5.34.0-beta-3", "libName": "CTRE_Phoenix_WPISim", "headerClassifier": "headers", "sharedLibrary": true, @@ -113,6 +130,7 @@ "binaryPlatforms": [ "windowsx86-64", "linuxx86-64", + "linuxarm64", "osxuniversal" ], "simMode": "swsim" @@ -120,7 +138,7 @@ { "groupId": "com.ctre.phoenix.sim", "artifactId": "api-cpp-sim", - "version": "5.33.1", + "version": "5.34.0-beta-3", "libName": "CTRE_PhoenixSim", "headerClassifier": "headers", "sharedLibrary": true, @@ -128,6 +146,7 @@ "binaryPlatforms": [ "windowsx86-64", "linuxx86-64", + "linuxarm64", "osxuniversal" ], "simMode": "swsim" @@ -135,7 +154,7 @@ { "groupId": "com.ctre.phoenix.sim", "artifactId": "cci-sim", - "version": "5.33.1", + "version": "5.34.0-beta-3", "libName": "CTRE_PhoenixCCISim", "headerClassifier": "headers", "sharedLibrary": true, @@ -143,6 +162,7 @@ "binaryPlatforms": [ "windowsx86-64", "linuxx86-64", + "linuxarm64", "osxuniversal" ], "simMode": "swsim"