blob: 5d8bf7c8da6090161131be8c533b0222d98ff9e3 [file] [log] [blame]
James Kuszmaulf01da392023-12-14 11:22:14 -08001load("//aos/flatbuffers:generate.bzl", "static_flatbuffer")
2load("@com_github_google_flatbuffers//:build_defs.bzl", "flatbuffer_py_library")
James Kuszmaul59a308f2023-01-28 19:14:07 -08003load("//aos:config.bzl", "aos_config")
Austin Schuha1d006e2022-09-14 21:50:42 -07004load("@com_github_google_flatbuffers//:typescript.bzl", "flatbuffer_ts_library")
Jim Ostrowski977850f2022-01-22 21:04:22 -08005
James Kuszmaulf01da392023-12-14 11:22:14 -08006static_flatbuffer(
Jim Ostrowski977850f2022-01-22 21:04:22 -08007 name = "vision_fbs",
8 srcs = ["vision.fbs"],
Jim Ostrowski977850f2022-01-22 21:04:22 -08009 target_compatible_with = ["@platforms//os:linux"],
10 visibility = ["//visibility:public"],
11)
12
13flatbuffer_ts_library(
14 name = "vision_ts_fbs",
15 srcs = ["vision.fbs"],
16 target_compatible_with = ["@platforms//os:linux"],
17 visibility = ["//visibility:public"],
18)
19
James Kuszmaulf01da392023-12-14 11:22:14 -080020static_flatbuffer(
milind-u2f101fc2023-01-21 12:28:49 -080021 name = "calibration_fbs",
22 srcs = ["calibration.fbs"],
milind-u2f101fc2023-01-21 12:28:49 -080023 target_compatible_with = ["@platforms//os:linux"],
24 visibility = ["//visibility:public"],
25)
26
27flatbuffer_ts_library(
28 name = "calibration_ts_fbs",
29 srcs = ["calibration.fbs"],
30 target_compatible_with = ["@platforms//os:linux"],
31 visibility = ["//visibility:public"],
32)
33
Milo Lin13906572023-03-15 20:55:22 -070034flatbuffer_ts_library(
35 name = "target_map_ts_fbs",
36 srcs = ["target_map.fbs"],
37 target_compatible_with = ["@platforms//os:linux"],
38 visibility = ["//visibility:public"],
39)
40
milind-u2f101fc2023-01-21 12:28:49 -080041flatbuffer_py_library(
42 name = "calibration_fbs_python",
43 srcs = [
44 "calibration.fbs",
45 ],
46 namespace = "frc971.vision.calibration",
47 tables = [
48 "CalibrationData",
49 "CameraCalibration",
50 "TransformationMatrix",
51 ],
52 target_compatible_with = ["@platforms//os:linux"],
53 visibility = ["//visibility:public"],
54)
55
milind-u959d6bd2023-01-21 12:32:52 -080056py_library(
57 name = "create_calib_file",
58 srcs = [
59 "create_calib_file.py",
60 ],
61 target_compatible_with = ["@platforms//os:linux"],
62 visibility = ["//visibility:public"],
63 deps = [
64 ":calibration_fbs_python",
65 "@bazel_tools//tools/python/runfiles",
66 "@pip//glog",
67 "@pip//opencv_python",
68 ],
69)
70
Jim Ostrowski977850f2022-01-22 21:04:22 -080071cc_library(
72 name = "v4l2_reader",
73 srcs = [
74 "v4l2_reader.cc",
75 ],
76 hdrs = [
77 "v4l2_reader.h",
78 ],
79 target_compatible_with = ["@platforms//os:linux"],
80 visibility = ["//visibility:public"],
81 deps = [
82 ":vision_fbs",
Ravago Jonesdc524752022-12-27 01:15:13 -080083 "//aos/events:epoll",
Jim Ostrowski977850f2022-01-22 21:04:22 -080084 "//aos/events:event_loop",
85 "//aos/scoped:scoped_fd",
Ravago Jonesc6b919f2023-01-01 21:34:12 -080086 "//aos/util:threaded_consumer",
Jim Ostrowski977850f2022-01-22 21:04:22 -080087 "@com_github_google_glog//:glog",
88 "@com_google_absl//absl/base",
89 ],
90)
Austin Schuhdcb6b362022-02-25 18:06:21 -080091
92cc_library(
93 name = "charuco_lib",
94 srcs = [
95 "charuco_lib.cc",
96 ],
97 hdrs = [
98 "charuco_lib.h",
99 ],
100 target_compatible_with = ["@platforms//os:linux"],
101 visibility = ["//visibility:public"],
102 deps = [
103 "//aos:flatbuffers",
104 "//aos/events:event_loop",
105 "//aos/network:message_bridge_server_fbs",
106 "//aos/network:team_number",
107 "//frc971/control_loops:quaternion_utils",
James Kuszmaul7e958812023-02-11 15:34:31 -0800108 "//frc971/vision:calibration_fbs",
Austin Schuhdcb6b362022-02-25 18:06:21 -0800109 "//frc971/vision:vision_fbs",
110 "//third_party:opencv",
James Kuszmaul969e4ab2023-01-28 16:09:19 -0800111 "@com_github_foxglove_schemas//:schemas",
Austin Schuhdcb6b362022-02-25 18:06:21 -0800112 "@com_github_google_glog//:glog",
113 "@com_google_absl//absl/strings:str_format",
114 "@com_google_absl//absl/types:span",
115 "@org_tuxfamily_eigen//:eigen",
116 ],
117)
118
119cc_library(
120 name = "extrinsics_calibration",
121 srcs = [
122 "calibration_accumulator.cc",
123 "calibration_accumulator.h",
124 "extrinsics_calibration.cc",
125 "extrinsics_calibration.h",
126 ],
127 target_compatible_with = ["@platforms//os:linux"],
128 visibility = ["//visibility:public"],
129 deps = [
130 ":charuco_lib",
James Kuszmaul77d536c2023-02-11 17:30:59 -0800131 ":foxglove_image_converter_lib",
Austin Schuhdcb6b362022-02-25 18:06:21 -0800132 "//aos:init",
133 "//aos/events/logging:log_reader",
134 "//frc971/analysis:in_process_plotter",
135 "//frc971/control_loops/drivetrain:improved_down_estimator",
Jim Ostrowskiba2edd12022-12-03 15:44:37 -0800136 "//frc971/vision:visualize_robot",
Austin Schuhdcb6b362022-02-25 18:06:21 -0800137 "//frc971/wpilib:imu_batch_fbs",
138 "//frc971/wpilib:imu_fbs",
139 "//third_party:opencv",
James Kuszmaul969e4ab2023-01-28 16:09:19 -0800140 "@com_github_foxglove_schemas//:CompressedImage_schema",
141 "@com_github_foxglove_schemas//:ImageAnnotations_schema",
Austin Schuhdcb6b362022-02-25 18:06:21 -0800142 "@com_google_absl//absl/strings:str_format",
143 "@com_google_ceres_solver//:ceres",
144 "@org_tuxfamily_eigen//:eigen",
145 ],
146)
Milind Upadhyayb67c6182022-10-22 13:45:45 -0700147
James Kuszmaulf01da392023-12-14 11:22:14 -0800148static_flatbuffer(
Milind Upadhyaycd677a32022-12-04 13:06:43 -0800149 name = "target_map_fbs",
150 srcs = ["target_map.fbs"],
Milind Upadhyaycd677a32022-12-04 13:06:43 -0800151 target_compatible_with = ["@platforms//os:linux"],
152 visibility = ["//visibility:public"],
153)
154
Milind Upadhyayb67c6182022-10-22 13:45:45 -0700155cc_library(
Milind Upadhyay7c205222022-11-16 18:20:58 -0800156 name = "target_mapper",
157 srcs = ["target_mapper.cc"],
158 hdrs = ["target_mapper.h"],
Yash Chainanid5c7f0d2022-11-19 17:05:57 -0800159 data = ["target_map.json"],
Milind Upadhyay7c205222022-11-16 18:20:58 -0800160 target_compatible_with = ["@platforms//os:linux"],
161 visibility = ["//visibility:public"],
162 deps = [
163 ":geometry_lib",
Milind Upadhyaycd677a32022-12-04 13:06:43 -0800164 ":target_map_fbs",
Milind Upadhyay7c205222022-11-16 18:20:58 -0800165 "//aos/events:simulated_event_loop",
166 "//frc971/control_loops:control_loop",
milind-u8f4e43e2023-04-09 17:11:19 -0700167 "//frc971/vision:visualize_robot",
Milind Upadhyayc5beba12022-12-17 17:41:20 -0800168 "//frc971/vision/ceres:pose_graph_3d_lib",
Milind Upadhyay7c205222022-11-16 18:20:58 -0800169 "//third_party:opencv",
170 "@com_google_ceres_solver//:ceres",
171 "@org_tuxfamily_eigen//:eigen",
172 ],
173)
174
175cc_test(
176 name = "target_mapper_test",
177 srcs = [
178 "target_mapper_test.cc",
179 ],
Milind Upadhyayc5beba12022-12-17 17:41:20 -0800180 data = [":target_map.json"],
Milind Upadhyay7c205222022-11-16 18:20:58 -0800181 target_compatible_with = ["@platforms//os:linux"],
182 deps = [
183 ":target_mapper",
184 "//aos/events:simulated_event_loop",
185 "//aos/testing:googletest",
Milind Upadhyayc5beba12022-12-17 17:41:20 -0800186 "//aos/testing:path",
Milind Upadhyay7c205222022-11-16 18:20:58 -0800187 "//aos/testing:random_seed",
Milind Upadhyayc5beba12022-12-17 17:41:20 -0800188 "//aos/util:math",
Milind Upadhyay7c205222022-11-16 18:20:58 -0800189 ],
190)
191
192cc_library(
Milind Upadhyayb67c6182022-10-22 13:45:45 -0700193 name = "geometry_lib",
194 hdrs = [
195 "geometry.h",
196 ],
197 target_compatible_with = ["@platforms//os:linux"],
198 visibility = ["//visibility:public"],
199 deps = [
200 "//aos/util:math",
201 "//third_party:opencv",
202 "@com_github_google_glog//:glog",
203 ],
204)
205
206cc_test(
207 name = "geometry_test",
208 srcs = [
209 "geometry_test.cc",
210 ],
211 deps = [
212 ":geometry_lib",
213 "//aos/testing:googletest",
214 ],
215)
Jim Ostrowskiba2edd12022-12-03 15:44:37 -0800216
217cc_library(
218 name = "visualize_robot",
219 srcs = [
220 "visualize_robot.cc",
221 ],
222 hdrs = [
223 "visualize_robot.h",
224 ],
Jim Ostrowski49be8232023-03-23 01:00:14 -0700225 visibility = ["//visibility:public"],
Jim Ostrowskiba2edd12022-12-03 15:44:37 -0800226 deps = [
227 "//aos:init",
228 "//third_party:opencv",
229 "@com_google_absl//absl/strings:str_format",
230 "@org_tuxfamily_eigen//:eigen",
231 ],
232)
233
234cc_binary(
235 name = "visualize_robot_sample",
236 srcs = [
237 "visualize_robot_sample.cc",
238 ],
239 target_compatible_with = ["@platforms//os:linux"],
240 visibility = ["//visibility:public"],
241 deps = [
242 "//aos:init",
243 "//frc971/vision:visualize_robot",
244 "//third_party:opencv",
245 "@com_github_google_glog//:glog",
246 "@com_google_ceres_solver//:ceres",
247 "@org_tuxfamily_eigen//:eigen",
248 ],
249)
Austin Schuhc97d48d2022-12-26 14:09:13 -0800250
251cc_library(
252 name = "media_device",
253 srcs = [
254 "media_device.cc",
255 ],
256 hdrs = ["media_device.h"],
257 visibility = ["//visibility:public"],
258 deps = [
259 "//aos/scoped:scoped_fd",
260 "//aos/util:file",
261 "@com_github_google_glog//:glog",
262 "@com_google_absl//absl/strings",
263 ],
264)
James Kuszmaul0c593962023-01-28 16:04:20 -0800265
266cc_library(
James Kuszmaul77d536c2023-02-11 17:30:59 -0800267 name = "foxglove_image_converter_lib",
268 srcs = ["foxglove_image_converter_lib.cc"],
269 hdrs = ["foxglove_image_converter_lib.h"],
James Kuszmaul0c593962023-01-28 16:04:20 -0800270 visibility = ["//visibility:public"],
271 deps = [
James Kuszmaul59a308f2023-01-28 19:14:07 -0800272 ":charuco_lib",
James Kuszmaul0c593962023-01-28 16:04:20 -0800273 ":vision_fbs",
274 "//aos/events:event_loop",
275 "//third_party:opencv",
276 "@com_github_foxglove_schemas//:schemas",
277 ],
278)
James Kuszmaul59a308f2023-01-28 19:14:07 -0800279
280aos_config(
281 name = "converter_config",
282 testonly = True,
283 src = "converter_test_config.json",
284 flatbuffers = [
285 "//frc971/vision:vision_fbs",
286 "//aos/events:event_loop_fbs",
287 "//aos/logging:log_message_fbs",
288 "//aos/network:message_bridge_client_fbs",
289 "//aos/network:message_bridge_server_fbs",
290 "//aos/network:timestamp_fbs",
291 "@com_github_foxglove_schemas//:schemas",
292 ],
293)
294
295cc_test(
296 name = "foxglove_image_converter_test",
297 srcs = ["foxglove_image_converter_test.cc"],
298 data = [
299 ":converter_config",
300 "@april_tag_test_image",
301 ],
302 deps = [
James Kuszmaul77d536c2023-02-11 17:30:59 -0800303 ":foxglove_image_converter_lib",
James Kuszmaul59a308f2023-01-28 19:14:07 -0800304 "//aos:configuration",
305 "//aos/events:simulated_event_loop",
306 "//aos/testing:googletest",
307 "//aos/testing:path",
308 "//aos/testing:tmpdir",
309 ],
310)
James Kuszmaul7e958812023-02-11 15:34:31 -0800311
312cc_library(
313 name = "intrinsics_calibration_lib",
314 srcs = [
315 "intrinsics_calibration_lib.cc",
316 ],
317 hdrs = [
318 "intrinsics_calibration_lib.h",
319 ],
320 target_compatible_with = ["@platforms//os:linux"],
321 deps = [
322 "//aos/events:event_loop",
323 "//frc971/control_loops/drivetrain:improved_down_estimator",
324 "//frc971/vision:charuco_lib",
325 "//frc971/vision:vision_fbs",
326 "//frc971/wpilib:imu_batch_fbs",
327 "//frc971/wpilib:imu_fbs",
328 "//third_party:opencv",
329 "@com_google_absl//absl/strings:str_format",
330 "@org_tuxfamily_eigen//:eigen",
331 ],
332)
333
334cc_binary(
335 name = "intrinsics_calibration",
336 srcs = [
337 "intrinsics_calibration.cc",
338 ],
339 target_compatible_with = ["@platforms//os:linux"],
340 visibility = [
341 "//y2020:__subpackages__",
342 "//y2022:__subpackages__",
343 "//y2023:__subpackages__",
Jim Ostrowski855b7442024-01-20 18:03:09 -0800344 "//y2024:__subpackages__",
James Kuszmaul7e958812023-02-11 15:34:31 -0800345 ],
346 deps = [
347 ":intrinsics_calibration_lib",
348 "//aos:init",
349 "//aos/events:shm_event_loop",
350 "//frc971/control_loops/drivetrain:improved_down_estimator",
351 "//frc971/vision:charuco_lib",
352 "//frc971/vision:vision_fbs",
353 "//frc971/wpilib:imu_batch_fbs",
354 "//frc971/wpilib:imu_fbs",
355 "//third_party:opencv",
356 "@com_google_absl//absl/strings:str_format",
357 "@org_tuxfamily_eigen//:eigen",
358 ],
359)
Jim Ostrowskicb8b4082024-01-21 02:23:46 -0800360
361cc_library(
362 name = "vision_util_lib",
363 srcs = ["vision_util_lib.cc"],
364 hdrs = ["vision_util_lib.h"],
365 visibility = ["//visibility:public"],
366 deps = [
367 "//frc971/vision:calibration_fbs",
368 "//third_party:opencv",
369 "@com_github_google_glog//:glog",
370 ],
371)