Skip to content

Commit

Permalink
Alliance transform utils. Still definitely a WIP. Only quarter done
Browse files Browse the repository at this point in the history
  • Loading branch information
1736student committed Jan 13, 2024
1 parent 55b8edd commit e397cb1
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions utils/allianceTransformUtils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import wpilib
from wpilib import DriverStation
from hal import AllianceStationID

from wpimath.geometry import Pose2d, Rotation2d, Transform2d, Translation2d
from wpimath.geometry import Pose2d, Rotation2d, Transform2d, Translation2d
from wpimath.geometry import Pose2d, Rotation2d, Transform2d, Translation2d
from wpimath.geometry import Pose2d, Rotation2d, Transform2d, Translation2d
from wpimath.geometry import Pose2d, Rotation2d, Transform2d, Translation2d

"""
Utilities to help transform from blue alliance to red if needed
We went rogue and chose a coordinate system where the origin is always in the
bottom left on the blue alliance
"""
class AllianceTransformUtils:
@staticmethod
def transformX(in):
if DriverStation.getAlliance() == AllianceStationID.Red:
return Constants.FIELD_LENGTH_M - in
else:
return in

def transformY(in):
return in

0 comments on commit e397cb1

Please sign in to comment.