blob: 9bb335c11e08b703d2434eb7297531a747a43786 [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",
291 "//frc971/control_loops:fixed_quadrature",
292 "//third_party/eigen",
293 ],
294)
295
296cc_test(
297 name = "distance_spline_test",
298 srcs = [
299 "distance_spline_test.cc",
300 ],
301 restricted_to = ["//tools:k8"],
302 deps = [
303 ":distance_spline",
304 "//aos/testing:googletest",
305 "//third_party/matplotlib-cpp",
306 "@com_github_gflags_gflags//:gflags",
307 ],
308)
Austin Schuhec7f06d2019-01-04 07:47:15 +1100309
310cc_library(
311 name = "trajectory",
312 srcs = ["trajectory.cc"],
313 hdrs = ["trajectory.h"],
314 deps = [
315 ":distance_spline",
316 ":drivetrain_config",
317 "//aos/logging:matrix_logging",
318 "//frc971/control_loops:c2d",
319 "//frc971/control_loops:dlqr",
320 "//frc971/control_loops:hybrid_state_feedback_loop",
321 "//frc971/control_loops:runge_kutta",
322 "//frc971/control_loops:state_feedback_loop",
323 "//third_party/eigen",
324 ],
325)
326
327cc_binary(
328 name = "trajectory_plot",
329 srcs = [
330 "trajectory_plot.cc",
331 ],
332 restricted_to = ["//tools:k8"],
333 deps = [
334 ":distance_spline",
335 ":trajectory",
336 "//aos/logging:implementations",
337 "//aos/logging:matrix_logging",
338 "//aos/network:team_number",
339 "//third_party/eigen",
340 "//third_party/matplotlib-cpp",
341 "//y2016/control_loops/drivetrain:drivetrain_base",
342 "@com_github_gflags_gflags//:gflags",
343 ],
344)
345
346cc_test(
347 name = "trajectory_test",
348 srcs = [
349 "trajectory_test.cc",
350 ],
Austin Schuh719a33e2019-01-07 15:13:34 -0800351 defines =
352 cpu_select({
353 "amd64": [
354 "SUPPORT_PLOT=1",
355 ],
356 "arm": [],
357 }),
358 linkstatic = True,
Austin Schuhec7f06d2019-01-04 07:47:15 +1100359 deps = [
360 ":trajectory",
361 "//aos/testing:googletest",
362 "//aos/testing:test_shm",
363 "//y2016:constants",
364 "//y2016/control_loops/drivetrain:polydrivetrain_plants",
Austin Schuh719a33e2019-01-07 15:13:34 -0800365 ] + cpu_select({
366 "amd64": [
367 "//third_party/matplotlib-cpp",
368 ],
369 "arm": [],
370 }),
Austin Schuhec7f06d2019-01-04 07:47:15 +1100371)