From: Wesley28w Date: Wed, 28 Jan 2026 16:42:25 +0000 (-0800) Subject: Fixed and modified X-Git-Url: https://git.taranathan.com/?a=commitdiff_plain;h=cbcff026ae683ae41ca334b8df5255ff05dc1f51;p=FRC2026.git Fixed and modified --- diff --git a/src/main/java/frc/robot/commands/gpm/TurretAutoShoot.java b/src/main/java/frc/robot/commands/gpm/TurretAutoShoot.java index 5098aaa..ff78d09 100644 --- a/src/main/java/frc/robot/commands/gpm/TurretAutoShoot.java +++ b/src/main/java/frc/robot/commands/gpm/TurretAutoShoot.java @@ -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); } } diff --git a/src/main/java/frc/robot/constants/FieldConstants.java b/src/main/java/frc/robot/constants/FieldConstants.java index d4ed810..5ec836d 100644 --- a/src/main/java/frc/robot/constants/FieldConstants.java +++ b/src/main/java/frc/robot/constants/FieldConstants.java @@ -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 index 0000000..605144c --- /dev/null +++ b/src/main/java/frc/robot/util/FieldZone.java @@ -0,0 +1,7 @@ +package frc.robot.util; + +public enum FieldZone { + ALLIANCE, + NEUTRAL, + OPPOSITION +}