utils.odometry_logic_2026
1import wpilib 2from wpimath.geometry import Pose2d 3from constants.field_target_constants_2026 import FieldTargets2026 4from typing import Callable 5 6 7def determineShooterTargets2026(odometry: Callable[[],Pose2d], alliance: wpilib.DriverStation.Alliance): 8 """ 9 Using the odometer and the robot's alliance, determine where on the field the shooter 10 should target. 11 12 Args: 13 odometry: polled current location and orientation of the robot on the field 14 alliance: red or blue 15 16 Returns: 17 target: the field location the shooter should target 18 """ 19 odometryTranslation = odometry().translation() 20 if alliance == wpilib.DriverStation.Alliance.kRed: 21 if odometryTranslation.X() > FieldTargets2026.redHubTarget[0]: 22 target = FieldTargets2026.redHubTarget 23 elif odometryTranslation.Y() < FieldTargets2026.redHubTarget[1]: 24 target = FieldTargets2026.bottomRightTarget 25 else: 26 target = FieldTargets2026.topRightTarget 27 else: 28 if odometryTranslation.X() < FieldTargets2026.blueHubTarget[0]: 29 target = FieldTargets2026.blueHubTarget 30 elif odometryTranslation.Y() < FieldTargets2026.blueHubTarget[1]: 31 target = FieldTargets2026.bottomLeftTarget 32 else: 33 target = FieldTargets2026.topLeftTarget 34 return target
def
determineShooterTargets2026( odometry: Callable[[], wpimath.geometry._geometry.Pose2d], alliance: wpilib._wpilib.DriverStation.Alliance):
8def determineShooterTargets2026(odometry: Callable[[],Pose2d], alliance: wpilib.DriverStation.Alliance): 9 """ 10 Using the odometer and the robot's alliance, determine where on the field the shooter 11 should target. 12 13 Args: 14 odometry: polled current location and orientation of the robot on the field 15 alliance: red or blue 16 17 Returns: 18 target: the field location the shooter should target 19 """ 20 odometryTranslation = odometry().translation() 21 if alliance == wpilib.DriverStation.Alliance.kRed: 22 if odometryTranslation.X() > FieldTargets2026.redHubTarget[0]: 23 target = FieldTargets2026.redHubTarget 24 elif odometryTranslation.Y() < FieldTargets2026.redHubTarget[1]: 25 target = FieldTargets2026.bottomRightTarget 26 else: 27 target = FieldTargets2026.topRightTarget 28 else: 29 if odometryTranslation.X() < FieldTargets2026.blueHubTarget[0]: 30 target = FieldTargets2026.blueHubTarget 31 elif odometryTranslation.Y() < FieldTargets2026.blueHubTarget[1]: 32 target = FieldTargets2026.bottomLeftTarget 33 else: 34 target = FieldTargets2026.topLeftTarget 35 return target
Using the odometer and the robot's alliance, determine where on the field the shooter should target.
Args: odometry: polled current location and orientation of the robot on the field alliance: red or blue
Returns: target: the field location the shooter should target