blob: e631799afef7c826c6a56fbf22650050c508ef07 [file] [log] [blame]
Philipp Schrader3de4dfc2023-02-15 20:18:25 -08001load("//tools/build_rules:js.bzl", "ts_project")
Austin Schuha1d006e2022-09-14 21:50:42 -07002load("@com_github_google_flatbuffers//:build_defs.bzl", "flatbuffer_cc_library")
3load("@com_github_google_flatbuffers//:typescript.bzl", "flatbuffer_ts_library")
Alex Perrycb7da4b2019-08-28 19:35:56 -07004load("//aos:config.bzl", "aos_config")
Philipp Schraderdada1072020-11-24 11:34:46 -08005load("//tools/build_rules:select.bzl", "cpu_select")
Austin Schuh41fad8c2021-10-23 21:25:12 -07006load("//aos:flatbuffers.bzl", "cc_static_flatbuffer")
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(
Maxwell Hendersoncef6f042023-05-26 14:38:09 -070011 name = "drivetrain_can_position_fbs",
12 srcs = ["drivetrain_can_position.fbs"],
13 gen_reflections = 1,
Maxwell Hendersonca1d18f2023-07-26 21:06:14 -070014 deps = ["//frc971/control_loops:can_falcon_fbs"],
Maxwell Hendersoncef6f042023-05-26 14:38:09 -070015)
16
17flatbuffer_cc_library(
James Kuszmaul75a18c52021-03-10 22:02:07 -080018 name = "spline_goal_fbs",
19 srcs = ["spline_goal.fbs"],
20 gen_reflections = 1,
21 includes = ["//frc971/control_loops:control_loops_fbs_includes"],
22)
23
24flatbuffer_cc_library(
Alex Perrycb7da4b2019-08-28 19:35:56 -070025 name = "drivetrain_goal_fbs",
26 srcs = ["drivetrain_goal.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -070027 gen_reflections = 1,
James Kuszmaul75a18c52021-03-10 22:02:07 -080028 includes = [
29 ":spline_goal_fbs_includes",
30 "//frc971/control_loops:control_loops_fbs_includes",
31 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +000032)
33
Alex Perrycb7da4b2019-08-28 19:35:56 -070034flatbuffer_cc_library(
35 name = "drivetrain_output_fbs",
36 srcs = ["drivetrain_output.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -070037 gen_reflections = 1,
38)
39
40flatbuffer_cc_library(
41 name = "drivetrain_position_fbs",
42 srcs = ["drivetrain_position.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -070043 gen_reflections = 1,
44)
45
46flatbuffer_cc_library(
47 name = "drivetrain_status_fbs",
48 srcs = ["drivetrain_status.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -070049 gen_reflections = 1,
50 includes = ["//frc971/control_loops:control_loops_fbs_includes"],
51)
52
James Kuszmaul75a18c52021-03-10 22:02:07 -080053flatbuffer_cc_library(
54 name = "trajectory_fbs",
55 srcs = ["trajectory.fbs"],
56 gen_reflections = 1,
57 includes = ["//frc971/control_loops:control_loops_fbs_includes"],
58)
59
Austin Schuh41fad8c2021-10-23 21:25:12 -070060cc_static_flatbuffer(
61 name = "trajectory_schema",
62 function = "frc971::control_loops::drivetrain::fb::TrajectorySchema",
63 target = ":trajectory_fbs_reflection_out",
64 visibility = ["//visibility:public"],
65)
66
Alex Perry2124ae82020-03-07 14:19:06 -080067flatbuffer_ts_library(
68 name = "drivetrain_status_ts_fbs",
69 srcs = ["drivetrain_status.fbs"],
Philipp Schraderdada1072020-11-24 11:34:46 -080070 target_compatible_with = ["@platforms//os:linux"],
James Kuszmauldac091f2022-03-22 09:35:06 -070071 deps = ["//frc971/control_loops:control_loops_ts_fbs"],
Alex Perry2124ae82020-03-07 14:19:06 -080072)
73
Niko Sohmers76f47562023-12-20 20:59:06 -080074flatbuffer_ts_library(
75 name = "drivetrain_position_ts_fbs",
76 srcs = ["drivetrain_position.fbs"],
77 target_compatible_with = ["@platforms//os:linux"],
78)
79
80flatbuffer_ts_library(
81 name = "drivetrain_can_position_ts_fbs",
82 srcs = ["drivetrain_can_position.fbs"],
83 target_compatible_with = ["@platforms//os:linux"],
84 deps = ["//frc971/control_loops:can_falcon_ts_fbs"],
85)
86
Alex Perrycb7da4b2019-08-28 19:35:56 -070087genrule(
88 name = "drivetrain_goal_float_fbs_generated",
89 srcs = ["drivetrain_goal.fbs"],
90 outs = ["drivetrain_goal_float.fbs"],
91 cmd = "cat $(SRCS) | sed 's/double/float/g' > $(OUTS)",
Alex Perrycb7da4b2019-08-28 19:35:56 -070092)
93
94genrule(
95 name = "drivetrain_position_float_fbs_generated",
96 srcs = ["drivetrain_position.fbs"],
97 outs = ["drivetrain_position_float.fbs"],
98 cmd = "cat $(SRCS) | sed 's/double/float/g' > $(OUTS)",
Alex Perrycb7da4b2019-08-28 19:35:56 -070099)
100
101genrule(
102 name = "drivetrain_output_float_fbs_generated",
103 srcs = ["drivetrain_output.fbs"],
104 outs = ["drivetrain_output_float.fbs"],
105 cmd = "cat $(SRCS) | sed 's/double/float/g' > $(OUTS)",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700106)
107
108genrule(
109 name = "drivetrain_status_float_fbs_generated",
110 srcs = ["drivetrain_status.fbs"],
111 outs = ["drivetrain_status_float.fbs"],
112 cmd = "cat $(SRCS) | sed 's/double/float/g' > $(OUTS)",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700113)
114
115flatbuffer_cc_library(
116 name = "drivetrain_goal_float_fbs",
117 srcs = ["drivetrain_goal_float.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -0700118 gen_reflections = 1,
James Kuszmaul75a18c52021-03-10 22:02:07 -0800119 includes = [
120 ":spline_goal_fbs_includes",
121 "//frc971/control_loops:control_loops_fbs_includes",
122 ],
Alex Perrycb7da4b2019-08-28 19:35:56 -0700123)
124
125flatbuffer_cc_library(
126 name = "drivetrain_output_float_fbs",
127 srcs = ["drivetrain_output_float.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -0700128 gen_reflections = 1,
129)
130
131flatbuffer_cc_library(
132 name = "drivetrain_position_float_fbs",
133 srcs = ["drivetrain_position_float.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -0700134 gen_reflections = 1,
135)
136
137flatbuffer_cc_library(
138 name = "drivetrain_status_float_fbs",
139 srcs = ["drivetrain_status_float.fbs"],
Alex Perrycb7da4b2019-08-28 19:35:56 -0700140 gen_reflections = 1,
141 includes = ["//frc971/control_loops:control_loops_fbs_includes"],
142)
143
144aos_config(
James Kuszmaul74d8f972020-02-11 17:13:17 -0800145 name = "simulation_channels",
146 src = "drivetrain_simulation_channels.json",
147 flatbuffers = [
148 ":drivetrain_status_fbs",
149 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800150 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul74d8f972020-02-11 17:13:17 -0800151 visibility = ["//visibility:public"],
152)
153
154aos_config(
155 name = "simulation_config",
156 src = "drivetrain_simulation_config.json",
Philipp Schraderdada1072020-11-24 11:34:46 -0800157 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul74d8f972020-02-11 17:13:17 -0800158 visibility = ["//visibility:public"],
159 deps = [
Austin Schuhc5fa6d92022-02-25 14:36:28 -0800160 ":aos_config",
James Kuszmaul74d8f972020-02-11 17:13:17 -0800161 ":simulation_channels",
162 ],
163)
164
165aos_config(
Austin Schuhc5fa6d92022-02-25 14:36:28 -0800166 name = "aos_config",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700167 src = "drivetrain_config.json",
168 flatbuffers = [
169 ":drivetrain_goal_fbs",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800170 ":trajectory_fbs",
171 ":spline_goal_fbs",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700172 ":drivetrain_output_fbs",
173 ":drivetrain_status_fbs",
174 ":drivetrain_position_fbs",
175 ":localizer_fbs",
Tyler Chatow24b5db12020-01-06 21:16:56 -0800176 "//frc971/queues:gyro_fbs",
177 "//frc971/queues:gyro_uid_fbs",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700178 "//frc971/wpilib:imu_fbs",
Austin Schuhac17fba2020-03-28 15:55:33 -0700179 "//frc971/wpilib:imu_batch_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700180 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800181 target_compatible_with = ["@platforms//os:linux"],
Alex Perrycb7da4b2019-08-28 19:35:56 -0700182 visibility = ["//visibility:public"],
Austin Schuhbcce26a2018-03-26 23:41:24 -0700183 deps = [
Austin Schuhc5fa6d92022-02-25 14:36:28 -0800184 "//frc971/input:aos_config",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700185 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000186)
187
188cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700189 name = "drivetrain_config",
190 hdrs = [
191 "drivetrain_config.h",
192 ],
193 deps = [
194 "//frc971:shifter_hall_effect",
195 "//frc971/control_loops:state_feedback_loop",
Philipp Schraderdada1072020-11-24 11:34:46 -0800196 ] + select({
197 "@platforms//os:linux": ["//frc971/control_loops:hybrid_state_feedback_loop"],
198 "//conditions:default": [],
199 }),
Comran Morshed5323ecb2015-12-26 20:50:55 +0000200)
201
202cc_library(
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800203 name = "hybrid_ekf",
204 hdrs = ["hybrid_ekf.h"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800205 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800206 deps = [
207 ":drivetrain_config",
James Kuszmaul3c5b4d32020-02-11 17:22:14 -0800208 "//aos:math",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800209 "//aos/containers:priority_queue",
James Kuszmaulfedc4612019-03-10 11:24:51 -0700210 "//aos/util:math",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800211 "//frc971/control_loops:c2d",
212 "//frc971/control_loops:runge_kutta",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700213 "@org_tuxfamily_eigen//:eigen",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800214 ],
215)
216
217cc_test(
218 name = "hybrid_ekf_test",
219 srcs = ["hybrid_ekf_test.cc"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800220 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800221 deps = [
222 ":drivetrain_test_lib",
223 ":hybrid_ekf",
224 ":trajectory",
225 "//aos/testing:googletest",
226 "//aos/testing:random_seed",
227 "//aos/testing:test_shm",
228 ],
229)
230
Alex Perrycb7da4b2019-08-28 19:35:56 -0700231flatbuffer_cc_library(
232 name = "localizer_fbs",
233 srcs = ["localizer.fbs"],
234 gen_reflections = 1,
Philipp Schraderdada1072020-11-24 11:34:46 -0800235 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaulef428a02019-03-02 22:19:41 -0800236)
237
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800238cc_library(
James Kuszmaul3431d622019-02-17 17:07:44 -0800239 name = "localizer",
240 hdrs = ["localizer.h"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800241 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul3431d622019-02-17 17:07:44 -0800242 deps = [
243 ":drivetrain_config",
James Kuszmaul3c5b4d32020-02-11 17:22:14 -0800244 ":drivetrain_status_fbs",
James Kuszmaul3431d622019-02-17 17:07:44 -0800245 ":hybrid_ekf",
James Kuszmaul5398fae2020-02-17 16:44:03 -0800246 "//frc971/control_loops:control_loops_fbs",
James Kuszmaul5bc6fc92019-03-01 21:50:06 -0800247 "//frc971/control_loops:pose",
James Kuszmaul3431d622019-02-17 17:07:44 -0800248 ],
249)
250
251cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700252 name = "gear",
253 hdrs = [
254 "gear.h",
255 ],
Austin Schuh093535c2016-03-05 23:21:00 -0800256)
257
258cc_library(
Alex Perry731b4602019-02-02 22:13:01 -0800259 name = "splinedrivetrain",
260 srcs = [
261 "splinedrivetrain.cc",
262 ],
263 hdrs = [
264 "splinedrivetrain.h",
265 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800266 target_compatible_with = ["@platforms//os:linux"],
Alex Perry731b4602019-02-02 22:13:01 -0800267 deps = [
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800268 ":distance_spline",
Alex Perry731b4602019-02-02 22:13:01 -0800269 ":drivetrain_config",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700270 ":drivetrain_goal_fbs",
271 ":drivetrain_output_fbs",
272 ":drivetrain_status_fbs",
Alex Perry731b4602019-02-02 22:13:01 -0800273 ":spline",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800274 ":spline_goal_fbs",
Alex Perry731b4602019-02-02 22:13:01 -0800275 ":trajectory",
Austin Schuh3d9ccd72020-08-01 15:42:40 -0700276 "//aos:condition",
Alex Perry1ec34522019-02-17 22:44:10 -0800277 "//aos:init",
James Kuszmaulc73bb222019-04-07 12:15:35 -0700278 "//aos/util:math",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700279 "//frc971/control_loops:control_loops_fbs",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800280 ],
Alex Perry731b4602019-02-02 22:13:01 -0800281)
282
283cc_library(
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800284 name = "line_follow_drivetrain",
285 srcs = [
286 "line_follow_drivetrain.cc",
287 ],
288 hdrs = [
289 "line_follow_drivetrain.h",
290 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800291 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800292 deps = [
293 ":drivetrain_config",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700294 ":drivetrain_goal_fbs",
295 ":drivetrain_output_fbs",
296 ":drivetrain_status_fbs",
James Kuszmaul5bc6fc92019-03-01 21:50:06 -0800297 ":localizer",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800298 ":spline_goal_fbs",
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800299 "//aos:math",
300 "//aos/util:math",
301 "//frc971/control_loops:c2d",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700302 "//frc971/control_loops:control_loops_fbs",
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800303 "//frc971/control_loops:dlqr",
304 "//frc971/control_loops:pose",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700305 "//frc971/control_loops:profiled_subsystem_fbs",
306 "//y2019/control_loops/superstructure:superstructure_goal_fbs",
307 "@org_tuxfamily_eigen//:eigen",
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800308 ],
309)
310
311cc_test(
312 name = "line_follow_drivetrain_test",
313 srcs = ["line_follow_drivetrain_test.cc"],
314 linkstatic = True,
Philipp Schraderdada1072020-11-24 11:34:46 -0800315 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800316 deps = [
317 ":drivetrain_config",
318 ":drivetrain_test_lib",
319 ":line_follow_drivetrain",
320 ":trajectory",
321 "//aos/testing:googletest",
322 "//aos/testing:test_shm",
323 "//third_party/matplotlib-cpp",
324 "@com_github_gflags_gflags//:gflags",
325 ],
326)
327
328cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700329 name = "ssdrivetrain",
330 srcs = [
331 "ssdrivetrain.cc",
332 ],
333 hdrs = [
334 "ssdrivetrain.h",
335 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800336 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhbcce26a2018-03-26 23:41:24 -0700337 deps = [
338 ":drivetrain_config",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700339 ":drivetrain_goal_fbs",
340 ":drivetrain_output_fbs",
Austin Schuh95771d92021-01-23 14:42:25 -0800341 ":drivetrain_states",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700342 ":drivetrain_status_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700343 ":gear",
James Kuszmaul3431d622019-02-17 17:07:44 -0800344 ":localizer",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800345 ":spline_goal_fbs",
John Park33858a32018-09-28 23:05:48 -0700346 "//aos:math",
John Park33858a32018-09-28 23:05:48 -0700347 "//aos/util:log_interval",
348 "//aos/util:trapezoid_profile",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700349 "//frc971:shifter_hall_effect",
350 "//frc971/control_loops:coerce_goal",
Austin Schuh0a3c9d42021-07-15 22:36:24 -0700351 "//frc971/control_loops:control_loop",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700352 "//frc971/control_loops:control_loops_fbs",
Austin Schuh0a3c9d42021-07-15 22:36:24 -0700353 "//frc971/control_loops:polytope",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700354 "//frc971/control_loops:state_feedback_loop",
Austin Schuh0a3c9d42021-07-15 22:36:24 -0700355 "//frc971/input:robot_state_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700356 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000357)
358
359cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700360 name = "polydrivetrain",
361 srcs = [
362 "polydrivetrain.cc",
363 ],
364 hdrs = [
365 "polydrivetrain.h",
366 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800367 copts = select({
368 "@platforms//os:none": ["-Wno-type-limits"],
369 "//conditions:default": [],
370 }),
Austin Schuhbcce26a2018-03-26 23:41:24 -0700371 deps = [
372 ":drivetrain_config",
Austin Schuh95771d92021-01-23 14:42:25 -0800373 ":drivetrain_states",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700374 ":gear",
Maxwell Hendersoncef6f042023-05-26 14:38:09 -0700375 ":spline_goal_fbs",
John Park33858a32018-09-28 23:05:48 -0700376 "//aos:math",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700377 "//frc971/control_loops:coerce_goal",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700378 "//frc971/control_loops:control_loops_fbs",
Maxwell Hendersoncef6f042023-05-26 14:38:09 -0700379 "//frc971/control_loops:polytope",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700380 "//frc971/control_loops:state_feedback_loop",
Philipp Schraderdada1072020-11-24 11:34:46 -0800381 ] + select({
382 "@platforms//os:linux": [
383 ":drivetrain_goal_fbs",
384 ":drivetrain_output_fbs",
385 ":drivetrain_position_fbs",
386 ":drivetrain_status_fbs",
Philipp Schraderdada1072020-11-24 11:34:46 -0800387 "//aos/util:log_interval",
Maxwell Hendersoncef6f042023-05-26 14:38:09 -0700388 "//frc971/input:robot_state_fbs",
Philipp Schraderdada1072020-11-24 11:34:46 -0800389 ],
390 "@platforms//os:none": [
391 ":drivetrain_goal_float_fbs",
392 ":drivetrain_output_float_fbs",
393 ":drivetrain_position_float_fbs",
394 ":drivetrain_status_float_fbs",
395 ],
396 }),
Comran Morshed5323ecb2015-12-26 20:50:55 +0000397)
398
Austin Schuh05c5a612016-04-02 15:10:25 -0700399genrule(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700400 name = "genrule_down_estimator",
401 outs = [
402 "down_estimator.h",
403 "down_estimator.cc",
404 ],
405 cmd = "$(location //frc971/control_loops/python:down_estimator) $(OUTS)",
Philipp Schraderdada1072020-11-24 11:34:46 -0800406 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhbcce26a2018-03-26 23:41:24 -0700407 tools = [
408 "//frc971/control_loops/python:down_estimator",
409 ],
410 visibility = ["//visibility:private"],
Austin Schuh05c5a612016-04-02 15:10:25 -0700411)
412
413cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700414 name = "down_estimator",
415 srcs = [
416 "down_estimator.cc",
417 ],
418 hdrs = [
419 "down_estimator.h",
420 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800421 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhbcce26a2018-03-26 23:41:24 -0700422 deps = [
423 "//frc971/control_loops:state_feedback_loop",
424 ],
Austin Schuh05c5a612016-04-02 15:10:25 -0700425)
426
Comran Morshed5323ecb2015-12-26 20:50:55 +0000427cc_library(
Austin Schuh95771d92021-01-23 14:42:25 -0800428 name = "drivetrain_states",
429 hdrs = ["drivetrain_states.h"],
430)
431
432cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700433 name = "drivetrain_lib",
434 srcs = [
435 "drivetrain.cc",
436 ],
437 hdrs = [
438 "drivetrain.h",
439 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800440 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhbcce26a2018-03-26 23:41:24 -0700441 deps = [
Alex Perrycb7da4b2019-08-28 19:35:56 -0700442 ":drivetrain_goal_fbs",
443 ":drivetrain_output_fbs",
444 ":drivetrain_position_fbs",
Austin Schuh95771d92021-01-23 14:42:25 -0800445 ":drivetrain_states",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700446 ":drivetrain_status_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700447 ":gear",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800448 ":improved_down_estimator",
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800449 ":line_follow_drivetrain",
James Kuszmaul3431d622019-02-17 17:07:44 -0800450 ":localizer",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700451 ":localizer_fbs",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700452 ":polydrivetrain",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800453 ":spline_goal_fbs",
Alex Perry731b4602019-02-02 22:13:01 -0800454 ":splinedrivetrain",
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800455 ":ssdrivetrain",
John Park33858a32018-09-28 23:05:48 -0700456 "//aos/util:log_interval",
Austin Schuh0a3c9d42021-07-15 22:36:24 -0700457 "//frc971/control_loops:control_loop",
Austin Schuh3a378462019-01-04 21:48:04 -0800458 "//frc971/control_loops:runge_kutta",
Tyler Chatow24b5db12020-01-06 21:16:56 -0800459 "//frc971/queues:gyro_fbs",
Austin Schuhac17fba2020-03-28 15:55:33 -0700460 "//frc971/wpilib:imu_batch_fbs",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700461 "//frc971/wpilib:imu_fbs",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800462 "//frc971/zeroing:imu_zeroer",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700463 ],
Comran Morshed5323ecb2015-12-26 20:50:55 +0000464)
465
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800466cc_library(
467 name = "drivetrain_test_lib",
468 testonly = True,
469 srcs = ["drivetrain_test_lib.cc"],
470 hdrs = ["drivetrain_test_lib.h"],
James Kuszmaul74d8f972020-02-11 17:13:17 -0800471 defines =
472 cpu_select({
473 "amd64": [
474 "SUPPORT_PLOT=1",
475 ],
476 "arm": [],
477 }),
Philipp Schraderdada1072020-11-24 11:34:46 -0800478 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800479 deps = [
480 ":drivetrain_config",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700481 ":drivetrain_goal_fbs",
482 ":drivetrain_output_fbs",
483 ":drivetrain_position_fbs",
484 ":drivetrain_status_fbs",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800485 ":trajectory",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700486 "//aos/events:event_loop",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800487 "//aos/testing:googletest",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700488 "//frc971/control_loops:control_loops_fbs",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800489 "//frc971/control_loops:state_feedback_loop",
Tyler Chatow24b5db12020-01-06 21:16:56 -0800490 "//frc971/queues:gyro_fbs",
Austin Schuhac17fba2020-03-28 15:55:33 -0700491 "//frc971/wpilib:imu_batch_fbs",
Maxwell Hendersoncef6f042023-05-26 14:38:09 -0700492 "//frc971/wpilib:imu_fbs",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800493 "//y2016:constants",
494 "//y2016/control_loops/drivetrain:polydrivetrain_plants",
James Kuszmaul74d8f972020-02-11 17:13:17 -0800495 ] + cpu_select({
496 "amd64": [
497 "//third_party/matplotlib-cpp",
498 ],
499 "arm": [],
500 }),
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800501)
502
Comran Morshed5323ecb2015-12-26 20:50:55 +0000503cc_test(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700504 name = "drivetrain_lib_test",
505 srcs = [
506 "drivetrain_lib_test.cc",
507 ],
Austin Schuh14d7d3d2020-09-10 18:14:36 -0700508 data = [":simulation_config"],
Alex Perry04300d62019-02-17 14:37:04 -0800509 defines =
510 cpu_select({
511 "amd64": [
512 "SUPPORT_PLOT=1",
513 ],
514 "arm": [],
515 }),
516 linkstatic = True,
Philipp Schraderdada1072020-11-24 11:34:46 -0800517 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhbcce26a2018-03-26 23:41:24 -0700518 deps = [
519 ":drivetrain_config",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700520 ":drivetrain_goal_fbs",
Maxwell Hendersoncef6f042023-05-26 14:38:09 -0700521 ":drivetrain_lib",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700522 ":drivetrain_output_fbs",
Maxwell Hendersoncef6f042023-05-26 14:38:09 -0700523 ":drivetrain_position_fbs",
524 ":drivetrain_status_fbs",
James Kuszmaul109ed8d2019-02-17 21:41:04 -0800525 ":drivetrain_test_lib",
Maxwell Hendersoncef6f042023-05-26 14:38:09 -0700526 ":localizer_fbs",
527 ":trajectory_generator",
Austin Schuhb06f03b2021-02-17 22:00:37 -0800528 "//aos/events/logging:log_writer",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700529 "//aos/testing:googletest",
Maxwell Hendersoncef6f042023-05-26 14:38:09 -0700530 "//frc971/control_loops:control_loop_test",
Tyler Chatow24b5db12020-01-06 21:16:56 -0800531 "//frc971/queues:gyro_fbs",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800532 "//frc971/wpilib:imu_fbs",
Alex Perry04300d62019-02-17 14:37:04 -0800533 ] + cpu_select({
534 "amd64": [
535 "//third_party/matplotlib-cpp",
536 ],
537 "arm": [],
538 }),
Comran Morshed5323ecb2015-12-26 20:50:55 +0000539)
Brian Silverman6260c092018-01-14 15:21:36 -0800540
541genrule(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700542 name = "genrule_haptic_wheel",
543 outs = [
544 "haptic_wheel.h",
545 "haptic_wheel.cc",
546 "integral_haptic_wheel.h",
547 "integral_haptic_wheel.cc",
548 "haptic_trigger.h",
549 "haptic_trigger.cc",
550 "integral_haptic_trigger.h",
551 "integral_haptic_trigger.cc",
552 ],
553 cmd = "$(location //frc971/control_loops/python:haptic_wheel) $(OUTS)",
Austin Schuhbcce26a2018-03-26 23:41:24 -0700554 tools = [
555 "//frc971/control_loops/python:haptic_wheel",
556 ],
557 visibility = ["//visibility:private"],
Brian Silverman6260c092018-01-14 15:21:36 -0800558)
559
560cc_library(
Austin Schuhbcce26a2018-03-26 23:41:24 -0700561 name = "haptic_wheel",
562 srcs = [
563 "haptic_trigger.cc",
564 "haptic_wheel.cc",
565 "integral_haptic_trigger.cc",
566 "integral_haptic_wheel.cc",
567 ],
568 hdrs = [
569 "haptic_trigger.h",
570 "haptic_wheel.h",
571 "integral_haptic_trigger.h",
572 "integral_haptic_wheel.h",
573 ],
574 deps = [
575 "//frc971/control_loops:state_feedback_loop",
576 ],
Brian Silverman6260c092018-01-14 15:21:36 -0800577)
Austin Schuhc2b08772018-12-19 18:05:06 +1100578
579cc_library(
580 name = "spline",
581 srcs = ["spline.cc"],
582 hdrs = ["spline.h"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800583 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhc2b08772018-12-19 18:05:06 +1100584 deps = [
Austin Schuhf49b4e32019-01-13 17:26:58 -0800585 "//frc971/control_loops:binomial",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700586 "@org_tuxfamily_eigen//:eigen",
Austin Schuhc2b08772018-12-19 18:05:06 +1100587 ],
588)
589
Alex Perrya60da442019-01-21 19:00:27 -0500590cc_binary(
591 name = "spline.so",
592 srcs = ["libspline.cc"],
James Kuszmaul2ed7b3c2019-02-09 18:26:19 -0800593 linkshared = True,
Philipp Schraderdada1072020-11-24 11:34:46 -0800594 target_compatible_with = ["@platforms//os:linux"],
Alex Perrya60da442019-01-21 19:00:27 -0500595 deps = [
596 ":distance_spline",
597 ":spline",
Alex Perry0603b542019-01-25 20:29:51 -0800598 ":trajectory",
Austin Schuhfc0caa82023-08-25 14:25:03 -0700599 "//aos/logging",
Alex Perry0603b542019-01-25 20:29:51 -0800600 "//aos/network:team_number",
James Kuszmaul8aa37cb2020-03-01 10:27:58 -0800601 "//y2020/control_loops/drivetrain:drivetrain_base",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700602 "@org_tuxfamily_eigen//:eigen",
Alex Perrya60da442019-01-21 19:00:27 -0500603 ],
Alex Perrya60da442019-01-21 19:00:27 -0500604)
605
Austin Schuhc2b08772018-12-19 18:05:06 +1100606cc_test(
607 name = "spline_test",
608 srcs = [
609 "spline_test.cc",
610 ],
James Kuszmaule32fa932021-05-11 21:38:16 -0700611 linkstatic = True,
Philipp Schraderdada1072020-11-24 11:34:46 -0800612 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhc2b08772018-12-19 18:05:06 +1100613 deps = [
614 ":spline",
615 "//aos/testing:googletest",
James Kuszmaule32fa932021-05-11 21:38:16 -0700616 "//frc971/analysis:in_process_plotter",
Austin Schuhc2b08772018-12-19 18:05:06 +1100617 "@com_github_gflags_gflags//:gflags",
618 ],
619)
Austin Schuh941b46d2018-12-19 18:06:05 +1100620
621cc_library(
622 name = "distance_spline",
623 srcs = ["distance_spline.cc"],
624 hdrs = ["distance_spline.h"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800625 target_compatible_with = ["@platforms//os:linux"],
Austin Schuh941b46d2018-12-19 18:06:05 +1100626 deps = [
627 ":spline",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800628 ":trajectory_fbs",
Austin Schuhf7c65202022-11-04 21:28:20 -0700629 "//aos/containers:sized_array",
Austin Schuha6e7b212019-01-20 13:53:01 -0800630 "//aos/logging",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800631 "//frc971/control_loops:control_loops_fbs",
Austin Schuh941b46d2018-12-19 18:06:05 +1100632 "//frc971/control_loops:fixed_quadrature",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800633 "@com_github_google_glog//:glog",
Austin Schuhf7c65202022-11-04 21:28:20 -0700634 "@com_google_absl//absl/types:span",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700635 "@org_tuxfamily_eigen//:eigen",
Austin Schuh941b46d2018-12-19 18:06:05 +1100636 ],
637)
638
639cc_test(
640 name = "distance_spline_test",
641 srcs = [
642 "distance_spline_test.cc",
643 ],
Austin Schuh9b0b6432019-01-13 21:15:17 -0800644 defines =
645 cpu_select({
646 "amd64": [
647 "SUPPORT_PLOT=1",
648 ],
649 "arm": [],
650 }),
651 linkstatic = True,
Philipp Schraderdada1072020-11-24 11:34:46 -0800652 target_compatible_with = ["@platforms//os:linux"],
Austin Schuh941b46d2018-12-19 18:06:05 +1100653 deps = [
654 ":distance_spline",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800655 "//aos:flatbuffers",
Maxwell Hendersoncef6f042023-05-26 14:38:09 -0700656 "//aos/testing:googletest",
Austin Schuha6e7b212019-01-20 13:53:01 -0800657 "//aos/testing:test_shm",
Austin Schuh941b46d2018-12-19 18:06:05 +1100658 "@com_github_gflags_gflags//:gflags",
Austin Schuh9b0b6432019-01-13 21:15:17 -0800659 ] + cpu_select({
660 "amd64": [
661 "//third_party/matplotlib-cpp",
662 ],
663 "arm": [],
664 }),
Austin Schuh941b46d2018-12-19 18:06:05 +1100665)
Austin Schuhec7f06d2019-01-04 07:47:15 +1100666
667cc_library(
668 name = "trajectory",
669 srcs = ["trajectory.cc"],
670 hdrs = ["trajectory.h"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800671 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhec7f06d2019-01-04 07:47:15 +1100672 deps = [
673 ":distance_spline",
674 ":drivetrain_config",
James Kuszmaul75a18c52021-03-10 22:02:07 -0800675 ":spline_goal_fbs",
676 ":trajectory_fbs",
James Kuszmaul5e8ce312021-03-27 14:59:17 -0700677 "//aos/util:math",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100678 "//frc971/control_loops:c2d",
679 "//frc971/control_loops:dlqr",
680 "//frc971/control_loops:hybrid_state_feedback_loop",
681 "//frc971/control_loops:runge_kutta",
682 "//frc971/control_loops:state_feedback_loop",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700683 "@org_tuxfamily_eigen//:eigen",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100684 ],
685)
686
James Kuszmaul75a18c52021-03-10 22:02:07 -0800687cc_library(
688 name = "trajectory_generator",
689 srcs = ["trajectory_generator.cc"],
690 hdrs = ["trajectory_generator.h"],
691 target_compatible_with = ["@platforms//os:linux"],
692 deps = [
693 ":distance_spline",
694 ":drivetrain_config",
695 ":spline_goal_fbs",
696 ":trajectory",
697 ":trajectory_fbs",
698 ],
699)
700
Austin Schuhec7f06d2019-01-04 07:47:15 +1100701cc_binary(
702 name = "trajectory_plot",
703 srcs = [
704 "trajectory_plot.cc",
705 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800706 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhec7f06d2019-01-04 07:47:15 +1100707 deps = [
708 ":distance_spline",
709 ":trajectory",
Austin Schuhfc0caa82023-08-25 14:25:03 -0700710 "//aos/logging",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100711 "//aos/network:team_number",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100712 "//third_party/matplotlib-cpp",
Austin Schuh11043182019-03-23 22:29:12 -0700713 "//y2019/control_loops/drivetrain:drivetrain_base",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100714 "@com_github_gflags_gflags//:gflags",
Alex Perrycb7da4b2019-08-28 19:35:56 -0700715 "@org_tuxfamily_eigen//:eigen",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100716 ],
717)
718
719cc_test(
720 name = "trajectory_test",
721 srcs = [
722 "trajectory_test.cc",
723 ],
Austin Schuh719a33e2019-01-07 15:13:34 -0800724 defines =
725 cpu_select({
726 "amd64": [
727 "SUPPORT_PLOT=1",
728 ],
729 "arm": [],
730 }),
731 linkstatic = True,
Philipp Schraderdada1072020-11-24 11:34:46 -0800732 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhec7f06d2019-01-04 07:47:15 +1100733 deps = [
James Kuszmaulea314d92019-02-18 19:45:06 -0800734 ":drivetrain_test_lib",
Maxwell Hendersoncef6f042023-05-26 14:38:09 -0700735 ":trajectory",
Austin Schuhec7f06d2019-01-04 07:47:15 +1100736 "//aos/testing:googletest",
737 "//aos/testing:test_shm",
738 "//y2016:constants",
739 "//y2016/control_loops/drivetrain:polydrivetrain_plants",
James Kuszmaulea314d92019-02-18 19:45:06 -0800740 "//y2019/control_loops/drivetrain:drivetrain_base",
Austin Schuh719a33e2019-01-07 15:13:34 -0800741 ] + cpu_select({
742 "amd64": [
743 "//third_party/matplotlib-cpp",
744 ],
745 "arm": [],
746 }),
Austin Schuhec7f06d2019-01-04 07:47:15 +1100747)
Austin Schuhca080812017-05-10 19:31:55 -0700748
749cc_library(
750 name = "improved_down_estimator",
751 srcs = [
752 "improved_down_estimator.cc",
753 ],
754 hdrs = [
755 "improved_down_estimator.h",
756 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800757 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhca080812017-05-10 19:31:55 -0700758 deps = [
James Kuszmaul7f55f072020-03-01 10:21:26 -0800759 ":drivetrain_config",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800760 ":drivetrain_status_fbs",
761 "//aos/events:event_loop",
762 "//frc971/control_loops:control_loops_fbs",
Austin Schuh0a3c9d42021-07-15 22:36:24 -0700763 "//frc971/control_loops:quaternion_utils",
Austin Schuhca080812017-05-10 19:31:55 -0700764 "//frc971/control_loops:runge_kutta",
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800765 "@//aos/time",
Austin Schuhca080812017-05-10 19:31:55 -0700766 "@com_github_google_glog//:glog",
767 "@org_tuxfamily_eigen//:eigen",
768 ],
769)
770
771cc_test(
772 name = "improved_down_estimator_test",
773 srcs = [
774 "improved_down_estimator_test.cc",
775 ],
Philipp Schraderdada1072020-11-24 11:34:46 -0800776 target_compatible_with = ["@platforms//os:linux"],
Austin Schuhca080812017-05-10 19:31:55 -0700777 deps = [
James Kuszmaul7f55f072020-03-01 10:21:26 -0800778 ":drivetrain_test_lib",
Austin Schuhca080812017-05-10 19:31:55 -0700779 "//aos/testing:googletest",
780 "//aos/testing:random_seed",
Austin Schuh0a3c9d42021-07-15 22:36:24 -0700781 "//frc971/control_loops:quaternion_utils",
Austin Schuhca080812017-05-10 19:31:55 -0700782 "//frc971/control_loops/drivetrain:improved_down_estimator",
783 "@org_tuxfamily_eigen//:eigen",
784 ],
785)
James Kuszmaulf4ede202020-02-14 08:47:40 -0800786
787cc_library(
788 name = "camera",
789 srcs = ["camera.h"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800790 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaulf4ede202020-02-14 08:47:40 -0800791 visibility = ["//visibility:public"],
792 deps = [
793 "//aos/containers:sized_array",
794 "//frc971/control_loops:pose",
795 ],
796)
797
798cc_test(
799 name = "camera_test",
800 srcs = ["camera_test.cc"],
Philipp Schraderdada1072020-11-24 11:34:46 -0800801 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaulf4ede202020-02-14 08:47:40 -0800802 deps = [
803 ":camera",
804 "//aos/testing:googletest",
805 ],
806)
James Kuszmaulc4ae11c2020-12-26 16:26:58 -0800807
Philipp Schrader3de4dfc2023-02-15 20:18:25 -0800808ts_project(
James Kuszmaulac2b6b42021-03-07 22:38:06 -0800809 name = "down_estimator_plotter",
810 srcs = ["down_estimator_plotter.ts"],
811 target_compatible_with = ["@platforms//os:linux"],
812 deps = [
813 "//aos/network/www:aos_plotter",
814 "//aos/network/www:colors",
815 "//aos/network/www:proxy",
816 "//frc971/wpilib:imu_plot_utils",
817 ],
818)
819
Philipp Schrader3de4dfc2023-02-15 20:18:25 -0800820ts_project(
James Kuszmaul73fc1352021-04-09 22:31:25 -0700821 name = "spline_plotter",
822 srcs = ["spline_plotter.ts"],
823 target_compatible_with = ["@platforms//os:linux"],
824 deps = [
825 "//aos/network/www:aos_plotter",
826 "//aos/network/www:colors",
827 "//aos/network/www:proxy",
828 ],
829)
830
Philipp Schrader3de4dfc2023-02-15 20:18:25 -0800831ts_project(
James Kuszmaulc4ae11c2020-12-26 16:26:58 -0800832 name = "drivetrain_plotter",
833 srcs = ["drivetrain_plotter.ts"],
834 target_compatible_with = ["@platforms//os:linux"],
835 deps = [
836 "//aos/network/www:aos_plotter",
James Kuszmaul933a9742021-03-07 19:59:06 -0800837 "//aos/network/www:colors",
James Kuszmaulc4ae11c2020-12-26 16:26:58 -0800838 "//aos/network/www:proxy",
839 "//frc971/wpilib:imu_plot_utils",
840 ],
841)
milind upadhyay9bd381d2021-01-23 13:44:13 -0800842
Philipp Schrader3de4dfc2023-02-15 20:18:25 -0800843ts_project(
milind upadhyay9bd381d2021-01-23 13:44:13 -0800844 name = "robot_state_plotter",
845 srcs = ["robot_state_plotter.ts"],
846 target_compatible_with = ["@platforms//os:linux"],
847 deps = [
848 "//aos/network/www:aos_plotter",
James Kuszmaul933a9742021-03-07 19:59:06 -0800849 "//aos/network/www:colors",
milind upadhyay9bd381d2021-01-23 13:44:13 -0800850 "//aos/network/www:proxy",
851 ],
852)