blob: dc40babce43ce1d93d0510ae97cc04a7311a43bd [file] [log] [blame]
James Kuszmaulf01da392023-12-14 11:22:14 -08001load("@com_github_google_flatbuffers//:build_defs.bzl", "flatbuffer_py_library")
Austin Schuha1d006e2022-09-14 21:50:42 -07002load("@com_github_google_flatbuffers//:typescript.bzl", "flatbuffer_ts_library")
Austin Schuh8f99c822024-05-05 22:43:40 -07003load("//aos:config.bzl", "aos_config")
4load("//aos/flatbuffers:generate.bzl", "static_flatbuffer")
Jim Ostrowski977850f2022-01-22 21:04:22 -08005
Yash Maheshwari997b3312024-05-18 17:08:44 -07006cc_binary(
7 name = "modify_extrinsics",
8 srcs = [
9 "modify_extrinsics.cc",
10 ],
11 target_compatible_with = ["@platforms//os:linux"],
12 visibility = ["//visibility:public"],
13 deps = [
14 "//aos:configuration",
15 "//aos:init",
16 "//aos/events:event_loop",
17 "//frc971/vision:calibration_fbs",
18 "//frc971/vision:vision_util_lib",
19 "@com_google_absl//absl/strings:str_format",
20 "@org_tuxfamily_eigen//:eigen",
21 ],
22)
23
24cc_binary(
25 name = "image_replay",
26 srcs = [
27 "image_replay.cc",
28 ],
29 target_compatible_with = ["@platforms//os:linux"],
30 visibility = ["//visibility:public"],
31 deps = [
32 "//aos:configuration",
33 "//aos:init",
34 "//aos/events:simulated_event_loop",
35 "//aos/events/logging:log_reader",
36 "//frc971/vision:vision_fbs",
37 "//third_party:opencv",
38 ],
39)
40
41cc_binary(
42 name = "image_logger",
43 srcs = [
44 "image_logger.cc",
45 ],
46 target_compatible_with = ["@platforms//os:linux"],
47 visibility = ["//visibility:public"],
48 deps = [
49 "//aos:configuration",
50 "//aos:init",
51 "//aos/events:shm_event_loop",
52 "//aos/events/logging:log_writer",
53 "//aos/logging:log_namer",
54 "//aos/util:filesystem_fbs",
55 "//frc971/input:joystick_state_fbs",
Austin Schuh99f7c6a2024-06-25 22:07:44 -070056 "@com_google_absl//absl/flags:flag",
57 "@com_google_absl//absl/log",
58 "@com_google_absl//absl/log:check",
Yash Maheshwari997b3312024-05-18 17:08:44 -070059 ],
60)
61
62cc_binary(
63 name = "foxglove_image_converter",
64 srcs = ["foxglove_image_converter.cc"],
65 visibility = ["//visibility:public"],
66 deps = [
67 "//aos:init",
68 "//aos/events:shm_event_loop",
69 "//frc971/vision:foxglove_image_converter_lib",
70 ],
71)
72
James Kuszmaulf01da392023-12-14 11:22:14 -080073static_flatbuffer(
Jim Ostrowski977850f2022-01-22 21:04:22 -080074 name = "vision_fbs",
75 srcs = ["vision.fbs"],
Jim Ostrowski977850f2022-01-22 21:04:22 -080076 target_compatible_with = ["@platforms//os:linux"],
77 visibility = ["//visibility:public"],
78)
79
80flatbuffer_ts_library(
81 name = "vision_ts_fbs",
82 srcs = ["vision.fbs"],
83 target_compatible_with = ["@platforms//os:linux"],
84 visibility = ["//visibility:public"],
85)
86
James Kuszmaulf01da392023-12-14 11:22:14 -080087static_flatbuffer(
milind-u2f101fc2023-01-21 12:28:49 -080088 name = "calibration_fbs",
89 srcs = ["calibration.fbs"],
milind-u2f101fc2023-01-21 12:28:49 -080090 target_compatible_with = ["@platforms//os:linux"],
91 visibility = ["//visibility:public"],
92)
93
94flatbuffer_ts_library(
95 name = "calibration_ts_fbs",
96 srcs = ["calibration.fbs"],
97 target_compatible_with = ["@platforms//os:linux"],
98 visibility = ["//visibility:public"],
99)
100
Milo Lin13906572023-03-15 20:55:22 -0700101flatbuffer_ts_library(
102 name = "target_map_ts_fbs",
103 srcs = ["target_map.fbs"],
104 target_compatible_with = ["@platforms//os:linux"],
105 visibility = ["//visibility:public"],
106)
107
milind-u2f101fc2023-01-21 12:28:49 -0800108flatbuffer_py_library(
109 name = "calibration_fbs_python",
110 srcs = [
111 "calibration.fbs",
112 ],
113 namespace = "frc971.vision.calibration",
114 tables = [
115 "CalibrationData",
116 "CameraCalibration",
117 "TransformationMatrix",
118 ],
119 target_compatible_with = ["@platforms//os:linux"],
120 visibility = ["//visibility:public"],
121)
122
milind-u959d6bd2023-01-21 12:32:52 -0800123py_library(
124 name = "create_calib_file",
125 srcs = [
126 "create_calib_file.py",
127 ],
128 target_compatible_with = ["@platforms//os:linux"],
129 visibility = ["//visibility:public"],
130 deps = [
131 ":calibration_fbs_python",
132 "@bazel_tools//tools/python/runfiles",
133 "@pip//glog",
134 "@pip//opencv_python",
135 ],
136)
137
Jim Ostrowski977850f2022-01-22 21:04:22 -0800138cc_library(
139 name = "v4l2_reader",
140 srcs = [
141 "v4l2_reader.cc",
142 ],
143 hdrs = [
144 "v4l2_reader.h",
145 ],
146 target_compatible_with = ["@platforms//os:linux"],
147 visibility = ["//visibility:public"],
148 deps = [
149 ":vision_fbs",
Ravago Jonesdc524752022-12-27 01:15:13 -0800150 "//aos/events:epoll",
Jim Ostrowski977850f2022-01-22 21:04:22 -0800151 "//aos/events:event_loop",
152 "//aos/scoped:scoped_fd",
Ravago Jonesc6b919f2023-01-01 21:34:12 -0800153 "//aos/util:threaded_consumer",
Jim Ostrowski977850f2022-01-22 21:04:22 -0800154 "@com_google_absl//absl/base",
Austin Schuh99f7c6a2024-06-25 22:07:44 -0700155 "@com_google_absl//absl/log",
156 "@com_google_absl//absl/log:check",
Jim Ostrowski977850f2022-01-22 21:04:22 -0800157 ],
158)
Austin Schuhdcb6b362022-02-25 18:06:21 -0800159
160cc_library(
161 name = "charuco_lib",
162 srcs = [
163 "charuco_lib.cc",
164 ],
165 hdrs = [
166 "charuco_lib.h",
167 ],
168 target_compatible_with = ["@platforms//os:linux"],
169 visibility = ["//visibility:public"],
170 deps = [
171 "//aos:flatbuffers",
172 "//aos/events:event_loop",
173 "//aos/network:message_bridge_server_fbs",
174 "//aos/network:team_number",
175 "//frc971/control_loops:quaternion_utils",
James Kuszmaul7e958812023-02-11 15:34:31 -0800176 "//frc971/vision:calibration_fbs",
Austin Schuhdcb6b362022-02-25 18:06:21 -0800177 "//frc971/vision:vision_fbs",
178 "//third_party:opencv",
James Kuszmaul969e4ab2023-01-28 16:09:19 -0800179 "@com_github_foxglove_schemas//:schemas",
Austin Schuh99f7c6a2024-06-25 22:07:44 -0700180 "@com_google_absl//absl/log",
181 "@com_google_absl//absl/log:check",
Austin Schuhdcb6b362022-02-25 18:06:21 -0800182 "@com_google_absl//absl/strings:str_format",
183 "@com_google_absl//absl/types:span",
184 "@org_tuxfamily_eigen//:eigen",
185 ],
186)
187
188cc_library(
189 name = "extrinsics_calibration",
190 srcs = [
191 "calibration_accumulator.cc",
192 "calibration_accumulator.h",
193 "extrinsics_calibration.cc",
194 "extrinsics_calibration.h",
195 ],
196 target_compatible_with = ["@platforms//os:linux"],
197 visibility = ["//visibility:public"],
198 deps = [
199 ":charuco_lib",
James Kuszmaul77d536c2023-02-11 17:30:59 -0800200 ":foxglove_image_converter_lib",
Austin Schuhdcb6b362022-02-25 18:06:21 -0800201 "//aos:init",
202 "//aos/events/logging:log_reader",
Austin Schuhdcb6b362022-02-25 18:06:21 -0800203 "//frc971/control_loops/drivetrain:improved_down_estimator",
Jim Ostrowskiba2edd12022-12-03 15:44:37 -0800204 "//frc971/vision:visualize_robot",
Austin Schuhdcb6b362022-02-25 18:06:21 -0800205 "//frc971/wpilib:imu_batch_fbs",
206 "//frc971/wpilib:imu_fbs",
207 "//third_party:opencv",
James Kuszmaul969e4ab2023-01-28 16:09:19 -0800208 "@com_github_foxglove_schemas//:CompressedImage_schema",
209 "@com_github_foxglove_schemas//:ImageAnnotations_schema",
Austin Schuhdcb6b362022-02-25 18:06:21 -0800210 "@com_google_absl//absl/strings:str_format",
211 "@com_google_ceres_solver//:ceres",
212 "@org_tuxfamily_eigen//:eigen",
Stephan Pleines85b295c2024-02-04 17:50:26 -0800213 ] + [
214 # TODO(Stephan): This is a whacky hack. If we include this
215 # in the proper spot above (alphabetically), then we get a
216 # linker error: duplicate symbol: crc32.
217 # It's part of both @zlib and @com_github_rawrtc_re.
218 "//aos/analysis:in_process_plotter",
Austin Schuhdcb6b362022-02-25 18:06:21 -0800219 ],
220)
Milind Upadhyayb67c6182022-10-22 13:45:45 -0700221
James Kuszmaulf01da392023-12-14 11:22:14 -0800222static_flatbuffer(
Milind Upadhyaycd677a32022-12-04 13:06:43 -0800223 name = "target_map_fbs",
224 srcs = ["target_map.fbs"],
Milind Upadhyaycd677a32022-12-04 13:06:43 -0800225 target_compatible_with = ["@platforms//os:linux"],
226 visibility = ["//visibility:public"],
227)
228
Milind Upadhyayb67c6182022-10-22 13:45:45 -0700229cc_library(
Milind Upadhyay7c205222022-11-16 18:20:58 -0800230 name = "target_mapper",
231 srcs = ["target_mapper.cc"],
232 hdrs = ["target_mapper.h"],
Yash Chainanid5c7f0d2022-11-19 17:05:57 -0800233 data = ["target_map.json"],
Milind Upadhyay7c205222022-11-16 18:20:58 -0800234 target_compatible_with = ["@platforms//os:linux"],
235 visibility = ["//visibility:public"],
236 deps = [
237 ":geometry_lib",
Milind Upadhyaycd677a32022-12-04 13:06:43 -0800238 ":target_map_fbs",
Milind Upadhyay7c205222022-11-16 18:20:58 -0800239 "//aos/events:simulated_event_loop",
240 "//frc971/control_loops:control_loop",
Jim Ostrowski6d242d52024-04-03 20:39:03 -0700241 "//frc971/vision:vision_util_lib",
milind-u8f4e43e2023-04-09 17:11:19 -0700242 "//frc971/vision:visualize_robot",
Milind Upadhyayc5beba12022-12-17 17:41:20 -0800243 "//frc971/vision/ceres:pose_graph_3d_lib",
Milind Upadhyay7c205222022-11-16 18:20:58 -0800244 "//third_party:opencv",
245 "@com_google_ceres_solver//:ceres",
246 "@org_tuxfamily_eigen//:eigen",
247 ],
248)
249
250cc_test(
251 name = "target_mapper_test",
252 srcs = [
253 "target_mapper_test.cc",
254 ],
Milind Upadhyayc5beba12022-12-17 17:41:20 -0800255 data = [":target_map.json"],
Milind Upadhyay7c205222022-11-16 18:20:58 -0800256 target_compatible_with = ["@platforms//os:linux"],
257 deps = [
258 ":target_mapper",
259 "//aos/events:simulated_event_loop",
260 "//aos/testing:googletest",
Milind Upadhyayc5beba12022-12-17 17:41:20 -0800261 "//aos/testing:path",
Milind Upadhyay7c205222022-11-16 18:20:58 -0800262 "//aos/testing:random_seed",
Milind Upadhyayc5beba12022-12-17 17:41:20 -0800263 "//aos/util:math",
Milind Upadhyay7c205222022-11-16 18:20:58 -0800264 ],
265)
266
267cc_library(
Milind Upadhyayb67c6182022-10-22 13:45:45 -0700268 name = "geometry_lib",
269 hdrs = [
270 "geometry.h",
271 ],
272 target_compatible_with = ["@platforms//os:linux"],
273 visibility = ["//visibility:public"],
274 deps = [
275 "//aos/util:math",
276 "//third_party:opencv",
Austin Schuh99f7c6a2024-06-25 22:07:44 -0700277 "@com_google_absl//absl/log",
278 "@com_google_absl//absl/log:check",
Milind Upadhyayb67c6182022-10-22 13:45:45 -0700279 ],
280)
281
282cc_test(
283 name = "geometry_test",
284 srcs = [
285 "geometry_test.cc",
286 ],
287 deps = [
288 ":geometry_lib",
289 "//aos/testing:googletest",
290 ],
291)
Jim Ostrowskiba2edd12022-12-03 15:44:37 -0800292
293cc_library(
294 name = "visualize_robot",
295 srcs = [
296 "visualize_robot.cc",
297 ],
298 hdrs = [
299 "visualize_robot.h",
300 ],
Jim Ostrowski49be8232023-03-23 01:00:14 -0700301 visibility = ["//visibility:public"],
Jim Ostrowskiba2edd12022-12-03 15:44:37 -0800302 deps = [
303 "//aos:init",
304 "//third_party:opencv",
305 "@com_google_absl//absl/strings:str_format",
306 "@org_tuxfamily_eigen//:eigen",
307 ],
308)
309
310cc_binary(
311 name = "visualize_robot_sample",
312 srcs = [
313 "visualize_robot_sample.cc",
314 ],
315 target_compatible_with = ["@platforms//os:linux"],
316 visibility = ["//visibility:public"],
317 deps = [
318 "//aos:init",
319 "//frc971/vision:visualize_robot",
320 "//third_party:opencv",
Austin Schuh99f7c6a2024-06-25 22:07:44 -0700321 "@com_google_absl//absl/log",
322 "@com_google_absl//absl/log:check",
Jim Ostrowskiba2edd12022-12-03 15:44:37 -0800323 "@com_google_ceres_solver//:ceres",
324 "@org_tuxfamily_eigen//:eigen",
325 ],
326)
Austin Schuhc97d48d2022-12-26 14:09:13 -0800327
328cc_library(
329 name = "media_device",
330 srcs = [
331 "media_device.cc",
332 ],
333 hdrs = ["media_device.h"],
334 visibility = ["//visibility:public"],
335 deps = [
336 "//aos/scoped:scoped_fd",
337 "//aos/util:file",
Austin Schuh99f7c6a2024-06-25 22:07:44 -0700338 "@com_google_absl//absl/log",
339 "@com_google_absl//absl/log:check",
Austin Schuhc97d48d2022-12-26 14:09:13 -0800340 "@com_google_absl//absl/strings",
341 ],
342)
James Kuszmaul0c593962023-01-28 16:04:20 -0800343
344cc_library(
James Kuszmaul77d536c2023-02-11 17:30:59 -0800345 name = "foxglove_image_converter_lib",
346 srcs = ["foxglove_image_converter_lib.cc"],
347 hdrs = ["foxglove_image_converter_lib.h"],
James Kuszmaul0c593962023-01-28 16:04:20 -0800348 visibility = ["//visibility:public"],
349 deps = [
James Kuszmaul59a308f2023-01-28 19:14:07 -0800350 ":charuco_lib",
James Kuszmaul0c593962023-01-28 16:04:20 -0800351 ":vision_fbs",
352 "//aos/events:event_loop",
353 "//third_party:opencv",
354 "@com_github_foxglove_schemas//:schemas",
355 ],
356)
James Kuszmaul59a308f2023-01-28 19:14:07 -0800357
358aos_config(
359 name = "converter_config",
360 testonly = True,
361 src = "converter_test_config.json",
362 flatbuffers = [
363 "//frc971/vision:vision_fbs",
364 "//aos/events:event_loop_fbs",
365 "//aos/logging:log_message_fbs",
366 "//aos/network:message_bridge_client_fbs",
367 "//aos/network:message_bridge_server_fbs",
368 "//aos/network:timestamp_fbs",
369 "@com_github_foxglove_schemas//:schemas",
370 ],
371)
372
373cc_test(
374 name = "foxglove_image_converter_test",
375 srcs = ["foxglove_image_converter_test.cc"],
376 data = [
377 ":converter_config",
378 "@april_tag_test_image",
379 ],
380 deps = [
James Kuszmaul77d536c2023-02-11 17:30:59 -0800381 ":foxglove_image_converter_lib",
James Kuszmaul59a308f2023-01-28 19:14:07 -0800382 "//aos:configuration",
383 "//aos/events:simulated_event_loop",
384 "//aos/testing:googletest",
385 "//aos/testing:path",
386 "//aos/testing:tmpdir",
387 ],
388)
James Kuszmaul7e958812023-02-11 15:34:31 -0800389
390cc_library(
391 name = "intrinsics_calibration_lib",
392 srcs = [
393 "intrinsics_calibration_lib.cc",
394 ],
395 hdrs = [
396 "intrinsics_calibration_lib.h",
397 ],
398 target_compatible_with = ["@platforms//os:linux"],
399 deps = [
400 "//aos/events:event_loop",
401 "//frc971/control_loops/drivetrain:improved_down_estimator",
402 "//frc971/vision:charuco_lib",
403 "//frc971/vision:vision_fbs",
Jim Ostrowskib974cca2024-01-28 15:07:50 -0800404 "//frc971/vision:vision_util_lib",
James Kuszmaul7e958812023-02-11 15:34:31 -0800405 "//frc971/wpilib:imu_batch_fbs",
406 "//frc971/wpilib:imu_fbs",
407 "//third_party:opencv",
408 "@com_google_absl//absl/strings:str_format",
409 "@org_tuxfamily_eigen//:eigen",
410 ],
411)
412
413cc_binary(
414 name = "intrinsics_calibration",
415 srcs = [
416 "intrinsics_calibration.cc",
417 ],
418 target_compatible_with = ["@platforms//os:linux"],
Yash Maheshwarie0b25c52024-05-22 20:23:36 -0700419 visibility = ["//visibility:public"],
James Kuszmaul7e958812023-02-11 15:34:31 -0800420 deps = [
421 ":intrinsics_calibration_lib",
422 "//aos:init",
423 "//aos/events:shm_event_loop",
424 "//frc971/control_loops/drivetrain:improved_down_estimator",
425 "//frc971/vision:charuco_lib",
426 "//frc971/vision:vision_fbs",
427 "//frc971/wpilib:imu_batch_fbs",
428 "//frc971/wpilib:imu_fbs",
429 "//third_party:opencv",
430 "@com_google_absl//absl/strings:str_format",
431 "@org_tuxfamily_eigen//:eigen",
432 ],
433)
Jim Ostrowskicb8b4082024-01-21 02:23:46 -0800434
435cc_library(
436 name = "vision_util_lib",
437 srcs = ["vision_util_lib.cc"],
438 hdrs = ["vision_util_lib.h"],
439 visibility = ["//visibility:public"],
440 deps = [
Jim Ostrowski6d242d52024-04-03 20:39:03 -0700441 "//aos/util:math",
442 "//frc971/control_loops:quaternion_utils",
Jim Ostrowskicb8b4082024-01-21 02:23:46 -0800443 "//frc971/vision:calibration_fbs",
Jim Ostrowski6d242d52024-04-03 20:39:03 -0700444 "//frc971/vision/ceres:pose_graph_3d_lib",
Jim Ostrowskicb8b4082024-01-21 02:23:46 -0800445 "//third_party:opencv",
Austin Schuh99f7c6a2024-06-25 22:07:44 -0700446 "@com_google_absl//absl/log",
447 "@com_google_absl//absl/log:check",
Jim Ostrowski33208982024-03-02 15:01:45 -0800448 "@com_google_absl//absl/strings:str_format",
Jim Ostrowski6d242d52024-04-03 20:39:03 -0700449 "@com_google_ceres_solver//:ceres",
450 "@org_tuxfamily_eigen//:eigen",
Jim Ostrowskicb8b4082024-01-21 02:23:46 -0800451 ],
452)
Jim Ostrowskib974cca2024-01-28 15:07:50 -0800453
454cc_test(
455 name = "vision_util_lib_test",
456 srcs = ["vision_util_lib_test.cc"],
457 visibility = ["//visibility:public"],
458 deps = [
459 "//aos/testing:googletest",
460 "//frc971/vision:vision_util_lib",
Austin Schuh99f7c6a2024-06-25 22:07:44 -0700461 "@com_google_absl//absl/log",
462 "@com_google_absl//absl/log:check",
Jim Ostrowskib974cca2024-01-28 15:07:50 -0800463 ],
464)
James Kuszmaul9c3db182024-02-09 22:02:18 -0800465
466cc_library(
467 name = "target_map_utils",
468 srcs = ["target_map_utils.cc"],
469 hdrs = ["target_map_utils.h"],
470 visibility = ["//visibility:public"],
471 deps = [
472 "//frc971/vision:target_map_fbs",
473 "@org_tuxfamily_eigen//:eigen",
474 ],
475)