blob: aee3a37a002925499be6520289412c945cb51b35 [file] [log] [blame]
Austin Schuhbcce26a2018-03-26 23:41:24 -07001package(default_visibility = ["//visibility:public"])
Comran Morshed5323ecb2015-12-26 20:50:55 +00002
Austin Schuhbcce26a2018-03-26 23:41:24 -07003load("//aos/build:queues.bzl", "queue_library")
4load("//tools:environments.bzl", "mcu_cpus")
Austin Schuh719a33e2019-01-07 15:13:34 -08005load("//tools/build_rules:select.bzl", "cpu_select", "compiler_select")
Comran Morshed5323ecb2015-12-26 20:50:55 +00006
7cc_binary(
Austin Schuhbcce26a2018-03-26 23:41:24 -07008 name = "replay_drivetrain",
9 srcs = [
10 "replay_drivetrain.cc",
11 ],
12 deps = [
13 ":drivetrain_queue",
John Park398c74a2018-10-20 21:17:39 -070014 "//aos:init",
Austin Schuhc2b08772018-12-19 18:05:06 +110015 "//aos/controls:replay_control_loop",
Austin Schuhbcce26a2018-03-26 23:41:24 -070016 "//frc971/queues:gyro",
17 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +000018)
19
20queue_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -070021 name = "drivetrain_queue",
22 srcs = [
23 "drivetrain.q",
24 ],
25 deps = [
John Park33858a32018-09-28 23:05:48 -070026 "//aos/controls:control_loop_queues",
Austin Schuhbcce26a2018-03-26 23:41:24 -070027 "//frc971/control_loops:queues",
28 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +000029)
30
31cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -070032 name = "drivetrain_config",
33 hdrs = [
34 "drivetrain_config.h",
35 ],
36 deps = [
37 "//frc971:shifter_hall_effect",
Austin Schuha062edb2019-01-03 13:17:13 -080038 "//frc971/control_loops:hybrid_state_feedback_loop",
Austin Schuhbcce26a2018-03-26 23:41:24 -070039 "//frc971/control_loops:state_feedback_loop",
40 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +000041)
42
43cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -070044 name = "gear",
45 hdrs = [
46 "gear.h",
47 ],
48 compatible_with = mcu_cpus,
Austin Schuh093535c2016-03-05 23:21:00 -080049)
50
51cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -070052 name = "ssdrivetrain",
53 srcs = [
54 "ssdrivetrain.cc",
55 ],
56 hdrs = [
57 "ssdrivetrain.h",
58 ],
59 deps = [
60 ":drivetrain_config",
61 ":drivetrain_queue",
62 ":gear",
John Park33858a32018-09-28 23:05:48 -070063 "//aos:math",
64 "//aos/controls:control_loop",
65 "//aos/controls:polytope",
66 "//aos/logging:matrix_logging",
67 "//aos/logging:queue_logging",
Austin Schuhc2b08772018-12-19 18:05:06 +110068 "//aos/robot_state",
John Park33858a32018-09-28 23:05:48 -070069 "//aos/util:log_interval",
70 "//aos/util:trapezoid_profile",
Austin Schuhbcce26a2018-03-26 23:41:24 -070071 "//frc971:shifter_hall_effect",
72 "//frc971/control_loops:coerce_goal",
73 "//frc971/control_loops:state_feedback_loop",
74 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +000075)
76
77cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -070078 name = "polydrivetrain",
79 srcs = [
80 "polydrivetrain.cc",
81 ],
82 hdrs = [
83 "polydrivetrain.h",
84 ],
85 deps = [
86 ":drivetrain_config",
87 ":drivetrain_queue",
88 ":gear",
John Park33858a32018-09-28 23:05:48 -070089 "//aos:math",
90 "//aos/controls:polytope",
91 "//aos/logging:matrix_logging",
92 "//aos/logging:queue_logging",
Austin Schuhc2b08772018-12-19 18:05:06 +110093 "//aos/robot_state",
John Park33858a32018-09-28 23:05:48 -070094 "//aos/util:log_interval",
Austin Schuhbcce26a2018-03-26 23:41:24 -070095 "//frc971/control_loops:coerce_goal",
96 "//frc971/control_loops:state_feedback_loop",
97 ],
98)
99
100cc_library(
101 name = "drivetrain_config_uc",
102 hdrs = [
103 "drivetrain_config.h",
104 ],
105 restricted_to = mcu_cpus,
106 deps = [
107 "//frc971:shifter_hall_effect",
108 "//frc971/control_loops:state_feedback_loop_uc",
109 ],
110)
111
112cc_library(
113 name = "polydrivetrain_uc",
114 srcs = [
115 "drivetrain_uc.q.cc",
116 "polydrivetrain.cc",
117 ],
118 hdrs = [
119 "drivetrain_uc.q.h",
120 "polydrivetrain.h",
121 ],
122 restricted_to = mcu_cpus,
123 deps = [
124 ":drivetrain_config_uc",
125 ":gear",
John Park33858a32018-09-28 23:05:48 -0700126 "//aos:math",
127 "//aos/controls:polytope_uc",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700128 "//frc971/control_loops:coerce_goal_uc",
129 "//frc971/control_loops:state_feedback_loop_uc",
130 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000131)
132
Austin Schuh05c5a612016-04-02 15:10:25 -0700133genrule(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700134 name = "genrule_down_estimator",
135 outs = [
136 "down_estimator.h",
137 "down_estimator.cc",
138 ],
139 cmd = "$(location //frc971/control_loops/python:down_estimator) $(OUTS)",
140 tools = [
141 "//frc971/control_loops/python:down_estimator",
142 ],
143 visibility = ["//visibility:private"],
Austin Schuh05c5a612016-04-02 15:10:25 -0700144)
145
146cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700147 name = "down_estimator",
148 srcs = [
149 "down_estimator.cc",
150 ],
151 hdrs = [
152 "down_estimator.h",
153 ],
154 deps = [
155 "//frc971/control_loops:state_feedback_loop",
156 ],
Austin Schuh05c5a612016-04-02 15:10:25 -0700157)
158
Comran Morshed5323ecb2015-12-26 20:50:55 +0000159cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700160 name = "drivetrain_lib",
161 srcs = [
162 "drivetrain.cc",
163 ],
164 hdrs = [
165 "drivetrain.h",
166 ],
167 deps = [
168 ":down_estimator",
169 ":drivetrain_queue",
170 ":gear",
171 ":polydrivetrain",
172 ":ssdrivetrain",
John Park33858a32018-09-28 23:05:48 -0700173 "//aos/controls:control_loop",
174 "//aos/logging:matrix_logging",
175 "//aos/logging:queue_logging",
176 "//aos/util:log_interval",
Austin Schuh3a378462019-01-04 21:48:04 -0800177 "//frc971/control_loops:runge_kutta",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700178 "//frc971/queues:gyro",
179 "//frc971/wpilib:imu_queue",
180 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000181)
182
183cc_test(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700184 name = "drivetrain_lib_test",
185 srcs = [
186 "drivetrain_lib_test.cc",
187 ],
188 deps = [
189 ":drivetrain_config",
190 ":drivetrain_lib",
191 ":drivetrain_queue",
John Park33858a32018-09-28 23:05:48 -0700192 "//aos:queues",
193 "//aos/controls:control_loop_test",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700194 "//aos/testing:googletest",
195 "//frc971/control_loops:state_feedback_loop",
196 "//frc971/queues:gyro",
197 "//y2016:constants",
198 "//y2016/control_loops/drivetrain:polydrivetrain_plants",
199 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000200)
Brian Silverman6260c092018-01-14 15:21:36 -0800201
202genrule(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700203 name = "genrule_haptic_wheel",
204 outs = [
205 "haptic_wheel.h",
206 "haptic_wheel.cc",
207 "integral_haptic_wheel.h",
208 "integral_haptic_wheel.cc",
209 "haptic_trigger.h",
210 "haptic_trigger.cc",
211 "integral_haptic_trigger.h",
212 "integral_haptic_trigger.cc",
213 ],
214 cmd = "$(location //frc971/control_loops/python:haptic_wheel) $(OUTS)",
215 compatible_with = mcu_cpus,
216 tools = [
217 "//frc971/control_loops/python:haptic_wheel",
218 ],
219 visibility = ["//visibility:private"],
Brian Silverman6260c092018-01-14 15:21:36 -0800220)
221
222cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700223 name = "haptic_input_uc",
224 srcs = [
225 "haptic_trigger.cc",
226 "haptic_wheel.cc",
227 "integral_haptic_trigger.cc",
228 "integral_haptic_wheel.cc",
229 ],
230 hdrs = [
231 "haptic_trigger.h",
232 "haptic_wheel.h",
233 "integral_haptic_trigger.h",
234 "integral_haptic_wheel.h",
235 ],
236 restricted_to = mcu_cpus,
237 deps = [
238 "//frc971/control_loops:state_feedback_loop_uc",
239 ],
Brian Silverman6260c092018-01-14 15:21:36 -0800240)
241
242cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700243 name = "haptic_wheel",
244 srcs = [
245 "haptic_trigger.cc",
246 "haptic_wheel.cc",
247 "integral_haptic_trigger.cc",
248 "integral_haptic_wheel.cc",
249 ],
250 hdrs = [
251 "haptic_trigger.h",
252 "haptic_wheel.h",
253 "integral_haptic_trigger.h",
254 "integral_haptic_wheel.h",
255 ],
256 deps = [
257 "//frc971/control_loops:state_feedback_loop",
258 ],
Brian Silverman6260c092018-01-14 15:21:36 -0800259)
Austin Schuhc2b08772018-12-19 18:05:06 +1100260
261cc_library(
262 name = "spline",
263 srcs = ["spline.cc"],
264 hdrs = ["spline.h"],
265 deps = [
Austin Schuhf49b4e32019-01-13 17:26:58 -0800266 "//frc971/control_loops:binomial",
Austin Schuhc2b08772018-12-19 18:05:06 +1100267 "//third_party/eigen",
268 ],
269)
270
Alex Perrya60da442019-01-21 19:00:27 -0500271cc_binary(
272 name = "spline.so",
273 srcs = ["libspline.cc"],
274 deps = [
275 ":distance_spline",
276 ":spline",
Alex Perry0603b542019-01-25 20:29:51 -0800277 ":trajectory",
278 "//aos/logging:implementations",
279 "//aos/network:team_number",
Alex Perrya60da442019-01-21 19:00:27 -0500280 "//third_party/eigen",
Alex Perry0603b542019-01-25 20:29:51 -0800281 "//y2019/control_loops/drivetrain:drivetrain_base",
Alex Perrya60da442019-01-21 19:00:27 -0500282 ],
283 linkshared=True,
284)
285
Austin Schuhc2b08772018-12-19 18:05:06 +1100286cc_test(
287 name = "spline_test",
288 srcs = [
289 "spline_test.cc",
290 ],
291 restricted_to = ["//tools:k8"],
292 deps = [
293 ":spline",
294 "//aos/testing:googletest",
295 "//third_party/matplotlib-cpp",
296 "@com_github_gflags_gflags//:gflags",
297 ],
298)
Austin Schuh941b46d2018-12-19 18:06:05 +1100299
300cc_library(
301 name = "distance_spline",
302 srcs = ["distance_spline.cc"],
303 hdrs = ["distance_spline.h"],
304 deps = [
305 ":spline",
Austin Schuha6e7b212019-01-20 13:53:01 -0800306 "//aos/logging",
Austin Schuh941b46d2018-12-19 18:06:05 +1100307 "//frc971/control_loops:fixed_quadrature",
308 "//third_party/eigen",
309 ],
310)
311
312cc_test(
313 name = "distance_spline_test",
314 srcs = [
315 "distance_spline_test.cc",
316 ],
Austin Schuh9b0b6432019-01-13 21:15:17 -0800317 defines =
318 cpu_select({
319 "amd64": [
320 "SUPPORT_PLOT=1",
321 ],
322 "arm": [],
323 }),
324 linkstatic = True,
Austin Schuh941b46d2018-12-19 18:06:05 +1100325 deps = [
326 ":distance_spline",
327 "//aos/testing:googletest",
Austin Schuha6e7b212019-01-20 13:53:01 -0800328 "//aos/testing:test_shm",
Austin Schuh941b46d2018-12-19 18:06:05 +1100329 "@com_github_gflags_gflags//:gflags",
Austin Schuh9b0b6432019-01-13 21:15:17 -0800330 ] + cpu_select({
331 "amd64": [
332 "//third_party/matplotlib-cpp",
333 ],
334 "arm": [],
335 }),
Austin Schuh941b46d2018-12-19 18:06:05 +1100336)
Austin Schuhec7f06d2019-01-04 07:47:15 +1100337
338cc_library(
339 name = "trajectory",
340 srcs = ["trajectory.cc"],
341 hdrs = ["trajectory.h"],
342 deps = [
343 ":distance_spline",
344 ":drivetrain_config",
345 "//aos/logging:matrix_logging",
346 "//frc971/control_loops:c2d",
347 "//frc971/control_loops:dlqr",
348 "//frc971/control_loops:hybrid_state_feedback_loop",
349 "//frc971/control_loops:runge_kutta",
350 "//frc971/control_loops:state_feedback_loop",
351 "//third_party/eigen",
352 ],
353)
354
355cc_binary(
356 name = "trajectory_plot",
357 srcs = [
358 "trajectory_plot.cc",
359 ],
360 restricted_to = ["//tools:k8"],
361 deps = [
362 ":distance_spline",
363 ":trajectory",
364 "//aos/logging:implementations",
365 "//aos/logging:matrix_logging",
366 "//aos/network:team_number",
367 "//third_party/eigen",
368 "//third_party/matplotlib-cpp",
369 "//y2016/control_loops/drivetrain:drivetrain_base",
370 "@com_github_gflags_gflags//:gflags",
371 ],
372)
373
374cc_test(
375 name = "trajectory_test",
376 srcs = [
377 "trajectory_test.cc",
378 ],
Austin Schuh719a33e2019-01-07 15:13:34 -0800379 defines =
380 cpu_select({
381 "amd64": [
382 "SUPPORT_PLOT=1",
383 ],
384 "arm": [],
385 }),
386 linkstatic = True,
Austin Schuhec7f06d2019-01-04 07:47:15 +1100387 deps = [
388 ":trajectory",
389 "//aos/testing:googletest",
390 "//aos/testing:test_shm",
391 "//y2016:constants",
392 "//y2016/control_loops/drivetrain:polydrivetrain_plants",
Austin Schuh719a33e2019-01-07 15:13:34 -0800393 ] + cpu_select({
394 "amd64": [
395 "//third_party/matplotlib-cpp",
396 ],
397 "arm": [],
398 }),
Austin Schuhec7f06d2019-01-04 07:47:15 +1100399)