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;
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;
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;
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){
}
}
- public ShootingTarget getZone(Translation2d drivepose) {
+ public FieldZone getZone(Translation2d drivepose) {
return FieldConstants.getZone(drivepose);
}
}
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 {
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);
}
}
- 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;
}
}