blob: 9f7eae8618fdaa0282223edbf231c7585aa97ffd [file] [log] [blame]
Austin Schuha1d006e2022-09-14 21:50:42 -07001load("@com_github_google_flatbuffers//:build_defs.bzl", "flatbuffer_cc_library")
2load("@com_github_google_flatbuffers//:typescript.bzl", "flatbuffer_ts_library")
Alex Perrycb7da4b2019-08-28 19:35:56 -07003load("//aos:config.bzl", "aos_config")
Philipp Schraderdada1072020-11-24 11:34:46 -08004load("//tools/build_rules:select.bzl", "cpu_select")
Austin Schuh41fad8c2021-10-23 21:25:12 -07005load("//aos:flatbuffers.bzl", "cc_static_flatbuffer")
Philipp Schrader87277f42022-01-01 07:45:12 -08006load("@npm//@bazel/typescript:index.bzl", "ts_library")
Comran Morshed5323ecb2015-12-26 20:50:55 +00007
Philipp Schradercc016b32021-12-30 08:59:58 -08008package(default_visibility = ["//visibility:public"])
9
Alex Perrycb7da4b2019-08-28 19:35:56 -070010flatbuffer_cc_library(
James Kuszmaul75a18c52021-03-10 22:02:07 -080011 name = "spline_goal_fbs",
12 srcs = ["spline_goal.fbs"],
13 gen_reflections = 1,
14 includes = ["//frc971/control_loops:control_loops_fbs_includes"],
15)
16
17flatbuffer_cc_library(
Alex Perrycb7da4b2019-08-28 19:35:56 -070018 name = "drivetrain_goal_fbs",
19 srcs = ["drivetrain_goal.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -070020 gen_reflections = 1,
James Kuszmaul75a18c52021-03-10 22:02:07 -080021 includes = [
22 ":spline_goal_fbs_includes",
23 "//frc971/control_loops:control_loops_fbs_includes",
24 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +000025)
26
Alex Perrycb7da4b2019-08-28 19:35:56 -070027flatbuffer_cc_library(
28 name = "drivetrain_output_fbs",
29 srcs = ["drivetrain_output.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -070030 gen_reflections = 1,
31)
32
33flatbuffer_cc_library(
34 name = "drivetrain_position_fbs",
35 srcs = ["drivetrain_position.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -070036 gen_reflections = 1,
37)
38
39flatbuffer_cc_library(
40 name = "drivetrain_status_fbs",
41 srcs = ["drivetrain_status.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -070042 gen_reflections = 1,
43 includes = ["//frc971/control_loops:control_loops_fbs_includes"],
44)
45
James Kuszmaul75a18c52021-03-10 22:02:07 -080046flatbuffer_cc_library(
47 name = "trajectory_fbs",
48 srcs = ["trajectory.fbs"],
49 gen_reflections = 1,
50 includes = ["//frc971/control_loops:control_loops_fbs_includes"],
51)
52
Austin Schuh41fad8c2021-10-23 21:25:12 -070053cc_static_flatbuffer(
54 name = "trajectory_schema",
55 function = "frc971::control_loops::drivetrain::fb::TrajectorySchema",
56 target = ":trajectory_fbs_reflection_out",
57 visibility = ["//visibility:public"],
58)
59
Alex Perry2124ae82020-03-07 14:19:06 -080060flatbuffer_ts_library(
61 name = "drivetrain_status_ts_fbs",
62 srcs = ["drivetrain_status.fbs"],
Philipp Schraderdada1072020-11-24 11:34:46 -080063 target_compatible_with = ["@platforms//os:linux"],
James Kuszmauldac091f2022-03-22 09:35:06 -070064 deps = ["//frc971/control_loops:control_loops_ts_fbs"],
Alex Perry2124ae82020-03-07 14:19:06 -080065)
66
Alex Perrycb7da4b2019-08-28 19:35:56 -070067genrule(
68 name = "drivetrain_goal_float_fbs_generated",
69 srcs = ["drivetrain_goal.fbs"],
70 outs = ["drivetrain_goal_float.fbs"],
71 cmd = "cat $(SRCS) | sed 's/double/float/g' > $(OUTS)",
Alex Perrycb7da4b2019-08-28 19:35:56 -070072)
73
74genrule(
75 name = "drivetrain_position_float_fbs_generated",
76 srcs = ["drivetrain_position.fbs"],
77 outs = ["drivetrain_position_float.fbs"],
78 cmd = "cat $(SRCS) | sed 's/double/float/g' > $(OUTS)",
Alex Perrycb7da4b2019-08-28 19:35:56 -070079)
80
81genrule(
82 name = "drivetrain_output_float_fbs_generated",
83 srcs = ["drivetrain_output.fbs"],
84 outs = ["drivetrain_output_float.fbs"],
85 cmd = "cat $(SRCS) | sed 's/double/float/g' > $(OUTS)",
Alex Perrycb7da4b2019-08-28 19:35:56 -070086)
87
88genrule(
89 name = "drivetrain_status_float_fbs_generated",
90 srcs = ["drivetrain_status.fbs"],
91 outs = ["drivetrain_status_float.fbs"],
92 cmd = "cat $(SRCS) | sed 's/double/float/g' > $(OUTS)",
Alex Perrycb7da4b2019-08-28 19:35:56 -070093)
94
95flatbuffer_cc_library(
96 name = "drivetrain_goal_float_fbs",
97 srcs = ["drivetrain_goal_float.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -070098 gen_reflections = 1,
James Kuszmaul75a18c52021-03-10 22:02:07 -080099 includes = [
100 ":spline_goal_fbs_includes",
101 "//frc971/control_loops:control_loops_fbs_includes",
102 ],
Alex Perrycb7da4b2019-08-28 19:35:56 -0700103)
104
105flatbuffer_cc_library(
106 name = "drivetrain_output_float_fbs",
107 srcs = ["drivetrain_output_float.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -0700108 gen_reflections = 1,
109)
110
111flatbuffer_cc_library(
112 name = "drivetrain_position_float_fbs",
113 srcs = ["drivetrain_position_float.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -0700114 gen_reflections = 1,
115)
116
117flatbuffer_cc_library(
118 name = "drivetrain_status_float_fbs",
119 srcs = ["drivetrain_status_float.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -0700120 gen_reflections = 1,
121 includes = ["//frc971/control_loops:control_loops_fbs_includes"],
122)
123
124aos_config(
James Kuszmaul74d8f972020-02-11 17:13:17 -0800125 name = "simulation_channels",
126 src = "drivetrain_simulation_channels.json",
127 flatbuffers = [
128 ":drivetrain_status_fbs",
129 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800130 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul74d8f972020-02-11 17:13:17 -0800131 visibility = ["//visibility:public"],
132)
133
134aos_config(
135 name = "simulation_config",
136 src = "drivetrain_simulation_config.json",
Philipp Schraderdada1072020-11-24 11:34:46 -0800137 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul74d8f972020-02-11 17:13:17 -0800138 visibility = ["//visibility:public"],
139 deps = [
Austin Schuhc5fa6d92022-02-25 14:36:28 -0800140 ":aos_config",
James Kuszmaul74d8f972020-02-11 17:13:17 -0800141 ":simulation_channels",
142 ],
143)
144
145aos_config(
Austin Schuhc5fa6d92022-02-25 14:36:28 -0800146 name = "aos_config",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700147 src = "drivetrain_config.json",
148 flatbuffers = [
149 ":drivetrain_goal_fbs",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800150 ":trajectory_fbs",
151 ":spline_goal_fbs",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700152 ":drivetrain_output_fbs",
153 ":drivetrain_status_fbs",
154 ":drivetrain_position_fbs",
155 ":localizer_fbs",
Tyler Chatow24b5db12020-01-06 21:16:56 -0800156 "//frc971/queues:gyro_fbs",
157 "//frc971/queues:gyro_uid_fbs",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700158 "//frc971/wpilib:imu_fbs",
Austin Schuhac17fba2020-03-28 15:55:33 -0700159 "//frc971/wpilib:imu_batch_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700160 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800161 target_compatible_with = ["@platforms//os:linux"],
Alex Perrycb7da4b2019-08-28 19:35:56 -0700162 visibility = ["//visibility:public"],
Austin Schuhbcce26a2018-03-26 23:41:24 -0700163 deps = [
Austin Schuhc5fa6d92022-02-25 14:36:28 -0800164 "//frc971/input:aos_config",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700165 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000166)
167
168cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700169 name = "drivetrain_config",
170 hdrs = [
171 "drivetrain_config.h",
172 ],
173 deps = [
174 "//frc971:shifter_hall_effect",
175 "//frc971/control_loops:state_feedback_loop",
Philipp Schraderdada1072020-11-24 11:34:46 -0800176 ] + select({
177 "@platforms//os:linux": ["//frc971/control_loops:hybrid_state_feedback_loop"],
178 "//conditions:default": [],
179 }),
Comran Morshed5323ecb2015-12-26 20:50:55 +0000180)
181
182cc_library(
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800183 name = "hybrid_ekf",
184 hdrs = ["hybrid_ekf.h"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800185 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800186 deps = [
187 ":drivetrain_config",
James Kuszmaul3c5b4d32020-02-11 17:22:14 -0800188 "//aos:math",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800189 "//aos/containers:priority_queue",
James Kuszmaulfedc4612019-03-10 11:24:51 -0700190 "//aos/util:math",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800191 "//frc971/control_loops:c2d",
192 "//frc971/control_loops:runge_kutta",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700193 "@org_tuxfamily_eigen//:eigen",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800194 ],
195)
196
197cc_test(
198 name = "hybrid_ekf_test",
199 srcs = ["hybrid_ekf_test.cc"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800200 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800201 deps = [
202 ":drivetrain_test_lib",
203 ":hybrid_ekf",
204 ":trajectory",
205 "//aos/testing:googletest",
206 "//aos/testing:random_seed",
207 "//aos/testing:test_shm",
208 ],
209)
210
Alex Perrycb7da4b2019-08-28 19:35:56 -0700211flatbuffer_cc_library(
212 name = "localizer_fbs",
213 srcs = ["localizer.fbs"],
214 gen_reflections = 1,
Philipp Schraderdada1072020-11-24 11:34:46 -0800215 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaulef428a02019-03-02 22:19:41 -0800216)
217
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800218cc_library(
James Kuszmaul3431d622019-02-17 17:07:44 -0800219 name = "localizer",
220 hdrs = ["localizer.h"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800221 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul3431d622019-02-17 17:07:44 -0800222 deps = [
223 ":drivetrain_config",
James Kuszmaul3c5b4d32020-02-11 17:22:14 -0800224 ":drivetrain_status_fbs",
James Kuszmaul3431d622019-02-17 17:07:44 -0800225 ":hybrid_ekf",
James Kuszmaul5398fae2020-02-17 16:44:03 -0800226 "//frc971/control_loops:control_loops_fbs",
James Kuszmaul5bc6fc92019-03-01 21:50:06 -0800227 "//frc971/control_loops:pose",
James Kuszmaul3431d622019-02-17 17:07:44 -0800228 ],
229)
230
231cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700232 name = "gear",
233 hdrs = [
234 "gear.h",
235 ],
Austin Schuh093535c2016-03-05 23:21:00 -0800236)
237
238cc_library(
Alex Perry731b4602019-02-02 22:13:01 -0800239 name = "splinedrivetrain",
240 srcs = [
241 "splinedrivetrain.cc",
242 ],
243 hdrs = [
244 "splinedrivetrain.h",
245 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800246 target_compatible_with = ["@platforms//os:linux"],
Alex Perry731b4602019-02-02 22:13:01 -0800247 deps = [
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800248 ":distance_spline",
Alex Perry731b4602019-02-02 22:13:01 -0800249 ":drivetrain_config",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700250 ":drivetrain_goal_fbs",
251 ":drivetrain_output_fbs",
252 ":drivetrain_status_fbs",
Alex Perry731b4602019-02-02 22:13:01 -0800253 ":spline",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800254 ":spline_goal_fbs",
Alex Perry731b4602019-02-02 22:13:01 -0800255 ":trajectory",
Austin Schuh3d9ccd72020-08-01 15:42:40 -0700256 "//aos:condition",
Alex Perry1ec34522019-02-17 22:44:10 -0800257 "//aos:init",
James Kuszmaulc73bb222019-04-07 12:15:35 -0700258 "//aos/util:math",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700259 "//frc971/control_loops:control_loops_fbs",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800260 ],
Alex Perry731b4602019-02-02 22:13:01 -0800261)
262
263cc_library(
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800264 name = "line_follow_drivetrain",
265 srcs = [
266 "line_follow_drivetrain.cc",
267 ],
268 hdrs = [
269 "line_follow_drivetrain.h",
270 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800271 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800272 deps = [
273 ":drivetrain_config",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700274 ":drivetrain_goal_fbs",
275 ":drivetrain_output_fbs",
276 ":drivetrain_status_fbs",
James Kuszmaul5bc6fc92019-03-01 21:50:06 -0800277 ":localizer",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800278 ":spline_goal_fbs",
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800279 "//aos:math",
280 "//aos/util:math",
281 "//frc971/control_loops:c2d",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700282 "//frc971/control_loops:control_loops_fbs",
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800283 "//frc971/control_loops:dlqr",
284 "//frc971/control_loops:pose",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700285 "//frc971/control_loops:profiled_subsystem_fbs",
286 "//y2019/control_loops/superstructure:superstructure_goal_fbs",
287 "@org_tuxfamily_eigen//:eigen",
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800288 ],
289)
290
291cc_test(
292 name = "line_follow_drivetrain_test",
293 srcs = ["line_follow_drivetrain_test.cc"],
294 linkstatic = True,
Philipp Schraderdada1072020-11-24 11:34:46 -0800295 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800296 deps = [
297 ":drivetrain_config",
298 ":drivetrain_test_lib",
299 ":line_follow_drivetrain",
300 ":trajectory",
301 "//aos/testing:googletest",
302 "//aos/testing:test_shm",
303 "//third_party/matplotlib-cpp",
304 "@com_github_gflags_gflags//:gflags",
305 ],
306)
307
308cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700309 name = "ssdrivetrain",
310 srcs = [
311 "ssdrivetrain.cc",
312 ],
313 hdrs = [
314 "ssdrivetrain.h",
315 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800316 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhbcce26a2018-03-26 23:41:24 -0700317 deps = [
318 ":drivetrain_config",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700319 ":drivetrain_goal_fbs",
320 ":drivetrain_output_fbs",
Austin Schuh95771d92021-01-23 14:42:25 -0800321 ":drivetrain_states",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700322 ":drivetrain_status_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700323 ":gear",
James Kuszmaul3431d622019-02-17 17:07:44 -0800324 ":localizer",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800325 ":spline_goal_fbs",
John Park33858a32018-09-28 23:05:48 -0700326 "//aos:math",
John Park33858a32018-09-28 23:05:48 -0700327 "//aos/util:log_interval",
328 "//aos/util:trapezoid_profile",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700329 "//frc971:shifter_hall_effect",
330 "//frc971/control_loops:coerce_goal",
Austin Schuh0a3c9d42021-07-15 22:36:24 -0700331 "//frc971/control_loops:control_loop",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700332 "//frc971/control_loops:control_loops_fbs",
Austin Schuh0a3c9d42021-07-15 22:36:24 -0700333 "//frc971/control_loops:polytope",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700334 "//frc971/control_loops:state_feedback_loop",
Austin Schuh0a3c9d42021-07-15 22:36:24 -0700335 "//frc971/input:robot_state_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700336 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000337)
338
339cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700340 name = "polydrivetrain",
341 srcs = [
342 "polydrivetrain.cc",
343 ],
344 hdrs = [
345 "polydrivetrain.h",
346 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800347 copts = select({
348 "@platforms//os:none": ["-Wno-type-limits"],
349 "//conditions:default": [],
350 }),
Austin Schuhbcce26a2018-03-26 23:41:24 -0700351 deps = [
352 ":drivetrain_config",
Austin Schuh95771d92021-01-23 14:42:25 -0800353 ":drivetrain_states",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700354 ":gear",
John Park33858a32018-09-28 23:05:48 -0700355 "//aos:math",
James Kuszmaul61750662021-06-21 21:32:33 -0700356 "//frc971/control_loops:polytope",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700357 "//frc971/control_loops:coerce_goal",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700358 "//frc971/control_loops:control_loops_fbs",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800359 ":spline_goal_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700360 "//frc971/control_loops:state_feedback_loop",
Philipp Schraderdada1072020-11-24 11:34:46 -0800361 ] + select({
362 "@platforms//os:linux": [
363 ":drivetrain_goal_fbs",
364 ":drivetrain_output_fbs",
365 ":drivetrain_position_fbs",
366 ":drivetrain_status_fbs",
James Kuszmaul7077d342021-06-09 20:23:58 -0700367 "//frc971/input:robot_state_fbs",
Philipp Schraderdada1072020-11-24 11:34:46 -0800368 "//aos/util:log_interval",
369 ],
370 "@platforms//os:none": [
371 ":drivetrain_goal_float_fbs",
372 ":drivetrain_output_float_fbs",
373 ":drivetrain_position_float_fbs",
374 ":drivetrain_status_float_fbs",
375 ],
376 }),
Comran Morshed5323ecb2015-12-26 20:50:55 +0000377)
378
Austin Schuh05c5a612016-04-02 15:10:25 -0700379genrule(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700380 name = "genrule_down_estimator",
381 outs = [
382 "down_estimator.h",
383 "down_estimator.cc",
384 ],
385 cmd = "$(location //frc971/control_loops/python:down_estimator) $(OUTS)",
Philipp Schraderdada1072020-11-24 11:34:46 -0800386 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhbcce26a2018-03-26 23:41:24 -0700387 tools = [
388 "//frc971/control_loops/python:down_estimator",
389 ],
390 visibility = ["//visibility:private"],
Austin Schuh05c5a612016-04-02 15:10:25 -0700391)
392
393cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700394 name = "down_estimator",
395 srcs = [
396 "down_estimator.cc",
397 ],
398 hdrs = [
399 "down_estimator.h",
400 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800401 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhbcce26a2018-03-26 23:41:24 -0700402 deps = [
403 "//frc971/control_loops:state_feedback_loop",
404 ],
Austin Schuh05c5a612016-04-02 15:10:25 -0700405)
406
Comran Morshed5323ecb2015-12-26 20:50:55 +0000407cc_library(
Austin Schuh95771d92021-01-23 14:42:25 -0800408 name = "drivetrain_states",
409 hdrs = ["drivetrain_states.h"],
410)
411
412cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700413 name = "drivetrain_lib",
414 srcs = [
415 "drivetrain.cc",
416 ],
417 hdrs = [
418 "drivetrain.h",
419 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800420 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhbcce26a2018-03-26 23:41:24 -0700421 deps = [
422 ":down_estimator",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700423 ":drivetrain_goal_fbs",
424 ":drivetrain_output_fbs",
425 ":drivetrain_position_fbs",
Austin Schuh95771d92021-01-23 14:42:25 -0800426 ":drivetrain_states",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700427 ":drivetrain_status_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700428 ":gear",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800429 ":improved_down_estimator",
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800430 ":line_follow_drivetrain",
James Kuszmaul3431d622019-02-17 17:07:44 -0800431 ":localizer",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700432 ":localizer_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700433 ":polydrivetrain",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800434 ":spline_goal_fbs",
Alex Perry731b4602019-02-02 22:13:01 -0800435 ":splinedrivetrain",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800436 ":ssdrivetrain",
John Park33858a32018-09-28 23:05:48 -0700437 "//aos/util:log_interval",
Austin Schuh0a3c9d42021-07-15 22:36:24 -0700438 "//frc971/control_loops:control_loop",
Austin Schuh3a378462019-01-04 21:48:04 -0800439 "//frc971/control_loops:runge_kutta",
Tyler Chatow24b5db12020-01-06 21:16:56 -0800440 "//frc971/queues:gyro_fbs",
Austin Schuhac17fba2020-03-28 15:55:33 -0700441 "//frc971/wpilib:imu_batch_fbs",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700442 "//frc971/wpilib:imu_fbs",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800443 "//frc971/zeroing:imu_zeroer",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700444 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000445)
446
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800447cc_library(
448 name = "drivetrain_test_lib",
449 testonly = True,
450 srcs = ["drivetrain_test_lib.cc"],
451 hdrs = ["drivetrain_test_lib.h"],
James Kuszmaul74d8f972020-02-11 17:13:17 -0800452 defines =
453 cpu_select({
454 "amd64": [
455 "SUPPORT_PLOT=1",
456 ],
457 "arm": [],
458 }),
Philipp Schraderdada1072020-11-24 11:34:46 -0800459 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800460 deps = [
461 ":drivetrain_config",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700462 ":drivetrain_goal_fbs",
463 ":drivetrain_output_fbs",
464 ":drivetrain_position_fbs",
465 ":drivetrain_status_fbs",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800466 ":trajectory",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700467 "//aos/events:event_loop",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800468 "//aos/testing:googletest",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700469 "//frc971/control_loops:control_loops_fbs",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800470 "//frc971/control_loops:state_feedback_loop",
Tyler Chatow24b5db12020-01-06 21:16:56 -0800471 "//frc971/queues:gyro_fbs",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800472 "//frc971/wpilib:imu_fbs",
Austin Schuhac17fba2020-03-28 15:55:33 -0700473 "//frc971/wpilib:imu_batch_fbs",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800474 "//y2016:constants",
475 "//y2016/control_loops/drivetrain:polydrivetrain_plants",
James Kuszmaul74d8f972020-02-11 17:13:17 -0800476 ] + cpu_select({
477 "amd64": [
478 "//third_party/matplotlib-cpp",
479 ],
480 "arm": [],
481 }),
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800482)
483
Comran Morshed5323ecb2015-12-26 20:50:55 +0000484cc_test(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700485 name = "drivetrain_lib_test",
486 srcs = [
487 "drivetrain_lib_test.cc",
488 ],
Austin Schuh14d7d3d2020-09-10 18:14:36 -0700489 data = [":simulation_config"],
Alex Perry04300d62019-02-17 14:37:04 -0800490 defines =
491 cpu_select({
492 "amd64": [
493 "SUPPORT_PLOT=1",
494 ],
495 "arm": [],
496 }),
497 linkstatic = True,
Philipp Schraderdada1072020-11-24 11:34:46 -0800498 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhbcce26a2018-03-26 23:41:24 -0700499 deps = [
500 ":drivetrain_config",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800501 ":trajectory_generator",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700502 ":drivetrain_lib",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700503 ":localizer_fbs",
504 ":drivetrain_goal_fbs",
505 ":drivetrain_status_fbs",
506 ":drivetrain_position_fbs",
507 ":drivetrain_output_fbs",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800508 ":drivetrain_test_lib",
James Kuszmaul61750662021-06-21 21:32:33 -0700509 "//frc971/control_loops:control_loop_test",
Austin Schuhb06f03b2021-02-17 22:00:37 -0800510 "//aos/events/logging:log_writer",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700511 "//aos/testing:googletest",
Tyler Chatow24b5db12020-01-06 21:16:56 -0800512 "//frc971/queues:gyro_fbs",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800513 "//frc971/wpilib:imu_fbs",
Alex Perry04300d62019-02-17 14:37:04 -0800514 ] + cpu_select({
515 "amd64": [
516 "//third_party/matplotlib-cpp",
517 ],
518 "arm": [],
519 }),
Comran Morshed5323ecb2015-12-26 20:50:55 +0000520)
Brian Silverman6260c092018-01-14 15:21:36 -0800521
522genrule(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700523 name = "genrule_haptic_wheel",
524 outs = [
525 "haptic_wheel.h",
526 "haptic_wheel.cc",
527 "integral_haptic_wheel.h",
528 "integral_haptic_wheel.cc",
529 "haptic_trigger.h",
530 "haptic_trigger.cc",
531 "integral_haptic_trigger.h",
532 "integral_haptic_trigger.cc",
533 ],
534 cmd = "$(location //frc971/control_loops/python:haptic_wheel) $(OUTS)",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700535 tools = [
536 "//frc971/control_loops/python:haptic_wheel",
537 ],
538 visibility = ["//visibility:private"],
Brian Silverman6260c092018-01-14 15:21:36 -0800539)
540
541cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700542 name = "haptic_wheel",
543 srcs = [
544 "haptic_trigger.cc",
545 "haptic_wheel.cc",
546 "integral_haptic_trigger.cc",
547 "integral_haptic_wheel.cc",
548 ],
549 hdrs = [
550 "haptic_trigger.h",
551 "haptic_wheel.h",
552 "integral_haptic_trigger.h",
553 "integral_haptic_wheel.h",
554 ],
555 deps = [
556 "//frc971/control_loops:state_feedback_loop",
557 ],
Brian Silverman6260c092018-01-14 15:21:36 -0800558)
Austin Schuhc2b08772018-12-19 18:05:06 +1100559
560cc_library(
561 name = "spline",
562 srcs = ["spline.cc"],
563 hdrs = ["spline.h"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800564 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhc2b08772018-12-19 18:05:06 +1100565 deps = [
Austin Schuhf49b4e32019-01-13 17:26:58 -0800566 "//frc971/control_loops:binomial",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700567 "@org_tuxfamily_eigen//:eigen",
Austin Schuhc2b08772018-12-19 18:05:06 +1100568 ],
569)
570
Alex Perrya60da442019-01-21 19:00:27 -0500571cc_binary(
572 name = "spline.so",
573 srcs = ["libspline.cc"],
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800574 linkshared = True,
Philipp Schraderdada1072020-11-24 11:34:46 -0800575 target_compatible_with = ["@platforms//os:linux"],
Alex Perrya60da442019-01-21 19:00:27 -0500576 deps = [
577 ":distance_spline",
578 ":spline",
Alex Perry0603b542019-01-25 20:29:51 -0800579 ":trajectory",
580 "//aos/logging:implementations",
581 "//aos/network:team_number",
James Kuszmaul8aa37cb2020-03-01 10:27:58 -0800582 "//y2020/control_loops/drivetrain:drivetrain_base",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700583 "@org_tuxfamily_eigen//:eigen",
Alex Perrya60da442019-01-21 19:00:27 -0500584 ],
Alex Perrya60da442019-01-21 19:00:27 -0500585)
586
Austin Schuhc2b08772018-12-19 18:05:06 +1100587cc_test(
588 name = "spline_test",
589 srcs = [
590 "spline_test.cc",
591 ],
James Kuszmaule32fa932021-05-11 21:38:16 -0700592 linkstatic = True,
Philipp Schraderdada1072020-11-24 11:34:46 -0800593 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhc2b08772018-12-19 18:05:06 +1100594 deps = [
595 ":spline",
596 "//aos/testing:googletest",
James Kuszmaule32fa932021-05-11 21:38:16 -0700597 "//frc971/analysis:in_process_plotter",
Austin Schuhc2b08772018-12-19 18:05:06 +1100598 "@com_github_gflags_gflags//:gflags",
599 ],
600)
Austin Schuh941b46d2018-12-19 18:06:05 +1100601
602cc_library(
603 name = "distance_spline",
604 srcs = ["distance_spline.cc"],
605 hdrs = ["distance_spline.h"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800606 target_compatible_with = ["@platforms//os:linux"],
Austin Schuh941b46d2018-12-19 18:06:05 +1100607 deps = [
608 ":spline",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800609 ":trajectory_fbs",
Austin Schuha6e7b212019-01-20 13:53:01 -0800610 "//aos/logging",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800611 "//frc971/control_loops:control_loops_fbs",
Austin Schuh941b46d2018-12-19 18:06:05 +1100612 "//frc971/control_loops:fixed_quadrature",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800613 "@com_github_google_glog//:glog",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700614 "@org_tuxfamily_eigen//:eigen",
Austin Schuh941b46d2018-12-19 18:06:05 +1100615 ],
616)
617
618cc_test(
619 name = "distance_spline_test",
620 srcs = [
621 "distance_spline_test.cc",
622 ],
Austin Schuh9b0b6432019-01-13 21:15:17 -0800623 defines =
624 cpu_select({
625 "amd64": [
626 "SUPPORT_PLOT=1",
627 ],
628 "arm": [],
629 }),
630 linkstatic = True,
Philipp Schraderdada1072020-11-24 11:34:46 -0800631 target_compatible_with = ["@platforms//os:linux"],
Austin Schuh941b46d2018-12-19 18:06:05 +1100632 deps = [
633 ":distance_spline",
634 "//aos/testing:googletest",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800635 "//aos:flatbuffers",
Austin Schuha6e7b212019-01-20 13:53:01 -0800636 "//aos/testing:test_shm",
Austin Schuh941b46d2018-12-19 18:06:05 +1100637 "@com_github_gflags_gflags//:gflags",
Austin Schuh9b0b6432019-01-13 21:15:17 -0800638 ] + cpu_select({
639 "amd64": [
640 "//third_party/matplotlib-cpp",
641 ],
642 "arm": [],
643 }),
Austin Schuh941b46d2018-12-19 18:06:05 +1100644)
Austin Schuhec7f06d2019-01-04 07:47:15 +1100645
646cc_library(
647 name = "trajectory",
648 srcs = ["trajectory.cc"],
649 hdrs = ["trajectory.h"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800650 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhec7f06d2019-01-04 07:47:15 +1100651 deps = [
652 ":distance_spline",
653 ":drivetrain_config",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800654 ":spline_goal_fbs",
655 ":trajectory_fbs",
James Kuszmaul5e8ce312021-03-27 14:59:17 -0700656 "//aos/util:math",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100657 "//frc971/control_loops:c2d",
658 "//frc971/control_loops:dlqr",
659 "//frc971/control_loops:hybrid_state_feedback_loop",
660 "//frc971/control_loops:runge_kutta",
661 "//frc971/control_loops:state_feedback_loop",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700662 "@org_tuxfamily_eigen//:eigen",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100663 ],
664)
665
James Kuszmaul75a18c52021-03-10 22:02:07 -0800666cc_library(
667 name = "trajectory_generator",
668 srcs = ["trajectory_generator.cc"],
669 hdrs = ["trajectory_generator.h"],
670 target_compatible_with = ["@platforms//os:linux"],
671 deps = [
672 ":distance_spline",
673 ":drivetrain_config",
674 ":spline_goal_fbs",
675 ":trajectory",
676 ":trajectory_fbs",
677 ],
678)
679
Austin Schuhec7f06d2019-01-04 07:47:15 +1100680cc_binary(
681 name = "trajectory_plot",
682 srcs = [
683 "trajectory_plot.cc",
684 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800685 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhec7f06d2019-01-04 07:47:15 +1100686 deps = [
687 ":distance_spline",
688 ":trajectory",
689 "//aos/logging:implementations",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100690 "//aos/network:team_number",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100691 "//third_party/matplotlib-cpp",
Austin Schuh11043182019-03-23 22:29:12 -0700692 "//y2019/control_loops/drivetrain:drivetrain_base",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100693 "@com_github_gflags_gflags//:gflags",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700694 "@org_tuxfamily_eigen//:eigen",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100695 ],
696)
697
698cc_test(
699 name = "trajectory_test",
700 srcs = [
701 "trajectory_test.cc",
702 ],
Austin Schuh719a33e2019-01-07 15:13:34 -0800703 defines =
704 cpu_select({
705 "amd64": [
706 "SUPPORT_PLOT=1",
707 ],
708 "arm": [],
709 }),
710 linkstatic = True,
Philipp Schraderdada1072020-11-24 11:34:46 -0800711 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhec7f06d2019-01-04 07:47:15 +1100712 deps = [
713 ":trajectory",
James Kuszmaulea314d92019-02-18 19:45:06 -0800714 ":drivetrain_test_lib",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100715 "//aos/testing:googletest",
716 "//aos/testing:test_shm",
717 "//y2016:constants",
718 "//y2016/control_loops/drivetrain:polydrivetrain_plants",
James Kuszmaulea314d92019-02-18 19:45:06 -0800719 "//y2019/control_loops/drivetrain:drivetrain_base",
Austin Schuh719a33e2019-01-07 15:13:34 -0800720 ] + cpu_select({
721 "amd64": [
722 "//third_party/matplotlib-cpp",
723 ],
724 "arm": [],
725 }),
Austin Schuhec7f06d2019-01-04 07:47:15 +1100726)
Austin Schuhca080812017-05-10 19:31:55 -0700727
728cc_library(
729 name = "improved_down_estimator",
730 srcs = [
731 "improved_down_estimator.cc",
732 ],
733 hdrs = [
734 "improved_down_estimator.h",
735 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800736 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhca080812017-05-10 19:31:55 -0700737 deps = [
James Kuszmaul7f55f072020-03-01 10:21:26 -0800738 ":drivetrain_config",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800739 ":drivetrain_status_fbs",
740 "//aos/events:event_loop",
741 "//frc971/control_loops:control_loops_fbs",
Austin Schuh0a3c9d42021-07-15 22:36:24 -0700742 "//frc971/control_loops:quaternion_utils",
Austin Schuhca080812017-05-10 19:31:55 -0700743 "//frc971/control_loops:runge_kutta",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800744 "@//aos/time",
Austin Schuhca080812017-05-10 19:31:55 -0700745 "@com_github_google_glog//:glog",
746 "@org_tuxfamily_eigen//:eigen",
747 ],
748)
749
750cc_test(
751 name = "improved_down_estimator_test",
752 srcs = [
753 "improved_down_estimator_test.cc",
754 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800755 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhca080812017-05-10 19:31:55 -0700756 deps = [
James Kuszmaul7f55f072020-03-01 10:21:26 -0800757 ":drivetrain_test_lib",
Austin Schuhca080812017-05-10 19:31:55 -0700758 "//aos/testing:googletest",
759 "//aos/testing:random_seed",
Austin Schuh0a3c9d42021-07-15 22:36:24 -0700760 "//frc971/control_loops:quaternion_utils",
Austin Schuhca080812017-05-10 19:31:55 -0700761 "//frc971/control_loops/drivetrain:improved_down_estimator",
762 "@org_tuxfamily_eigen//:eigen",
763 ],
764)
James Kuszmaulf4ede202020-02-14 08:47:40 -0800765
766cc_library(
767 name = "camera",
768 srcs = ["camera.h"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800769 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaulf4ede202020-02-14 08:47:40 -0800770 visibility = ["//visibility:public"],
771 deps = [
772 "//aos/containers:sized_array",
773 "//frc971/control_loops:pose",
774 ],
775)
776
777cc_test(
778 name = "camera_test",
779 srcs = ["camera_test.cc"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800780 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaulf4ede202020-02-14 08:47:40 -0800781 deps = [
782 ":camera",
783 "//aos/testing:googletest",
784 ],
785)
James Kuszmaulc4ae11c2020-12-26 16:26:58 -0800786
787ts_library(
James Kuszmaulac2b6b42021-03-07 22:38:06 -0800788 name = "down_estimator_plotter",
789 srcs = ["down_estimator_plotter.ts"],
790 target_compatible_with = ["@platforms//os:linux"],
791 deps = [
792 "//aos/network/www:aos_plotter",
793 "//aos/network/www:colors",
794 "//aos/network/www:proxy",
795 "//frc971/wpilib:imu_plot_utils",
796 ],
797)
798
799ts_library(
James Kuszmaul73fc1352021-04-09 22:31:25 -0700800 name = "spline_plotter",
801 srcs = ["spline_plotter.ts"],
802 target_compatible_with = ["@platforms//os:linux"],
803 deps = [
804 "//aos/network/www:aos_plotter",
805 "//aos/network/www:colors",
806 "//aos/network/www:proxy",
807 ],
808)
809
810ts_library(
James Kuszmaulc4ae11c2020-12-26 16:26:58 -0800811 name = "drivetrain_plotter",
812 srcs = ["drivetrain_plotter.ts"],
813 target_compatible_with = ["@platforms//os:linux"],
814 deps = [
815 "//aos/network/www:aos_plotter",
James Kuszmaul933a9742021-03-07 19:59:06 -0800816 "//aos/network/www:colors",
James Kuszmaulc4ae11c2020-12-26 16:26:58 -0800817 "//aos/network/www:proxy",
818 "//frc971/wpilib:imu_plot_utils",
819 ],
820)
milind upadhyay9bd381d2021-01-23 13:44:13 -0800821
822ts_library(
823 name = "robot_state_plotter",
824 srcs = ["robot_state_plotter.ts"],
825 target_compatible_with = ["@platforms//os:linux"],
826 deps = [
827 "//aos/network/www:aos_plotter",
James Kuszmaul933a9742021-03-07 19:59:06 -0800828 "//aos/network/www:colors",
milind upadhyay9bd381d2021-01-23 13:44:13 -0800829 "//aos/network/www:proxy",
830 ],
831)