From 8740431940b1b5cf0e4974fea4aa7f1e5e1e384c Mon Sep 17 00:00:00 2001 From: Tylr-J42 Date: Mon, 9 Oct 2023 22:25:00 -0400 Subject: [PATCH] math for triangulating robot coords --- FRC_Fiducial_Tracking/Pose_Estimation.py | 13 ++++++++++--- .../__pycache__/Pose_Estimation.cpython-39.pyc | Bin 0 -> 3189 bytes 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 FRC_Fiducial_Tracking/__pycache__/Pose_Estimation.cpython-39.pyc diff --git a/FRC_Fiducial_Tracking/Pose_Estimation.py b/FRC_Fiducial_Tracking/Pose_Estimation.py index 13d73fe..d0d391d 100644 --- a/FRC_Fiducial_Tracking/Pose_Estimation.py +++ b/FRC_Fiducial_Tracking/Pose_Estimation.py @@ -36,17 +36,24 @@ class PoseEstimation: tag0Tvec = cam_pose_to_robot_tvec(self.data_array[0], self.robo_space_pose) tag1Tvec = cam_pose_to_robot_tvec(self.data_array[1], self.robo_space_pose) - tag0Coords = [self.tag_coords[self.data_array[0].tag_id][0], self.tag_coords[self.data_array[0].tag_id][2], self.tag_coords[self.data_array[0].tag_id][3]] - tag1Coords = [self.tag_coords[self.data_array[1].tag_id][0], self.tag_coords[self.data_array[1].tag_id][2], self.tag_coords[self.data_array[1].tag_id][3]] + tag0Coords = [self.tag_coords[self.data_array[0].tag_id][1], self.tag_coords[self.data_array[0].tag_id][2], self.tag_coords[self.data_array[0].tag_id][3]] + tag1Coords = [self.tag_coords[self.data_array[1].tag_id][1], self.tag_coords[self.data_array[1].tag_id][2], self.tag_coords[self.data_array[1].tag_id][3]] tag_line_dist = distance(tag0Coords[0], tag0Coords[1], tag1Coords[0], tag1Coords[1]) tag0_cam_dist = math.hypot(tag0Tvec[0], tag0Tvec[2]) tag1_cam_dist = math.hypot(tag1Tvec[0], tag1Tvec[2]) - cam_angle = math.toDegrees(math.atan(tag0Tvec[0]/tag0Tvec[2])-math.atan(tag1Tvec[0]/tag1Tvec[2])) + tag_line_angle = slope_angle(tag0Coords[0], tag0Coords[1], tag1Coords[0], tag1Coords[1]) + + cam_angle = math.abs(math.toDegrees(math.atan(tag0Tvec[0]/tag0Tvec[2])-math.atan(tag1Tvec[0]/tag1Tvec[2]))) tag0_angle = math.acos(((tag0_cam_dist**2) + (tag_line_dist**2) - (tag1_cam_dist**2)) / (2 * tag0_cam_dist * tag_line_dist)) tag1_angle = 180-(cam_angle+tag0_angle) + robotXCoord = (math.toDegrees(math.cos(tag_line_angle + tag0_angle))*tag0_cam_dist) + tag0Coords[0] + self.robo_space_pose[0] + robotYCoord = (math.toDegrees(math.sin(tag_line_angle + tag0_angle))*tag0_cam_dist) + tag0Coords[1] + self.robo_space_pose[1] + + coord_array = [robotXCoord, robotYCoord] + tvecZCoord = math.hypot(tag0Tvec[0], tag0Tvec[1]) return coord_array diff --git a/FRC_Fiducial_Tracking/__pycache__/Pose_Estimation.cpython-39.pyc b/FRC_Fiducial_Tracking/__pycache__/Pose_Estimation.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..7b513f0d4000549fb82fd7e18a0dda8fd3ea6561 GIT binary patch literal 3189 zcmbVOOK;mo5Z+x<6!r8=j^!js4^7c9ZQ=(|AO(uRfYbC)zzve1XowaBtz~4|vZyTS z)G{cbK=K28?xl85&Aq>(KY`bteCoZYezTNhNiN!=5_UK{JNxbI%{Z5_9pMlO6TKpJ9GRZs4rLXAlL+*0UzF^Xj=36GsH^LRNAg#B|HDpoR_?ogL z%lH;#MON{(B!9-7+6A!Kj>9wSx!?Y3cfUpb$)7-H3oX745-^ub25c?`FpPXXVCQQU zWD%HlR(}%3!RK)j9{Ncbbz5Zl=tn$ZZlh_;l&8#NsQ~3|?CNLgi!odQ zM-wOJy<>`k@#ps1UUV3&^};p3r@{`Fx<|10UaHpG)z$w@Avwd?RjB0Ogzt`J=-9RTlkmx$;z~+?vFHEHheIzcz9z7FGXw-b0UG=AZdu3AdXw2)eD6Y;C3{A>=G^>bX`v0d|(e1F=m0r?`| zcWo$#FMvq?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