From 02364b04b6af5b57f6119ce8d5d6704ba3f2fcf1 Mon Sep 17 00:00:00 2001 From: Surya Thoppae <63197592+suryatho@users.noreply.github.com> Date: Sun, 18 Feb 2024 13:44:34 -0500 Subject: [PATCH] Set module configs constants for compbot (#27) --- .../littletonrobotics/frc2024/Constants.java | 2 +- .../frc2024/RobotContainer.java | 8 +++- .../subsystems/drive/DriveConstants.java | 20 +++++--- .../subsystems/drive/GyroIOPigeon2.java | 12 +++-- .../frc2024/subsystems/drive/Module.java | 2 +- .../subsystems/drive/ModuleIOKrakenFOC.java | 23 +++++---- .../flywheels/FlywheelConstants.java | 4 +- vendordeps/Phoenix6.json | 48 +++++++++---------- vendordeps/REVLib.json | 10 ++-- 9 files changed, 76 insertions(+), 53 deletions(-) diff --git a/src/main/java/org/littletonrobotics/frc2024/Constants.java b/src/main/java/org/littletonrobotics/frc2024/Constants.java index e6f05ebb..d054eed9 100644 --- a/src/main/java/org/littletonrobotics/frc2024/Constants.java +++ b/src/main/java/org/littletonrobotics/frc2024/Constants.java @@ -21,7 +21,7 @@ */ public final class Constants { public static final double loopPeriodSecs = 0.02; - private static RobotType robotType = RobotType.DEVBOT; + private static RobotType robotType = RobotType.COMPBOT; public static final boolean tuningMode = true; public static RobotType getRobot() { diff --git a/src/main/java/org/littletonrobotics/frc2024/RobotContainer.java b/src/main/java/org/littletonrobotics/frc2024/RobotContainer.java index 78450fea..0bd2df62 100644 --- a/src/main/java/org/littletonrobotics/frc2024/RobotContainer.java +++ b/src/main/java/org/littletonrobotics/frc2024/RobotContainer.java @@ -88,7 +88,13 @@ public RobotContainer() { if (Constants.getMode() != Constants.Mode.REPLAY) { switch (Constants.getRobot()) { case COMPBOT -> { - // No impl yet + drive = + new Drive( + new GyroIOPigeon2(true), + new ModuleIOKrakenFOC(DriveConstants.moduleConfigs[0]), + new ModuleIOKrakenFOC(DriveConstants.moduleConfigs[1]), + new ModuleIOKrakenFOC(DriveConstants.moduleConfigs[2]), + new ModuleIOKrakenFOC(DriveConstants.moduleConfigs[3])); } case DEVBOT -> { drive = diff --git a/src/main/java/org/littletonrobotics/frc2024/subsystems/drive/DriveConstants.java b/src/main/java/org/littletonrobotics/frc2024/subsystems/drive/DriveConstants.java index 27ed86d7..54566697 100644 --- a/src/main/java/org/littletonrobotics/frc2024/subsystems/drive/DriveConstants.java +++ b/src/main/java/org/littletonrobotics/frc2024/subsystems/drive/DriveConstants.java @@ -67,7 +67,14 @@ public final class DriveConstants { // Module Constants public static ModuleConfig[] moduleConfigs = switch (Constants.getRobot()) { - case COMPBOT, DEVBOT -> + case COMPBOT -> + new ModuleConfig[] { + new ModuleConfig(16, 12, 0, new Rotation2d(-1.93585), true), + new ModuleConfig(19, 14, 1, new Rotation2d(0.73053), true), + new ModuleConfig(17, 13, 2, new Rotation2d(-0.50507), true), + new ModuleConfig(18, 15, 3, new Rotation2d(-1.51666), true) + }; + case DEVBOT -> new ModuleConfig[] { new ModuleConfig(15, 11, 0, new Rotation2d(-0.036), true), new ModuleConfig(12, 9, 1, new Rotation2d(1.0185), true), @@ -86,12 +93,12 @@ public final class DriveConstants { switch (Constants.getRobot()) { case COMPBOT -> new ModuleConstants( - 2.0, 0.0, - 200.0, 0.0, - 200.0, - 20.0, + 0.0, + 0.0, + 0.0, + 0.0, Mk4iReductions.L3.reduction, Mk4iReductions.TURN.reduction); case DEVBOT -> @@ -125,7 +132,8 @@ public final class DriveConstants { // Trajectory Following public static TrajectoryConstants trajectoryConstants = switch (Constants.getRobot()) { - case COMPBOT, DEVBOT -> + case COMPBOT -> new TrajectoryConstants(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); + case DEVBOT -> new TrajectoryConstants( 6.0, 0.0, diff --git a/src/main/java/org/littletonrobotics/frc2024/subsystems/drive/GyroIOPigeon2.java b/src/main/java/org/littletonrobotics/frc2024/subsystems/drive/GyroIOPigeon2.java index 57c8423a..e091a9be 100644 --- a/src/main/java/org/littletonrobotics/frc2024/subsystems/drive/GyroIOPigeon2.java +++ b/src/main/java/org/littletonrobotics/frc2024/subsystems/drive/GyroIOPigeon2.java @@ -18,12 +18,18 @@ /** IO implementation for Pigeon2 */ public class GyroIOPigeon2 implements GyroIO { - private final Pigeon2 pigeon = new Pigeon2(0); - private final StatusSignal yaw = pigeon.getYaw(); + private static final int id = 0; + + private final Pigeon2 pigeon; + private final StatusSignal yaw; private final Queue yawPositionQueue; - private final StatusSignal yawVelocity = pigeon.getAngularVelocityZWorld(); + private final StatusSignal yawVelocity; public GyroIOPigeon2(boolean phoenixDrive) { + pigeon = new Pigeon2(id, "canivore"); + yaw = pigeon.getYaw(); + yawVelocity = pigeon.getAngularVelocityZWorld(); + pigeon.getConfigurator().apply(new Pigeon2Configuration()); pigeon.getConfigurator().setYaw(0.0); yaw.setUpdateFrequency(DriveConstants.odometryFrequency); diff --git a/src/main/java/org/littletonrobotics/frc2024/subsystems/drive/Module.java b/src/main/java/org/littletonrobotics/frc2024/subsystems/drive/Module.java index b41e9d40..7edb7a4b 100644 --- a/src/main/java/org/littletonrobotics/frc2024/subsystems/drive/Module.java +++ b/src/main/java/org/littletonrobotics/frc2024/subsystems/drive/Module.java @@ -60,7 +60,7 @@ public Module(ModuleIO io, int index) { /** Called while blocking odometry thread */ public void updateInputs() { io.updateInputs(inputs); - Logger.processInputs("Drive/" + moduleNames[index] + "_Module", inputs); + Logger.processInputs("Drive/Module" + index, inputs); // Update ff and controllers LoggedTunableNumber.ifChanged( diff --git a/src/main/java/org/littletonrobotics/frc2024/subsystems/drive/ModuleIOKrakenFOC.java b/src/main/java/org/littletonrobotics/frc2024/subsystems/drive/ModuleIOKrakenFOC.java index 32742835..7b2fc102 100644 --- a/src/main/java/org/littletonrobotics/frc2024/subsystems/drive/ModuleIOKrakenFOC.java +++ b/src/main/java/org/littletonrobotics/frc2024/subsystems/drive/ModuleIOKrakenFOC.java @@ -104,6 +104,15 @@ public ModuleIOKrakenFOC(ModuleConfig config) { if (!error) break; } + // 250hz signals + drivePosition = driveTalon.getPosition(); + turnPosition = turnTalon.getPosition(); + BaseStatusSignal.setUpdateFrequencyForAll(odometryFrequency, drivePosition, turnPosition); + + drivePositionQueue = + PhoenixOdometryThread.getInstance().registerSignal(driveTalon, drivePosition); + turnPositionQueue = PhoenixOdometryThread.getInstance().registerSignal(turnTalon, turnPosition); + // Get signals and set update rate // 100hz signals driveVelocity = driveTalon.getVelocity(); @@ -133,17 +142,11 @@ public ModuleIOKrakenFOC(ModuleConfig config) { turnSupplyCurrent, turnTorqueCurrent); - // 250hz signals - drivePosition = driveTalon.getPosition(); - turnPosition = turnTalon.getPosition(); - BaseStatusSignal.setUpdateFrequencyForAll(odometryFrequency, drivePosition, turnPosition); - drivePositionQueue = - PhoenixOdometryThread.getInstance().registerSignal(driveTalon, driveTalon.getPosition()); - turnPositionQueue = - PhoenixOdometryThread.getInstance().registerSignal(turnTalon, turnTalon.getPosition()); - // Reset turn position to absolute encoder position - turnTalon.setPosition(turnAbsolutePosition.get().getRotations()); + turnTalon.setPosition(turnAbsolutePosition.get().getRotations(), 1.0); + + driveTalon.optimizeBusUtilization(1.0); + turnTalon.optimizeBusUtilization(1.0); } @Override diff --git a/src/main/java/org/littletonrobotics/frc2024/subsystems/flywheels/FlywheelConstants.java b/src/main/java/org/littletonrobotics/frc2024/subsystems/flywheels/FlywheelConstants.java index f08f990e..4d615d14 100644 --- a/src/main/java/org/littletonrobotics/frc2024/subsystems/flywheels/FlywheelConstants.java +++ b/src/main/java/org/littletonrobotics/frc2024/subsystems/flywheels/FlywheelConstants.java @@ -12,14 +12,14 @@ public class FlywheelConstants { public static FlywheelConfig flywheelConfig = switch (Constants.getRobot()) { - case COMPBOT -> null; + case COMPBOT -> new FlywheelConfig(0, 0, 0, 0, 0); case DEVBOT -> new FlywheelConfig(5, 4, (1.0 / 2.0), 6000.0, 100.0); case SIMBOT -> new FlywheelConfig(0, 0, (1.0 / 2.0), 6000.0, 50.0); }; public static Gains gains = switch (Constants.getRobot()) { - case COMPBOT -> null; + case COMPBOT -> new Gains(0, 0, 0, 0, 0, 0); case DEVBOT -> new Gains(0.0006, 0.0, 0.05, 0.33329, 0.00083, 0.0); case SIMBOT -> new Gains(0.05, 0.0, 0.0, 0.01, 0.00103, 0.0); }; diff --git a/vendordeps/Phoenix6.json b/vendordeps/Phoenix6.json index 42d1c3e4..e9113c8d 100644 --- a/vendordeps/Phoenix6.json +++ b/vendordeps/Phoenix6.json @@ -1,7 +1,7 @@ { "fileName": "Phoenix6.json", "name": "CTRE-Phoenix (v6)", - "version": "24.1.0", + "version": "24.2.0", "frcYear": 2024, "uuid": "e995de00-2c64-4df5-8831-c1441420ff19", "mavenUrls": [ @@ -19,14 +19,14 @@ { "groupId": "com.ctre.phoenix6", "artifactId": "wpiapi-java", - "version": "24.1.0" + "version": "24.2.0" } ], "jniDependencies": [ { "groupId": "com.ctre.phoenix6", "artifactId": "tools", - "version": "24.1.0", + "version": "24.2.0", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ @@ -39,7 +39,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "tools-sim", - "version": "24.1.0", + "version": "24.2.0", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ @@ -52,7 +52,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simTalonSRX", - "version": "24.1.0", + "version": "24.2.0", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ @@ -65,7 +65,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simTalonFX", - "version": "24.1.0", + "version": "24.2.0", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ @@ -78,7 +78,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simVictorSPX", - "version": "24.1.0", + "version": "24.2.0", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ @@ -91,7 +91,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simPigeonIMU", - "version": "24.1.0", + "version": "24.2.0", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ @@ -104,7 +104,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simCANCoder", - "version": "24.1.0", + "version": "24.2.0", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ @@ -117,7 +117,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simProTalonFX", - "version": "24.1.0", + "version": "24.2.0", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ @@ -130,7 +130,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simProCANcoder", - "version": "24.1.0", + "version": "24.2.0", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ @@ -143,7 +143,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simProPigeon2", - "version": "24.1.0", + "version": "24.2.0", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ @@ -158,7 +158,7 @@ { "groupId": "com.ctre.phoenix6", "artifactId": "wpiapi-cpp", - "version": "24.1.0", + "version": "24.2.0", "libName": "CTRE_Phoenix6_WPI", "headerClassifier": "headers", "sharedLibrary": true, @@ -173,7 +173,7 @@ { "groupId": "com.ctre.phoenix6", "artifactId": "tools", - "version": "24.1.0", + "version": "24.2.0", "libName": "CTRE_PhoenixTools", "headerClassifier": "headers", "sharedLibrary": true, @@ -188,7 +188,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "wpiapi-cpp-sim", - "version": "24.1.0", + "version": "24.2.0", "libName": "CTRE_Phoenix6_WPISim", "headerClassifier": "headers", "sharedLibrary": true, @@ -203,7 +203,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "tools-sim", - "version": "24.1.0", + "version": "24.2.0", "libName": "CTRE_PhoenixTools_Sim", "headerClassifier": "headers", "sharedLibrary": true, @@ -218,7 +218,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simTalonSRX", - "version": "24.1.0", + "version": "24.2.0", "libName": "CTRE_SimTalonSRX", "headerClassifier": "headers", "sharedLibrary": true, @@ -233,7 +233,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simTalonFX", - "version": "24.1.0", + "version": "24.2.0", "libName": "CTRE_SimTalonFX", "headerClassifier": "headers", "sharedLibrary": true, @@ -248,7 +248,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simVictorSPX", - "version": "24.1.0", + "version": "24.2.0", "libName": "CTRE_SimVictorSPX", "headerClassifier": "headers", "sharedLibrary": true, @@ -263,7 +263,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simPigeonIMU", - "version": "24.1.0", + "version": "24.2.0", "libName": "CTRE_SimPigeonIMU", "headerClassifier": "headers", "sharedLibrary": true, @@ -278,7 +278,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simCANCoder", - "version": "24.1.0", + "version": "24.2.0", "libName": "CTRE_SimCANCoder", "headerClassifier": "headers", "sharedLibrary": true, @@ -293,7 +293,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simProTalonFX", - "version": "24.1.0", + "version": "24.2.0", "libName": "CTRE_SimProTalonFX", "headerClassifier": "headers", "sharedLibrary": true, @@ -308,7 +308,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simProCANcoder", - "version": "24.1.0", + "version": "24.2.0", "libName": "CTRE_SimProCANcoder", "headerClassifier": "headers", "sharedLibrary": true, @@ -323,7 +323,7 @@ { "groupId": "com.ctre.phoenix6.sim", "artifactId": "simProPigeon2", - "version": "24.1.0", + "version": "24.2.0", "libName": "CTRE_SimProPigeon2", "headerClassifier": "headers", "sharedLibrary": true, diff --git a/vendordeps/REVLib.json b/vendordeps/REVLib.json index 9e9b7c9b..6bb009ca 100644 --- a/vendordeps/REVLib.json +++ b/vendordeps/REVLib.json @@ -1,7 +1,7 @@ { "fileName": "REVLib.json", "name": "REVLib", - "version": "2024.2.0", + "version": "2024.2.1", "frcYear": "2024", "uuid": "3f48eb8c-50fe-43a6-9cb7-44c86353c4cb", "mavenUrls": [ @@ -12,14 +12,14 @@ { "groupId": "com.revrobotics.frc", "artifactId": "REVLib-java", - "version": "2024.2.0" + "version": "2024.2.1" } ], "jniDependencies": [ { "groupId": "com.revrobotics.frc", "artifactId": "REVLib-driver", - "version": "2024.2.0", + "version": "2024.2.1", "skipInvalidPlatforms": true, "isJar": false, "validPlatforms": [ @@ -37,7 +37,7 @@ { "groupId": "com.revrobotics.frc", "artifactId": "REVLib-cpp", - "version": "2024.2.0", + "version": "2024.2.1", "libName": "REVLib", "headerClassifier": "headers", "sharedLibrary": false, @@ -55,7 +55,7 @@ { "groupId": "com.revrobotics.frc", "artifactId": "REVLib-driver", - "version": "2024.2.0", + "version": "2024.2.1", "libName": "REVLibDriver", "headerClassifier": "headers", "sharedLibrary": false,