blob: 2bad4d946e9d1f5483a11eea139802739bc2ac9b [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
271cc_test(
272 name = "spline_test",
273 srcs = [
274 "spline_test.cc",
275 ],
276 restricted_to = ["//tools:k8"],
277 deps = [
278 ":spline",
279 "//aos/testing:googletest",
280 "//third_party/matplotlib-cpp",
281 "@com_github_gflags_gflags//:gflags",
282 ],
283)
Austin Schuh941b46d2018-12-19 18:06:05 +1100284
285cc_library(
286 name = "distance_spline",
287 srcs = ["distance_spline.cc"],
288 hdrs = ["distance_spline.h"],
289 deps = [
290 ":spline",
Austin Schuha6e7b212019-01-20 13:53:01 -0800291 "//aos/logging",
Austin Schuh941b46d2018-12-19 18:06:05 +1100292 "//frc971/control_loops:fixed_quadrature",
293 "//third_party/eigen",
294 ],
295)
296
297cc_test(
298 name = "distance_spline_test",
299 srcs = [
300 "distance_spline_test.cc",
301 ],
Austin Schuh9b0b6432019-01-13 21:15:17 -0800302 defines =
303 cpu_select({
304 "amd64": [
305 "SUPPORT_PLOT=1",
306 ],
307 "arm": [],
308 }),
309 linkstatic = True,
Austin Schuh941b46d2018-12-19 18:06:05 +1100310 deps = [
311 ":distance_spline",
312 "//aos/testing:googletest",
Austin Schuha6e7b212019-01-20 13:53:01 -0800313 "//aos/testing:test_shm",
Austin Schuh941b46d2018-12-19 18:06:05 +1100314 "@com_github_gflags_gflags//:gflags",
Austin Schuh9b0b6432019-01-13 21:15:17 -0800315 ] + cpu_select({
316 "amd64": [
317 "//third_party/matplotlib-cpp",
318 ],
319 "arm": [],
320 }),
Austin Schuh941b46d2018-12-19 18:06:05 +1100321)
Austin Schuhec7f06d2019-01-04 07:47:15 +1100322
323cc_library(
324 name = "trajectory",
325 srcs = ["trajectory.cc"],
326 hdrs = ["trajectory.h"],
327 deps = [
328 ":distance_spline",
329 ":drivetrain_config",
330 "//aos/logging:matrix_logging",
331 "//frc971/control_loops:c2d",
332 "//frc971/control_loops:dlqr",
333 "//frc971/control_loops:hybrid_state_feedback_loop",
334 "//frc971/control_loops:runge_kutta",
335 "//frc971/control_loops:state_feedback_loop",
336 "//third_party/eigen",
337 ],
338)
339
340cc_binary(
341 name = "trajectory_plot",
342 srcs = [
343 "trajectory_plot.cc",
344 ],
345 restricted_to = ["//tools:k8"],
346 deps = [
347 ":distance_spline",
348 ":trajectory",
349 "//aos/logging:implementations",
350 "//aos/logging:matrix_logging",
351 "//aos/network:team_number",
352 "//third_party/eigen",
353 "//third_party/matplotlib-cpp",
354 "//y2016/control_loops/drivetrain:drivetrain_base",
355 "@com_github_gflags_gflags//:gflags",
356 ],
357)
358
359cc_test(
360 name = "trajectory_test",
361 srcs = [
362 "trajectory_test.cc",
363 ],
Austin Schuh719a33e2019-01-07 15:13:34 -0800364 defines =
365 cpu_select({
366 "amd64": [
367 "SUPPORT_PLOT=1",
368 ],
369 "arm": [],
370 }),
371 linkstatic = True,
Austin Schuhec7f06d2019-01-04 07:47:15 +1100372 deps = [
373 ":trajectory",
374 "//aos/testing:googletest",
375 "//aos/testing:test_shm",
376 "//y2016:constants",
377 "//y2016/control_loops/drivetrain:polydrivetrain_plants",
Austin Schuh719a33e2019-01-07 15:13:34 -0800378 ] + cpu_select({
379 "amd64": [
380 "//third_party/matplotlib-cpp",
381 ],
382 "arm": [],
383 }),
Austin Schuhec7f06d2019-01-04 07:47:15 +1100384)