From a5131b809dfcd9835fcfb670590b1956bfe840ba Mon Sep 17 00:00:00 2001 From: maxwtan <100314265+MaxwellTTan20@users.noreply.github.com> Date: Fri, 13 Feb 2026 15:19:44 -0800 Subject: [PATCH] Update TurretAutoShoot.java --- .../robot/commands/gpm/TurretAutoShoot.java | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/main/java/frc/robot/commands/gpm/TurretAutoShoot.java b/src/main/java/frc/robot/commands/gpm/TurretAutoShoot.java index 07c06a4..8864ab5 100644 --- a/src/main/java/frc/robot/commands/gpm/TurretAutoShoot.java +++ b/src/main/java/frc/robot/commands/gpm/TurretAutoShoot.java @@ -9,6 +9,7 @@ import edu.wpi.first.math.geometry.Translation2d; import edu.wpi.first.math.geometry.Twist2d; import edu.wpi.first.math.kinematics.ChassisSpeeds; import edu.wpi.first.math.util.Units; +import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import edu.wpi.first.wpilibj2.command.Command; import frc.robot.constants.Constants; import frc.robot.constants.FieldConstants; @@ -35,7 +36,7 @@ public class TurretAutoShoot extends Command { public TurretAutoShoot(Turret turret, Drivetrain drivetrain) { this.turret = turret; this.drivetrain = drivetrain; - drivepose = drivetrain.getPose(); + drivepose = drivetrain.getPose().rotateBy(new Rotation2d(Math.PI)); addRequirements(turret); } @@ -64,19 +65,19 @@ public class TurretAutoShoot extends Command { // Account for imparted velocity by robot (turret) to offset double timeOfFlight; Pose2d lookaheadPose = turretPosition; - double lookaheadTurretToTargetDistance = turretToTargetDistance; + //double lookaheadTurretToTargetDistance = turretToTargetDistance; // Loop (20) until lookahreadTurretToTargetDistance converges - for (int i = 0; i < 20; i++) { - timeOfFlight = ShotInterpolation.timeOfFlightMap.get(lookaheadTurretToTargetDistance); + //for (int i = 0; i < 20; i++) { + timeOfFlight = 1.0; double offsetX = turretVelocityX * timeOfFlight; double offsetY = turretVelocityY * timeOfFlight; lookaheadPose = new Pose2d( turretPosition.getTranslation().plus(new Translation2d(offsetX, offsetY)), turretPosition.getRotation()); - lookaheadTurretToTargetDistance = target.getDistance(lookaheadPose.getTranslation()); - } + //lookaheadTurretToTargetDistance = target.getDistance(lookaheadPose.getTranslation()); + //} turretAngle = target.minus(lookaheadPose.getTranslation()).getAngle(); if (lastTurretAngle == null) { lastTurretAngle = turretAngle; @@ -100,18 +101,13 @@ public class TurretAutoShoot extends Command { robotRelVel.omegaRadiansPerSecond * phaseDelay)); } - @Override - public void initialize() { - updateDrivePose(); - updateTurretSetpoint(drivepose); - turret.setFieldRelativeTarget(new Rotation2d(Units.degreesToRadians(turretSetpoint)), turretVelocity - drivetrain.getAngularRate(2)); - } - @Override public void execute() { updateDrivePose(); updateTurretSetpoint(drivepose); - turret.setFieldRelativeTarget(new Rotation2d(Units.degreesToRadians(turretSetpoint)), turretVelocity - drivetrain.getAngularRate(2)); + //turret.setFieldRelativeTarget(new Rotation2d(Units.degreesToRadians(turretSetpoint)), turretVelocity - drivetrain.getAngularRate(2)); + System.out.println("Turret Setpoint: " + turretSetpoint); + //System.out.println("Turret goal velocity" + (turretVelocity - drivetrain.getAngularRate(2))); } @Override -- 2.39.5