blob: 15bac77f8a0d16d8f2f0c4c5720b4d42d653de1d [file] [log] [blame]
Het Satasiya9633d4b2020-08-16 15:31:17 -07001from gi.repository import Gtk
Ravago Jones5f787df2021-01-23 16:26:27 -08002from collections import namedtuple
John Park91e69732019-03-03 13:12:43 -08003
Het Satasiya9633d4b2020-08-16 15:31:17 -07004window = Gtk.Window()
5screen = window.get_screen()
6
7#Set screen size for rest of program.
Austin Schuhb2d77af2021-03-31 20:07:21 -07008SCREEN_SIZE = screen.get_height() / 1.5
John Park91e69732019-03-03 13:12:43 -08009
Het Satasiya9633d4b2020-08-16 15:31:17 -070010# Placeholder value
11ROBOT_SIDE_TO_BALL_CENTER = 0.15
John Park91e69732019-03-03 13:12:43 -080012BALL_RADIUS = 0.165
Het Satasiya9633d4b2020-08-16 15:31:17 -070013
14# Placeholder value
15ROBOT_SIDE_TO_HATCH_PANEL = 0.1
John Park91e69732019-03-03 13:12:43 -080016HATCH_PANEL_WIDTH = 0.4826
17
Ravago Jones5f787df2021-01-23 16:26:27 -080018FieldType = namedtuple(
Ravago Jonesc26b9162021-06-30 20:12:48 -070019 'Field', ['name', 'tags', 'year', 'width', 'length', 'robot', 'field_id'])
Ravago Jones5e09c072021-03-27 13:21:03 -070020RobotType = namedtuple(
21 "Robot", ['width', 'length'])
John Parkcf545162020-02-23 20:07:25 -080022
Ravago Jones5f787df2021-01-23 16:26:27 -080023GALACTIC_SEARCH = "Galactic Search"
24ARED = "A Red"
25BRED = "B Red"
26ABLUE = "A Blue"
27BBLUE = "B Blue"
28AUTONAV = "AutoNav"
29BOUNCE = "Bounce"
30SLALOM = "Slalom"
31BARREL = "Barrel"
32
Ravago Jones5e09c072021-03-27 13:21:03 -070033Robot2019 = RobotType(width=0.65, length=0.8)
34Robot2020 = RobotType(width=0.8128, length=0.8636) # 32 in x 34 in
35Robot2021 = Robot2020
36
Ravago Jones5f787df2021-01-23 16:26:27 -080037FIELDS = {
38 "2019 Field":
39 FieldType(
40 "2019 Field",
41 tags=[],
42 year=2019,
43 width=8.258302,
44 length=8.258302,
Ravago Jones5e09c072021-03-27 13:21:03 -070045 robot=Robot2019,
Ravago Jonesc26b9162021-06-30 20:12:48 -070046 field_id="2019"),
Ravago Jones5f787df2021-01-23 16:26:27 -080047 "2020 Field":
48 FieldType(
49 "2020 Field",
50 tags=[],
51 year=2020,
52 width=15.98295,
53 length=8.21055,
Ravago Jones5e09c072021-03-27 13:21:03 -070054 robot=Robot2020,
Ravago Jonesc26b9162021-06-30 20:12:48 -070055 field_id="2020"),
Ravago Jones5f787df2021-01-23 16:26:27 -080056 "2021 Galactic Search BRed":
57 FieldType(
58 "2021 Galactic Search BRed",
59 tags=[GALACTIC_SEARCH, BRED],
60 year=2021,
61 width=9.144,
62 length=4.572,
Ravago Jones5e09c072021-03-27 13:21:03 -070063 robot=Robot2021,
Ravago Jonesc26b9162021-06-30 20:12:48 -070064 field_id="red_b"),
Ravago Jones5f787df2021-01-23 16:26:27 -080065 "2021 Galactic Search ARed":
66 FieldType(
67 "2021 Galactic Search ARed",
68 tags=[GALACTIC_SEARCH, ARED],
69 year=2021,
70 width=9.144,
71 length=4.572,
Ravago Jones5e09c072021-03-27 13:21:03 -070072 robot=Robot2021,
Ravago Jonesc26b9162021-06-30 20:12:48 -070073 field_id="red_a"),
Ravago Jones5f787df2021-01-23 16:26:27 -080074 "2021 Galactic Search BBlue":
75 FieldType(
76 "2021 Galactic Search BBlue",
77 tags=[GALACTIC_SEARCH, BBLUE],
78 year=2021,
79 width=9.144,
80 length=4.572,
Ravago Jones5e09c072021-03-27 13:21:03 -070081 robot=Robot2021,
Ravago Jonesc26b9162021-06-30 20:12:48 -070082 field_id="blue_b"),
Ravago Jones5f787df2021-01-23 16:26:27 -080083 "2021 Galactic Search ABlue":
84 FieldType(
85 "2021 Galactic Search ABlue",
86 tags=[GALACTIC_SEARCH, ABLUE],
87 year=2021,
88 width=9.144,
89 length=4.572,
Ravago Jones5e09c072021-03-27 13:21:03 -070090 robot=Robot2021,
Ravago Jonesc26b9162021-06-30 20:12:48 -070091 field_id="blue_a"),
Ravago Jones5f787df2021-01-23 16:26:27 -080092 "2021 AutoNav Barrel":
93 FieldType(
94 "2021 AutoNav Barrel",
95 tags=[AUTONAV, BARREL],
96 year=2021,
97 width=9.144,
98 length=4.572,
Ravago Jones5e09c072021-03-27 13:21:03 -070099 robot=Robot2021,
Ravago Jonesc26b9162021-06-30 20:12:48 -0700100 field_id="autonav_barrel"),
Ravago Jones5f787df2021-01-23 16:26:27 -0800101 "2021 AutoNav Slalom":
102 FieldType(
103 "2021 AutoNav Slalom",
104 tags=[AUTONAV, SLALOM],
105 year=2021,
106 width=9.144,
107 length=4.572,
Ravago Jones5e09c072021-03-27 13:21:03 -0700108 robot=Robot2021,
Ravago Jonesc26b9162021-06-30 20:12:48 -0700109 field_id="autonav_slalom"),
Ravago Jones5f787df2021-01-23 16:26:27 -0800110 "2021 AutoNav Bounce":
111 FieldType(
112 "2021 AutoNav Bounce",
113 tags=[AUTONAV, BOUNCE],
114 year=2021,
115 width=9.144,
116 length=4.572,
Ravago Jones5e09c072021-03-27 13:21:03 -0700117 robot=Robot2021,
Ravago Jonesc26b9162021-06-30 20:12:48 -0700118 field_id="autonav_bounce"),
Ravago Jones5f787df2021-01-23 16:26:27 -0800119}
120
Ravago Jones76ecec82021-08-07 14:37:08 -0700121FIELD = FIELDS["2020 Field"]
John Parkcf545162020-02-23 20:07:25 -0800122
James Kuszmaul1c933e02020-03-07 16:17:51 -0800123
Ravago Jones09f59722021-03-03 21:11:41 -0800124def get_json_folder(field):
125 if field.year == 2020 or field.year == 2021:
126 return "y2020/actors/splines"
127 else:
128 return "frc971/control_loops/python/spline_jsons"
129
130
James Kuszmaul1c933e02020-03-07 16:17:51 -0800131def pxToM(p):
Ravago Jones5f787df2021-01-23 16:26:27 -0800132 return p * FIELD.width / SCREEN_SIZE
John Park91e69732019-03-03 13:12:43 -0800133
James Kuszmaul1c933e02020-03-07 16:17:51 -0800134
135def mToPx(m):
Ravago Jones5f787df2021-01-23 16:26:27 -0800136 return (m * SCREEN_SIZE / FIELD.width)
James Kuszmaul1c933e02020-03-07 16:17:51 -0800137
John Parkcf545162020-02-23 20:07:25 -0800138
139def inToM(i):
James Kuszmaul1c933e02020-03-07 16:17:51 -0800140 return (i * 0.0254)