generated from Choate-Robotics/7407-DriveCode-Template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
constants.py
313 lines (285 loc) · 10.5 KB
/
constants.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
"""
Constant values
"""
import math
from robotpy_toolkit_7407.utils.units import hour, m, mile, rad, rev, s
from wpimath.geometry import Pose3d, Rotation3d, Transform3d
from config import field_length, field_width
from units.SI import (
inches_to_meters,
meters,
meters_per_second,
meters_per_second_squared,
radians,
radians_per_second,
rotations,
rotations_per_minute,
rotations_per_minute_per_second,
)
# boundary dimension constants
# --------------------------------------------------------------
horizontal_boundary: meters = (
28 * inches_to_meters
) # the horizontal boundary is the distance from the pivot point (center of robot) to the\
# robots maximum extension limit in the x direction (one side of the robot)
vertical_boundary: meters = (
78 * inches_to_meters
) # the vertical boundary is the distance from the floor to the robots maximum extension limit in the y direction
# --------------------------------------------------------------
# boundary buffer constants
# --------------------------------------------------------------
bottom_boundary_buffer_gap: meters = (
1 * inches_to_meters
) # the buffer in between the bottom boundary
top_boundary_buffer_gap: meters = (
0 * inches_to_meters
) # the buffer in between the top boundary
side_boundary_buffer_gap: meters = (
0 * inches_to_meters
) # the buffer in between the side boundaries
# --------------------------------------------------------------
# shoulder constants
# --------------------------------------------------------------
shoulder_max_rotation: radians = math.radians(
80
) # the maximum rotation of the shoulder
shoulder_min_rotation: radians = math.radians(
110
) # the minimum rotation of the shoulder
shoulder_intake_up_max_rotation: radians = math.radians(
90
) # the maximum rotation of the shoulder when the intake is up
# --------------------------------------------------------------
# shoulder buffer constants
# --------------------------------------------------------------
shoulder_min_buffer_rotation: radians = math.radians(
1
) # the buffer in between the minimum rotation
shoulder_max_buffer_rotation: radians = math.radians(
1
) # the buffer in between the maximum rotation
# --------------------------------------------------------------
# elevator constants
# --------------------------------------------------------------
min_elevator_height: meters = (
30 * inches_to_meters
) # the minimum height of the elevator
elevator_pivot_offset: meters = (
-2.5 * inches_to_meters
) # offset from the pivot point to the center of the elevator
max_elevator_height: meters = (
59.5 * inches_to_meters
) # the maximum height of the elevator
max_elevator_height_delta: meters = (
40 * inches_to_meters
) # the maximum height of the elevator
pivot_point_height: meters = 17 * inches_to_meters # the height of the pivot point
# --------------------------------------------------------------
# --------------------------------------------------------------
elevator_zero_length: meters = (min_elevator_height / 2) + (-elevator_pivot_offset)
# gets the length of the elevator above the pivot point using the offset and the min height
# --------------------------------------------------------------
# arm pose accuracy
# --------------------------------------------------------------
arm_pose_accuracy: float = 0.01 # the accuracy of the arm pose
# --------------------------------------------------------------
# claw constants
# --------------------------------------------------------------
claw_height: meters = 10 * inches_to_meters # the height of the claw
claw_width: meters = 3 * inches_to_meters # the width of the claw
claw_length_open: meters = (
14 * inches_to_meters
) # the length of the claw when it is open
claw_length_close: meters = (
8 * inches_to_meters
) # the length of the claw when it is closed
# --------------------------------------------------------------
# elevator gear ratios
# --------------------------------------------------------------
elevator_rotation_gear_ratio: rotations = 67.38 # to one
elevator_extend_gear_ratio: rotations = 6.33 # 6.33 # to one
elevator_length_per_rotation: meters = (
1.736 * inches_to_meters
) # the length of the elevator per rotation
wrist_gear_ratio: rotations = 80
# 24 rotations to max extension
stabilizer_magnitude: float = (
2 # the magnitude of the rotation of the arm based on the tip of the robot
)
shoulder_max_velocity: rotations_per_minute = 25 * elevator_rotation_gear_ratio # RPM
shoulder_max_acceleration: rotations_per_minute_per_second = (
25 * elevator_rotation_gear_ratio
) # RPM / S
shoulder_min_acceleration: rotations_per_minute_per_second = (
5 * elevator_extend_gear_ratio
) # RPM / S
# --------------------------------------------------------------
# Wrist soft mount
# --------------------------------------------------------------
wrist_max_rotation: radians = math.radians(90) # the maximum rotation of the wrist
wrist_min_rotation: radians = math.radians(90) # the minimum rotation of the wrist
# --------------------------------------------------------------
# elevator zeroing constants
# --------------------------------------------------------------
elevator_initial_rotation = (
0 # the initial rotation of the elevator that it will zero to
)
elevator_initial_length = (
0 * inches_to_meters
) # the initial length of the elevator that it will zero to
# --------------------------------------------------------------
claw_motor_speed: float = 0.2
# --------------------------------------------------------------
period = 0.03
# --- DRIVETRAIN ---
# drivetrain_turn_gear_ratio = ((8.16 * 4096)/(2*math.pi) * rev_sensor_unit / rad).asNumber()
drivetrain_turn_gear_ratio: rotations = 150 / 7 # 21.428
drivetrain_move_gear_ratio_as_rotations_per_meter = 21.148
drivetrain_move_gear_ratio: rotations_per_minute = (
drivetrain_move_gear_ratio_as_rotations_per_meter * 60
) # 20.64 * 62
track_width: meters = 0.60325
robot_length: meters = 0.7366
# TODO Maybe change these
drivetrain_accel = True
drivetrain_max_vel: meters_per_second = (15 * mile / hour).asNumber(m / s) # 15 11
drivetrain_max_accel_tele: meters_per_second_squared = (45 * mile / hour).asNumber(m / s)
drivetrain_max_target_accel: meters_per_second_squared = (
1.5 * mile / hour
).asNumber( # 10
m / s
)
drivetrain_target_max_vel: meters_per_second = (2 * mile / hour).asNumber(m / s) # 3
drivetrain_max_angular_vel: radians_per_second = (1 * rev / s).asNumber(rad / s) # 5
drivetrain_max_correction_vel: radians_per_second = (2 * rev / s).asNumber(rad / s)
drivetrain_max_climb_vel: meters_per_second = (5 * mile / hour).asNumber(m / s)
climber_out = False
# this sets up the operator controller to determine which state the climber is in at the start of the match :)
ApriltagPositionDictRed = {
1: Pose3d(
(field_length - inches_to_meters * 610.77),
(field_width - inches_to_meters * 42.19),
(inches_to_meters * 18.22),
Rotation3d(0.0, 0.0, 0),
),
2: Pose3d(
(field_length - inches_to_meters * 610.77),
(field_width - inches_to_meters * 108.19),
(inches_to_meters * 18.22),
Rotation3d(0.0, 0.0, 0),
),
3: Pose3d(
(field_length - inches_to_meters * 610.77),
(field_width - inches_to_meters * 174.19),
(inches_to_meters * 18.22),
Rotation3d(0.0, 0.0, 0),
),
4: Pose3d(
(field_length - inches_to_meters * 636.96),
(field_width - inches_to_meters * 265.74),
(inches_to_meters * 27.38),
Rotation3d(0.0, 0.0, 0),
),
5: Pose3d(
(field_length - inches_to_meters * 14.25),
(field_width - inches_to_meters * 265.74),
(inches_to_meters * 27.38),
Rotation3d(0.0, 0.0, math.pi),
),
6: Pose3d(
(field_length - inches_to_meters * 40.45),
(field_width - inches_to_meters * 174.19),
(inches_to_meters * 18.22),
Rotation3d(0.0, 0.0, math.pi),
),
7: Pose3d(
(field_length - inches_to_meters * 40.45),
(field_width - inches_to_meters * 108.19),
(inches_to_meters * 18.22),
Rotation3d(0.0, 0.0, math.pi),
),
8: Pose3d(
(field_length - inches_to_meters * 40.45),
(field_width - inches_to_meters * 42.19),
(inches_to_meters * 18.22),
Rotation3d(0.0, 0.0, math.pi),
),
}
ApriltagPositionDictBlue = {
1: Pose3d(
(inches_to_meters * 610.77),
(inches_to_meters * 42.19),
(inches_to_meters * 18.22),
Rotation3d(0.0, 0.0, math.pi),
),
2: Pose3d(
(inches_to_meters * 610.77),
(inches_to_meters * 108.19),
(inches_to_meters * 18.22),
Rotation3d(0.0, 0.0, math.pi),
),
3: Pose3d(
(inches_to_meters * 610.77),
(inches_to_meters * 174.19), # FIRST's diagram has a typo (it says 147.19)
(inches_to_meters * 18.22),
Rotation3d(0.0, 0.0, math.pi),
),
4: Pose3d(
(inches_to_meters * 636.96),
(inches_to_meters * 265.74),
(inches_to_meters * 27.38),
Rotation3d(0.0, 0.0, math.pi),
),
5: Pose3d(
(inches_to_meters * 14.25),
(inches_to_meters * 265.74),
(inches_to_meters * 27.38),
Rotation3d(),
),
6: Pose3d(
(inches_to_meters * 40.45),
(inches_to_meters * 174.19), # FIRST's diagram has a typo (it says 147.19)
(inches_to_meters * 18.22),
Rotation3d(),
),
7: Pose3d(
(inches_to_meters * 40.45),
(inches_to_meters * 108.19),
(inches_to_meters * 18.22),
Rotation3d(),
),
8: Pose3d(
(inches_to_meters * 40.45),
(inches_to_meters * 42.19),
(inches_to_meters * 18.22),
Rotation3d(),
),
}
kCameras = {
"Arducam_OV9281_USB_Camera": [
Transform3d(
Pose3d(),
Pose3d(
6.43 * inches_to_meters,
-7 * inches_to_meters,
22.5 * inches_to_meters,
Rotation3d(0, 0, math.radians(180)),
),
)
],
"Arducam_OV9281_USB_Camera_2": [
Transform3d(
Pose3d(),
Pose3d(
-6.43 * inches_to_meters,
-7 * inches_to_meters,
22.5 * inches_to_meters,
Rotation3d(0, 0, math.radians(0)),
),
)
],
}
# Climber:
climber_motor_gear_ratio = 16
climber_pivot_rotations = 1.22 * climber_motor_gear_ratio
climber_unlatch_extension = 0.3 * climber_motor_gear_ratio