blob: 48a8fb16b61e5c7977db3e0bd338f913d0adb659 [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",
milind-u8f4e43e2023-04-09 17:11:19 -0700241 "//frc971/vision:visualize_robot",
Milind Upadhyayc5beba12022-12-17 17:41:20 -0800242 "//frc971/vision/ceres:pose_graph_3d_lib",
Milind Upadhyay7c205222022-11-16 18:20:58 -0800243 "//third_party:opencv",
244 "@com_google_ceres_solver//:ceres",
245 "@org_tuxfamily_eigen//:eigen",
246 ],
247)
248
249cc_test(
250 name = "target_mapper_test",
251 srcs = [
252 "target_mapper_test.cc",
253 ],
Milind Upadhyayc5beba12022-12-17 17:41:20 -0800254 data = [":target_map.json"],
Milind Upadhyay7c205222022-11-16 18:20:58 -0800255 target_compatible_with = ["@platforms//os:linux"],
256 deps = [
257 ":target_mapper",
258 "//aos/events:simulated_event_loop",
259 "//aos/testing:googletest",
Milind Upadhyayc5beba12022-12-17 17:41:20 -0800260 "//aos/testing:path",
Milind Upadhyay7c205222022-11-16 18:20:58 -0800261 "//aos/testing:random_seed",
Milind Upadhyayc5beba12022-12-17 17:41:20 -0800262 "//aos/util:math",
Milind Upadhyay7c205222022-11-16 18:20:58 -0800263 ],
264)
265
266cc_library(
Milind Upadhyayb67c6182022-10-22 13:45:45 -0700267 name = "geometry_lib",
268 hdrs = [
269 "geometry.h",
270 ],
271 target_compatible_with = ["@platforms//os:linux"],
272 visibility = ["//visibility:public"],
273 deps = [
274 "//aos/util:math",
275 "//third_party:opencv",
Austin Schuh99f7c6a2024-06-25 22:07:44 -0700276 "@com_google_absl//absl/log",
277 "@com_google_absl//absl/log:check",
Milind Upadhyayb67c6182022-10-22 13:45:45 -0700278 ],
279)
280
281cc_test(
282 name = "geometry_test",
283 srcs = [
284 "geometry_test.cc",
285 ],
286 deps = [
287 ":geometry_lib",
288 "//aos/testing:googletest",
289 ],
290)
Jim Ostrowskiba2edd12022-12-03 15:44:37 -0800291
292cc_library(
293 name = "visualize_robot",
294 srcs = [
295 "visualize_robot.cc",
296 ],
297 hdrs = [
298 "visualize_robot.h",
299 ],
Jim Ostrowski49be8232023-03-23 01:00:14 -0700300 visibility = ["//visibility:public"],
Jim Ostrowskiba2edd12022-12-03 15:44:37 -0800301 deps = [
302 "//aos:init",
303 "//third_party:opencv",
304 "@com_google_absl//absl/strings:str_format",
305 "@org_tuxfamily_eigen//:eigen",
306 ],
307)
308
309cc_binary(
310 name = "visualize_robot_sample",
311 srcs = [
312 "visualize_robot_sample.cc",
313 ],
314 target_compatible_with = ["@platforms//os:linux"],
315 visibility = ["//visibility:public"],
316 deps = [
317 "//aos:init",
318 "//frc971/vision:visualize_robot",
319 "//third_party:opencv",
Austin Schuh99f7c6a2024-06-25 22:07:44 -0700320 "@com_google_absl//absl/log",
321 "@com_google_absl//absl/log:check",
Jim Ostrowskiba2edd12022-12-03 15:44:37 -0800322 "@com_google_ceres_solver//:ceres",
323 "@org_tuxfamily_eigen//:eigen",
324 ],
325)
Austin Schuhc97d48d2022-12-26 14:09:13 -0800326
327cc_library(
328 name = "media_device",
329 srcs = [
330 "media_device.cc",
331 ],
332 hdrs = ["media_device.h"],
333 visibility = ["//visibility:public"],
334 deps = [
335 "//aos/scoped:scoped_fd",
336 "//aos/util:file",
Austin Schuh99f7c6a2024-06-25 22:07:44 -0700337 "@com_google_absl//absl/log",
338 "@com_google_absl//absl/log:check",
Austin Schuhc97d48d2022-12-26 14:09:13 -0800339 "@com_google_absl//absl/strings",
340 ],
341)
James Kuszmaul0c593962023-01-28 16:04:20 -0800342
343cc_library(
James Kuszmaul77d536c2023-02-11 17:30:59 -0800344 name = "foxglove_image_converter_lib",
345 srcs = ["foxglove_image_converter_lib.cc"],
346 hdrs = ["foxglove_image_converter_lib.h"],
James Kuszmaul0c593962023-01-28 16:04:20 -0800347 visibility = ["//visibility:public"],
348 deps = [
James Kuszmaul59a308f2023-01-28 19:14:07 -0800349 ":charuco_lib",
James Kuszmaul0c593962023-01-28 16:04:20 -0800350 ":vision_fbs",
351 "//aos/events:event_loop",
352 "//third_party:opencv",
353 "@com_github_foxglove_schemas//:schemas",
354 ],
355)
James Kuszmaul59a308f2023-01-28 19:14:07 -0800356
357aos_config(
358 name = "converter_config",
359 testonly = True,
360 src = "converter_test_config.json",
361 flatbuffers = [
362 "//frc971/vision:vision_fbs",
363 "//aos/events:event_loop_fbs",
364 "//aos/logging:log_message_fbs",
365 "//aos/network:message_bridge_client_fbs",
366 "//aos/network:message_bridge_server_fbs",
367 "//aos/network:timestamp_fbs",
368 "@com_github_foxglove_schemas//:schemas",
369 ],
370)
371
372cc_test(
373 name = "foxglove_image_converter_test",
374 srcs = ["foxglove_image_converter_test.cc"],
375 data = [
376 ":converter_config",
377 "@april_tag_test_image",
378 ],
379 deps = [
James Kuszmaul77d536c2023-02-11 17:30:59 -0800380 ":foxglove_image_converter_lib",
James Kuszmaul59a308f2023-01-28 19:14:07 -0800381 "//aos:configuration",
382 "//aos/events:simulated_event_loop",
383 "//aos/testing:googletest",
384 "//aos/testing:path",
385 "//aos/testing:tmpdir",
386 ],
387)
James Kuszmaul7e958812023-02-11 15:34:31 -0800388
389cc_library(
390 name = "intrinsics_calibration_lib",
391 srcs = [
392 "intrinsics_calibration_lib.cc",
393 ],
394 hdrs = [
395 "intrinsics_calibration_lib.h",
396 ],
397 target_compatible_with = ["@platforms//os:linux"],
398 deps = [
399 "//aos/events:event_loop",
400 "//frc971/control_loops/drivetrain:improved_down_estimator",
401 "//frc971/vision:charuco_lib",
402 "//frc971/vision:vision_fbs",
Jim Ostrowskib974cca2024-01-28 15:07:50 -0800403 "//frc971/vision:vision_util_lib",
James Kuszmaul7e958812023-02-11 15:34:31 -0800404 "//frc971/wpilib:imu_batch_fbs",
405 "//frc971/wpilib:imu_fbs",
406 "//third_party:opencv",
407 "@com_google_absl//absl/strings:str_format",
408 "@org_tuxfamily_eigen//:eigen",
409 ],
410)
411
412cc_binary(
413 name = "intrinsics_calibration",
414 srcs = [
415 "intrinsics_calibration.cc",
416 ],
417 target_compatible_with = ["@platforms//os:linux"],
Yash Maheshwarie0b25c52024-05-22 20:23:36 -0700418 visibility = ["//visibility:public"],
James Kuszmaul7e958812023-02-11 15:34:31 -0800419 deps = [
420 ":intrinsics_calibration_lib",
421 "//aos:init",
422 "//aos/events:shm_event_loop",
423 "//frc971/control_loops/drivetrain:improved_down_estimator",
424 "//frc971/vision:charuco_lib",
425 "//frc971/vision:vision_fbs",
426 "//frc971/wpilib:imu_batch_fbs",
427 "//frc971/wpilib:imu_fbs",
428 "//third_party:opencv",
429 "@com_google_absl//absl/strings:str_format",
430 "@org_tuxfamily_eigen//:eigen",
431 ],
432)
Jim Ostrowskicb8b4082024-01-21 02:23:46 -0800433
434cc_library(
435 name = "vision_util_lib",
436 srcs = ["vision_util_lib.cc"],
437 hdrs = ["vision_util_lib.h"],
438 visibility = ["//visibility:public"],
439 deps = [
440 "//frc971/vision:calibration_fbs",
441 "//third_party:opencv",
Austin Schuh99f7c6a2024-06-25 22:07:44 -0700442 "@com_google_absl//absl/log",
443 "@com_google_absl//absl/log:check",
Jim Ostrowski33208982024-03-02 15:01:45 -0800444 "@com_google_absl//absl/strings:str_format",
Jim Ostrowskicb8b4082024-01-21 02:23:46 -0800445 ],
446)
Jim Ostrowskib974cca2024-01-28 15:07:50 -0800447
448cc_test(
449 name = "vision_util_lib_test",
450 srcs = ["vision_util_lib_test.cc"],
451 visibility = ["//visibility:public"],
452 deps = [
453 "//aos/testing:googletest",
454 "//frc971/vision:vision_util_lib",
Austin Schuh99f7c6a2024-06-25 22:07:44 -0700455 "@com_google_absl//absl/log",
456 "@com_google_absl//absl/log:check",
Jim Ostrowskib974cca2024-01-28 15:07:50 -0800457 ],
458)
James Kuszmaul9c3db182024-02-09 22:02:18 -0800459
460cc_library(
461 name = "target_map_utils",
462 srcs = ["target_map_utils.cc"],
463 hdrs = ["target_map_utils.h"],
464 visibility = ["//visibility:public"],
465 deps = [
466 "//frc971/vision:target_map_fbs",
467 "@org_tuxfamily_eigen//:eigen",
468 ],
469)