From 93d8e755623fb84bc9bc9e17f875c7bea0dcdaa6 Mon Sep 17 00:00:00 2001 From: maxwtan <100314265+MaxwellTTan20@users.noreply.github.com> Date: Fri, 20 Feb 2026 14:06:19 -0800 Subject: [PATCH] a --- .../java/frc/robot/subsystems/turret/Turret.java | 16 +++++++--------- .../robot/subsystems/turret/TurretConstants.java | 2 +- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/main/java/frc/robot/subsystems/turret/Turret.java b/src/main/java/frc/robot/subsystems/turret/Turret.java index 013f91b..1647999 100644 --- a/src/main/java/frc/robot/subsystems/turret/Turret.java +++ b/src/main/java/frc/robot/subsystems/turret/Turret.java @@ -145,28 +145,26 @@ public class Turret extends SubsystemBase implements TurretIO{ int leftTooth = (int) Math.round(leftAbs * TurretConstants.LEFT_ENCODER_TEETH) % TurretConstants.LEFT_ENCODER_TEETH; - SmartDashboard.putNumber("Left Tooth", leftTooth); + //SmartDashboard.putNumber("Left Tooth", leftTooth); int rightTooth = (int) Math.round(rightAbs * TurretConstants.RIGHT_ENCODER_TEETH) % TurretConstants.RIGHT_ENCODER_TEETH; - SmartDashboard.putNumber("Right Tooth", rightTooth); + //SmartDashboard.putNumber("Right Tooth", rightTooth); int turretIndex = ChineseRemainderTheorem.solve(leftTooth, TurretConstants.LEFT_ENCODER_TEETH, rightTooth, TurretConstants.RIGHT_ENCODER_TEETH); - SmartDashboard.putNumber("Turret Index", turretIndex); + //SmartDashboard.putNumber("Turret Index", turretIndex); - double totalTeeth = TurretConstants.LEFT_ENCODER_TEETH - * TurretConstants.RIGHT_ENCODER_TEETH; - - double turretRotations = turretIndex / (double) 140.0; + double turretRotations = turretIndex / (double) TurretConstants.TURRET_TEETH_COUNT; if(Units.rotationsToDegrees(turretRotations) > 500.0){ turretRotations -= Units.degreesToRotations(846.0); } - SmartDashboard.putNumber("CRT thing out", Units.rotationsToDegrees(turretRotations)); + SmartDashboard.putNumber("CRT Position", Units.rotationsToDegrees(turretRotations)); double motorRotations = turretRotations * TurretConstants.TURRET_GEAR_RATIO; + + //Sets the initial motor position motor.setPosition(motorRotations); - // Position extrapolation double lookAheadSeconds = EXTRAPOLATION_TIME_CONSTANT; double futureRobotAngle = goalAngle.getRadians() + (goalVelocityRadPerSec * lookAheadSeconds); diff --git a/src/main/java/frc/robot/subsystems/turret/TurretConstants.java b/src/main/java/frc/robot/subsystems/turret/TurretConstants.java index 8710b6b..e56cfec 100644 --- a/src/main/java/frc/robot/subsystems/turret/TurretConstants.java +++ b/src/main/java/frc/robot/subsystems/turret/TurretConstants.java @@ -14,7 +14,7 @@ public class TurretConstants { public static double TURRET_RADIUS = TURRET_WIDTH / 2; public static double TURRET_TEETH_COUNT = 140.0; // the turret teeth count - public static double TURRET_GEAR_RATIO = 30.545454; + public static double TURRET_GEAR_RATIO = 25.454545454; public static int LEFT_ENCODER_TEETH = 15; // gear teeth public static int RIGHT_ENCODER_TEETH = 22; // read above public static int ENCODER_COUNT_TOTAL = 8192; // how many intervals it can have, like clicks on a clock chat gpt explained to me -- 2.39.5