44import edu .wpi .first .math .geometry .Pose2d ;
55import edu .wpi .first .math .geometry .Rotation2d ;
66import edu .wpi .first .math .geometry .Translation2d ;
7- import edu .wpi .first .wpilibj .DriverStation ;
8- import edu .wpi .first .wpilibj .DriverStation .Alliance ;
97import edu .wpi .first .wpilibj2 .command .Command ;
108import frc .robot .FieldConstants .CoralStation ;
119import frc .robot .FieldConstants .Reef ;
@@ -20,7 +18,7 @@ public static Command alignToCage(Drive drivetrain, JoystickInputController inpu
2018 return DriveCommands .joystickHeadingDrive (
2119 drivetrain ,
2220 input ::getTranslationMetersPerSecond ,
23- () -> Optional .of (isBlue () ? Rotation2d .k180deg : Rotation2d . kZero ),
21+ () -> Optional .of (AllianceFlipUtil . apply ( Rotation2d .kZero ) ),
2422 () -> SpeedLevel .NO_LEVEL ,
2523 () -> true );
2624 }
@@ -29,7 +27,7 @@ public static Command alignToSourceLeft(Drive drivetrain, JoystickInputControlle
2927 return DriveCommands .joystickHeadingDrive (
3028 drivetrain ,
3129 input ::getTranslationMetersPerSecond ,
32- () -> Optional .of (CoralStation .leftCenterFace .getRotation (). minus ( allianceRotation ())),
30+ () -> Optional .of (AllianceFlipUtil . apply ( CoralStation .leftCenterFace .getRotation ())),
3331 () -> SpeedLevel .NO_LEVEL ,
3432 () -> true );
3533 }
@@ -38,7 +36,7 @@ public static Command alignToSourceRight(Drive drivetrain, JoystickInputControll
3836 return DriveCommands .joystickHeadingDrive (
3937 drivetrain ,
4038 input ::getTranslationMetersPerSecond ,
41- () -> Optional .of (CoralStation .rightCenterFace .getRotation (). minus ( allianceRotation ())),
39+ () -> Optional .of (AllianceFlipUtil . apply ( CoralStation .rightCenterFace .getRotation ())),
4240 () -> SpeedLevel .NO_LEVEL ,
4341 () -> true );
4442 }
@@ -69,13 +67,4 @@ public static Command alignToReef(Drive drivetrain, JoystickInputController inpu
6967 () -> SpeedLevel .NO_LEVEL ,
7068 () -> true );
7169 }
72-
73- private static Rotation2d allianceRotation () {
74- return Rotation2d .fromDegrees (isBlue () ? 0 : 180 );
75- }
76-
77- private static boolean isBlue () {
78- return DriverStation .getAlliance ().isPresent ()
79- && DriverStation .getAlliance ().get () == Alliance .Blue ;
80- }
8170}
0 commit comments