From 8429c4a9b1041571de6521dda0bb39024ac9d779 Mon Sep 17 00:00:00 2001 From: Pix_XL <82770059+PIXLwastaken@users.noreply.github.com> Date: Thu, 3 Apr 2025 15:13:13 -0400 Subject: [PATCH] fix red alliiance inversion? --- src/main/java/frc/robot/RobotContainer.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 26ab3fb..cae803d 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -2,6 +2,8 @@ import com.ctre.phoenix6.swerve.SwerveRequest; +import edu.wpi.first.wpilibj.DriverStation; +import edu.wpi.first.wpilibj.DriverStation.Alliance; import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard; import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab; import edu.wpi.first.wpilibj.smartdashboard.SendableChooser; @@ -80,17 +82,30 @@ public Command getAutonomousCommand() { public void setDefaultCommands() { final var driver = DriverXbox.getInstance(); final var operator = OperatorXbox.getInstance(); + final var currAlliance = DriverStation.getAlliance().get(); CommandSwerveDrivetrain.getInstance().setDefaultCommand( CommandSwerveDrivetrain.getInstance().applyRequest(() -> { + if (currAlliance == Alliance.Blue){ if (modeFast) { return drive.withVelocityX(driver.getDriveTranslation().getX() * kMaxVelocity) // Drive forward with negative Y (forward) .withVelocityY(driver.getDriveTranslation().getY() * kMaxVelocity) // Drive left with negative X (left) .withRotationalRate(driver.getDriveRotation() * kMaxAngularVelocity); // Drive counterclockwise with negative X (left) - } else { + } else { return drive.withVelocityX(driver.getDriveTranslation().getX() * kMaxVelocity * 0.3) // Drive forward with negative Y (forward) .withVelocityY(driver.getDriveTranslation().getY() * kMaxVelocity * 0.3) // Drive left with negative X (left) .withRotationalRate(driver.getDriveRotation() * kMaxAngularVelocity * 0.3); // Drive counterclockwise with negative X (left) + } + } else { + if (modeFast) { + return drive.withVelocityX(-driver.getDriveTranslation().getX() * kMaxVelocity) // Drive forward with negative Y (forward) + .withVelocityY(-driver.getDriveTranslation().getY() * kMaxVelocity) // Drive left with negative X (left) + .withRotationalRate(driver.getDriveRotation() * kMaxAngularVelocity); // Drive counterclockwise with negative X (left) + } else { + return drive.withVelocityX(-driver.getDriveTranslation().getX() * kMaxVelocity * 0.3) // Drive forward with negative Y (forward) + .withVelocityY(-driver.getDriveTranslation().getY() * kMaxVelocity * 0.3) // Drive left with negative X (left) + .withRotationalRate(driver.getDriveRotation() * kMaxAngularVelocity * 0.3); // Drive counterclockwise with negative X (left) + } } }) );