]> git.taranathan.com Git - FRC2026.git/commitdiff
Fixed and modified
authorWesley28w <wesleycwong@gmail.com>
Wed, 28 Jan 2026 16:42:25 +0000 (08:42 -0800)
committerWesley28w <wesleycwong@gmail.com>
Wed, 28 Jan 2026 16:42:25 +0000 (08:42 -0800)
src/main/java/frc/robot/commands/gpm/TurretAutoShoot.java
src/main/java/frc/robot/constants/FieldConstants.java
src/main/java/frc/robot/util/FieldZone.java [new file with mode: 0644]

index 5098aaacba83d9abc22f257e9e8981ddb884cf8e..ff78d0973c6f8a1466251ed7a7e69c003257b77d 100644 (file)
@@ -13,6 +13,7 @@ import frc.robot.Robot;
 import frc.robot.constants.FieldConstants;
 import frc.robot.subsystems.drivetrain.Drivetrain;
 import frc.robot.subsystems.turret.Turret;
+import frc.robot.util.FieldZone;
 import frc.robot.util.ShootingTarget;
 import frc.robot.util.Vision.TurretVision;
 
@@ -30,7 +31,7 @@ public class TurretAutoShoot extends Command {
     private boolean turretVisionEnabled = false;
     private boolean SOTM = true;
     private Translation2d drivepose = drivetrain.getPose().getTranslation();
-    public TurretAutoShoot(Turret turret, Drivetrain drivetrain, TurretVision turretVision){
+    public TurretAutoShoot(Turret turret, Drivetrain drivetrain, TurretVision turretVision) {
         this.turret = turret;
         this.drivetrain = drivetrain;
         this.turretVision = turretVision;
@@ -38,24 +39,26 @@ public class TurretAutoShoot extends Command {
         addRequirements(turret);
     }
 
-    public TurretAutoShoot(Turret turret, Drivetrain drivetrain){
+    public TurretAutoShoot(Turret turret, Drivetrain drivetrain) {
         this(turret, drivetrain, null);
     }
 
     public void updateTurretSetpoint(Translation2d drivepose) {
-        ShootingTarget shootingTarget = getZone(drivepose);
+        
+        FieldZone currentZone = getZone(drivepose);
         Translation2d target;
-        switch (shootingTarget) {
-            case HUB: 
-                target = FieldConstants.getHubTranslation().toTranslation2d();
+        switch (currentZone) {
             case NEUTRAL:
-                target = FieldConstants.getNeutralTranslation(leftSide(drivepose)).toTranslation2d();
-            case ALLIANCE:
                 target = FieldConstants.getAllianceTranslation(leftSide(drivepose)).toTranslation2d();
             case OPPOSITION:
-                target = FieldConstants.getOppositionTranslation(leftSide(drivepose)).toTranslation2d();
+                target = FieldConstants.getAllianceTranslation(leftSide(drivepose)).toTranslation2d();
+            case ALLIANCE:
+                target = FieldConstants.getAllianceTranslation(leftSide(drivepose)).toTranslation2d(); // For the shooter we will want to check if active but turret should be fine
             default:
                 target = FieldConstants.getHubTranslation().toTranslation2d();
+            
+            // I also made this for if we want to shoot to the opposing teams area (though we would never haha):
+            // target = FieldConstants.getOppositionTranslation(leftSide(drivepose)).toTranslation2d();
         }
 
         double D_y;
@@ -89,7 +92,7 @@ public class TurretAutoShoot extends Command {
         System.out.println("Aligning the turn to degree angle: " + turretSetpoint);
     }
 
-    public void adjustWithTurretCam(){
+    public void adjustWithTurretCam() {
         if(turretVision.canSeeTag(26) || turretVision.canSeeTag(10)){
             // Adjust turret setpoint based on vision input
             if(Robot.getAlliance() == Alliance.Blue){
@@ -146,7 +149,7 @@ public class TurretAutoShoot extends Command {
         }
     }
 
-    public ShootingTarget getZone(Translation2d drivepose) {
+    public FieldZone getZone(Translation2d drivepose) {
         return FieldConstants.getZone(drivepose);
     }
 }
index d4ed8103da2e2c52fedfe5c25d3d5b4301291484..5ec836d2a33e28c157b4d02c04a2465850dfc007 100644 (file)
@@ -12,6 +12,7 @@ import edu.wpi.first.math.util.Units;
 import edu.wpi.first.wpilibj.DriverStation.Alliance;
 import edu.wpi.first.wpilibj2.command.InstantCommand;
 import frc.robot.Robot;
+import frc.robot.util.FieldZone;
 import frc.robot.util.ShootingTarget;
 
 public class FieldConstants {
@@ -36,7 +37,7 @@ public class FieldConstants {
     new Translation3d(field.getFieldLength()*0.5, field.getFieldWidth() - NEUTRAL_LEFT.getX(), 0);
 
   public static final Translation3d ALLIANCE_LEFT_BLUE =
-    new Translation3d(156.8+20+50, field.getFieldWidth()*0.25, 0); // previous hub + a few feet
+    new Translation3d(156.8+20+50, field.getFieldWidth()*0.25, 0); // previous hub + a few feet further back
 
   public static final Translation3d ALLIANCE_RIGHT_BLUE =
     new Translation3d(158.8+20+50, field.getFieldWidth() - ALLIANCE_LEFT_BLUE.getX(), 0);
@@ -88,23 +89,23 @@ public class FieldConstants {
     }
   }
 
-  public static ShootingTarget getZone(Translation2d drivepose) {
+  public static FieldZone getZone(Translation2d drivepose) {
     double x = drivepose.getX();
     double y = drivepose.getY();
     if(x < FieldConstants.RedAllianceLine) { // inside red
       if (Robot.getAlliance() == Alliance.Red) {
-        return ShootingTarget.ALLIANCE;
+        return FieldZone.ALLIANCE;
       } else {
-        return ShootingTarget.OPPOSITION;
+        return FieldZone.OPPOSITION;
       }
     } else if (x > FieldConstants.BlueAllianceLine) {
       if (Robot.getAlliance() == Alliance.Blue) {
-        return ShootingTarget.ALLIANCE;
+        return FieldZone.ALLIANCE;
       } else {
-        return ShootingTarget.OPPOSITION;
+        return FieldZone.OPPOSITION;
       }
     } else {
-      return ShootingTarget.NEUTRAL;
+      return FieldZone.NEUTRAL;
     }
   }
 
diff --git a/src/main/java/frc/robot/util/FieldZone.java b/src/main/java/frc/robot/util/FieldZone.java
new file mode 100644 (file)
index 0000000..605144c
--- /dev/null
@@ -0,0 +1,7 @@
+package frc.robot.util;
+
+public enum FieldZone {
+    ALLIANCE,
+    NEUTRAL,
+    OPPOSITION
+}