blob: ac6e2d3a60b858ac39f6644a7937fb3c6d49d90b [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 = [
266 "//third_party/eigen",
267 ],
268)
269
270cc_test(
271 name = "spline_test",
272 srcs = [
273 "spline_test.cc",
274 ],
275 restricted_to = ["//tools:k8"],
276 deps = [
277 ":spline",
278 "//aos/testing:googletest",
279 "//third_party/matplotlib-cpp",
280 "@com_github_gflags_gflags//:gflags",
281 ],
282)
Austin Schuh941b46d2018-12-19 18:06:05 +1100283
284cc_library(
285 name = "distance_spline",
286 srcs = ["distance_spline.cc"],
287 hdrs = ["distance_spline.h"],
288 deps = [
289 ":spline",
290 "//frc971/control_loops:fixed_quadrature",
291 "//third_party/eigen",
292 ],
293)
294
295cc_test(
296 name = "distance_spline_test",
297 srcs = [
298 "distance_spline_test.cc",
299 ],
300 restricted_to = ["//tools:k8"],
301 deps = [
302 ":distance_spline",
303 "//aos/testing:googletest",
304 "//third_party/matplotlib-cpp",
305 "@com_github_gflags_gflags//:gflags",
306 ],
307)
Austin Schuhec7f06d2019-01-04 07:47:15 +1100308
309cc_library(
310 name = "trajectory",
311 srcs = ["trajectory.cc"],
312 hdrs = ["trajectory.h"],
313 deps = [
314 ":distance_spline",
315 ":drivetrain_config",
316 "//aos/logging:matrix_logging",
317 "//frc971/control_loops:c2d",
318 "//frc971/control_loops:dlqr",
319 "//frc971/control_loops:hybrid_state_feedback_loop",
320 "//frc971/control_loops:runge_kutta",
321 "//frc971/control_loops:state_feedback_loop",
322 "//third_party/eigen",
323 ],
324)
325
326cc_binary(
327 name = "trajectory_plot",
328 srcs = [
329 "trajectory_plot.cc",
330 ],
331 restricted_to = ["//tools:k8"],
332 deps = [
333 ":distance_spline",
334 ":trajectory",
335 "//aos/logging:implementations",
336 "//aos/logging:matrix_logging",
337 "//aos/network:team_number",
338 "//third_party/eigen",
339 "//third_party/matplotlib-cpp",
340 "//y2016/control_loops/drivetrain:drivetrain_base",
341 "@com_github_gflags_gflags//:gflags",
342 ],
343)
344
345cc_test(
346 name = "trajectory_test",
347 srcs = [
348 "trajectory_test.cc",
349 ],
Austin Schuh719a33e2019-01-07 15:13:34 -0800350 defines =
351 cpu_select({
352 "amd64": [
353 "SUPPORT_PLOT=1",
354 ],
355 "arm": [],
356 }),
357 linkstatic = True,
Austin Schuhec7f06d2019-01-04 07:47:15 +1100358 deps = [
359 ":trajectory",
360 "//aos/testing:googletest",
361 "//aos/testing:test_shm",
362 "//y2016:constants",
363 "//y2016/control_loops/drivetrain:polydrivetrain_plants",
Austin Schuh719a33e2019-01-07 15:13:34 -0800364 ] + cpu_select({
365 "amd64": [
366 "//third_party/matplotlib-cpp",
367 ],
368 "arm": [],
369 }),
Austin Schuhec7f06d2019-01-04 07:47:15 +1100370)