blob: 133281bfecfffee0e79b0349f0d4fb5d28286c2c [file] [log] [blame]
milind-u2f101fc2023-01-21 12:28:49 -08001load("@com_github_google_flatbuffers//:build_defs.bzl", "flatbuffer_cc_library", "flatbuffer_py_library")
James Kuszmaul59a308f2023-01-28 19:14:07 -08002load("//aos:config.bzl", "aos_config")
Austin Schuha1d006e2022-09-14 21:50:42 -07003load("@com_github_google_flatbuffers//:typescript.bzl", "flatbuffer_ts_library")
Jim Ostrowski977850f2022-01-22 21:04:22 -08004
5flatbuffer_cc_library(
6 name = "vision_fbs",
7 srcs = ["vision.fbs"],
8 gen_reflections = 1,
9 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
milind-u2f101fc2023-01-21 12:28:49 -080020flatbuffer_cc_library(
21 name = "calibration_fbs",
22 srcs = ["calibration.fbs"],
23 gen_reflections = 1,
24 target_compatible_with = ["@platforms//os:linux"],
25 visibility = ["//visibility:public"],
26)
27
28flatbuffer_ts_library(
29 name = "calibration_ts_fbs",
30 srcs = ["calibration.fbs"],
31 target_compatible_with = ["@platforms//os:linux"],
32 visibility = ["//visibility:public"],
33)
34
Milo Lin13906572023-03-15 20:55:22 -070035flatbuffer_ts_library(
36 name = "target_map_ts_fbs",
37 srcs = ["target_map.fbs"],
38 target_compatible_with = ["@platforms//os:linux"],
39 visibility = ["//visibility:public"],
40)
41
milind-u2f101fc2023-01-21 12:28:49 -080042flatbuffer_py_library(
43 name = "calibration_fbs_python",
44 srcs = [
45 "calibration.fbs",
46 ],
47 namespace = "frc971.vision.calibration",
48 tables = [
49 "CalibrationData",
50 "CameraCalibration",
51 "TransformationMatrix",
52 ],
53 target_compatible_with = ["@platforms//os:linux"],
54 visibility = ["//visibility:public"],
55)
56
milind-u959d6bd2023-01-21 12:32:52 -080057py_library(
58 name = "create_calib_file",
59 srcs = [
60 "create_calib_file.py",
61 ],
62 target_compatible_with = ["@platforms//os:linux"],
63 visibility = ["//visibility:public"],
64 deps = [
65 ":calibration_fbs_python",
66 "@bazel_tools//tools/python/runfiles",
67 "@pip//glog",
68 "@pip//opencv_python",
69 ],
70)
71
Jim Ostrowski977850f2022-01-22 21:04:22 -080072cc_library(
73 name = "v4l2_reader",
74 srcs = [
75 "v4l2_reader.cc",
76 ],
77 hdrs = [
78 "v4l2_reader.h",
79 ],
80 target_compatible_with = ["@platforms//os:linux"],
81 visibility = ["//visibility:public"],
82 deps = [
83 ":vision_fbs",
Ravago Jonesdc524752022-12-27 01:15:13 -080084 "//aos/events:epoll",
Jim Ostrowski977850f2022-01-22 21:04:22 -080085 "//aos/events:event_loop",
86 "//aos/scoped:scoped_fd",
Ravago Jonesc6b919f2023-01-01 21:34:12 -080087 "//aos/util:threaded_consumer",
Jim Ostrowski977850f2022-01-22 21:04:22 -080088 "@com_github_google_glog//:glog",
89 "@com_google_absl//absl/base",
90 ],
91)
Austin Schuhdcb6b362022-02-25 18:06:21 -080092
93cc_library(
94 name = "charuco_lib",
95 srcs = [
96 "charuco_lib.cc",
97 ],
98 hdrs = [
99 "charuco_lib.h",
100 ],
101 target_compatible_with = ["@platforms//os:linux"],
102 visibility = ["//visibility:public"],
103 deps = [
104 "//aos:flatbuffers",
105 "//aos/events:event_loop",
106 "//aos/network:message_bridge_server_fbs",
107 "//aos/network:team_number",
108 "//frc971/control_loops:quaternion_utils",
James Kuszmaul7e958812023-02-11 15:34:31 -0800109 "//frc971/vision:calibration_fbs",
Austin Schuhdcb6b362022-02-25 18:06:21 -0800110 "//frc971/vision:vision_fbs",
111 "//third_party:opencv",
James Kuszmaul969e4ab2023-01-28 16:09:19 -0800112 "@com_github_foxglove_schemas//:schemas",
Austin Schuhdcb6b362022-02-25 18:06:21 -0800113 "@com_github_google_glog//:glog",
114 "@com_google_absl//absl/strings:str_format",
115 "@com_google_absl//absl/types:span",
116 "@org_tuxfamily_eigen//:eigen",
117 ],
118)
119
120cc_library(
121 name = "extrinsics_calibration",
122 srcs = [
123 "calibration_accumulator.cc",
124 "calibration_accumulator.h",
125 "extrinsics_calibration.cc",
126 "extrinsics_calibration.h",
127 ],
128 target_compatible_with = ["@platforms//os:linux"],
129 visibility = ["//visibility:public"],
130 deps = [
131 ":charuco_lib",
James Kuszmaul77d536c2023-02-11 17:30:59 -0800132 ":foxglove_image_converter_lib",
Austin Schuhdcb6b362022-02-25 18:06:21 -0800133 "//aos:init",
134 "//aos/events/logging:log_reader",
135 "//frc971/analysis:in_process_plotter",
136 "//frc971/control_loops/drivetrain:improved_down_estimator",
Jim Ostrowskiba2edd12022-12-03 15:44:37 -0800137 "//frc971/vision:visualize_robot",
Austin Schuhdcb6b362022-02-25 18:06:21 -0800138 "//frc971/wpilib:imu_batch_fbs",
139 "//frc971/wpilib:imu_fbs",
140 "//third_party:opencv",
James Kuszmaul969e4ab2023-01-28 16:09:19 -0800141 "@com_github_foxglove_schemas//:CompressedImage_schema",
142 "@com_github_foxglove_schemas//:ImageAnnotations_schema",
Austin Schuhdcb6b362022-02-25 18:06:21 -0800143 "@com_google_absl//absl/strings:str_format",
144 "@com_google_ceres_solver//:ceres",
145 "@org_tuxfamily_eigen//:eigen",
146 ],
147)
Milind Upadhyayb67c6182022-10-22 13:45:45 -0700148
Milind Upadhyaycd677a32022-12-04 13:06:43 -0800149flatbuffer_cc_library(
150 name = "target_map_fbs",
151 srcs = ["target_map.fbs"],
152 gen_reflections = 1,
153 target_compatible_with = ["@platforms//os:linux"],
154 visibility = ["//visibility:public"],
155)
156
Milind Upadhyayb67c6182022-10-22 13:45:45 -0700157cc_library(
Milind Upadhyay7c205222022-11-16 18:20:58 -0800158 name = "target_mapper",
159 srcs = ["target_mapper.cc"],
160 hdrs = ["target_mapper.h"],
Yash Chainanid5c7f0d2022-11-19 17:05:57 -0800161 data = ["target_map.json"],
Milind Upadhyay7c205222022-11-16 18:20:58 -0800162 target_compatible_with = ["@platforms//os:linux"],
163 visibility = ["//visibility:public"],
164 deps = [
165 ":geometry_lib",
Milind Upadhyaycd677a32022-12-04 13:06:43 -0800166 ":target_map_fbs",
Milind Upadhyay7c205222022-11-16 18:20:58 -0800167 "//aos/events:simulated_event_loop",
168 "//frc971/control_loops:control_loop",
Milind Upadhyayc5beba12022-12-17 17:41:20 -0800169 "//frc971/vision/ceres:pose_graph_3d_lib",
Milind Upadhyay7c205222022-11-16 18:20:58 -0800170 "//third_party:opencv",
171 "@com_google_ceres_solver//:ceres",
172 "@org_tuxfamily_eigen//:eigen",
173 ],
174)
175
176cc_test(
177 name = "target_mapper_test",
178 srcs = [
179 "target_mapper_test.cc",
180 ],
Milind Upadhyayc5beba12022-12-17 17:41:20 -0800181 data = [":target_map.json"],
Milind Upadhyay7c205222022-11-16 18:20:58 -0800182 target_compatible_with = ["@platforms//os:linux"],
183 deps = [
184 ":target_mapper",
185 "//aos/events:simulated_event_loop",
186 "//aos/testing:googletest",
Milind Upadhyayc5beba12022-12-17 17:41:20 -0800187 "//aos/testing:path",
Milind Upadhyay7c205222022-11-16 18:20:58 -0800188 "//aos/testing:random_seed",
Milind Upadhyayc5beba12022-12-17 17:41:20 -0800189 "//aos/util:math",
Milind Upadhyay7c205222022-11-16 18:20:58 -0800190 ],
191)
192
193cc_library(
Milind Upadhyayb67c6182022-10-22 13:45:45 -0700194 name = "geometry_lib",
195 hdrs = [
196 "geometry.h",
197 ],
198 target_compatible_with = ["@platforms//os:linux"],
199 visibility = ["//visibility:public"],
200 deps = [
201 "//aos/util:math",
202 "//third_party:opencv",
203 "@com_github_google_glog//:glog",
204 ],
205)
206
207cc_test(
208 name = "geometry_test",
209 srcs = [
210 "geometry_test.cc",
211 ],
212 deps = [
213 ":geometry_lib",
214 "//aos/testing:googletest",
215 ],
216)
Jim Ostrowskiba2edd12022-12-03 15:44:37 -0800217
218cc_library(
219 name = "visualize_robot",
220 srcs = [
221 "visualize_robot.cc",
222 ],
223 hdrs = [
224 "visualize_robot.h",
225 ],
Jim Ostrowski49be8232023-03-23 01:00:14 -0700226 visibility = ["//visibility:public"],
Jim Ostrowskiba2edd12022-12-03 15:44:37 -0800227 deps = [
228 "//aos:init",
229 "//third_party:opencv",
230 "@com_google_absl//absl/strings:str_format",
231 "@org_tuxfamily_eigen//:eigen",
232 ],
233)
234
235cc_binary(
236 name = "visualize_robot_sample",
237 srcs = [
238 "visualize_robot_sample.cc",
239 ],
240 target_compatible_with = ["@platforms//os:linux"],
241 visibility = ["//visibility:public"],
242 deps = [
243 "//aos:init",
244 "//frc971/vision:visualize_robot",
245 "//third_party:opencv",
246 "@com_github_google_glog//:glog",
247 "@com_google_ceres_solver//:ceres",
248 "@org_tuxfamily_eigen//:eigen",
249 ],
250)
Austin Schuhc97d48d2022-12-26 14:09:13 -0800251
252cc_library(
253 name = "media_device",
254 srcs = [
255 "media_device.cc",
256 ],
257 hdrs = ["media_device.h"],
258 visibility = ["//visibility:public"],
259 deps = [
260 "//aos/scoped:scoped_fd",
261 "//aos/util:file",
262 "@com_github_google_glog//:glog",
263 "@com_google_absl//absl/strings",
264 ],
265)
James Kuszmaul0c593962023-01-28 16:04:20 -0800266
267cc_library(
James Kuszmaul77d536c2023-02-11 17:30:59 -0800268 name = "foxglove_image_converter_lib",
269 srcs = ["foxglove_image_converter_lib.cc"],
270 hdrs = ["foxglove_image_converter_lib.h"],
James Kuszmaul0c593962023-01-28 16:04:20 -0800271 visibility = ["//visibility:public"],
272 deps = [
James Kuszmaul59a308f2023-01-28 19:14:07 -0800273 ":charuco_lib",
James Kuszmaul0c593962023-01-28 16:04:20 -0800274 ":vision_fbs",
275 "//aos/events:event_loop",
276 "//third_party:opencv",
277 "@com_github_foxglove_schemas//:schemas",
278 ],
279)
James Kuszmaul59a308f2023-01-28 19:14:07 -0800280
281aos_config(
282 name = "converter_config",
283 testonly = True,
284 src = "converter_test_config.json",
285 flatbuffers = [
286 "//frc971/vision:vision_fbs",
287 "//aos/events:event_loop_fbs",
288 "//aos/logging:log_message_fbs",
289 "//aos/network:message_bridge_client_fbs",
290 "//aos/network:message_bridge_server_fbs",
291 "//aos/network:timestamp_fbs",
292 "@com_github_foxglove_schemas//:schemas",
293 ],
294)
295
296cc_test(
297 name = "foxglove_image_converter_test",
298 srcs = ["foxglove_image_converter_test.cc"],
299 data = [
300 ":converter_config",
301 "@april_tag_test_image",
302 ],
303 deps = [
James Kuszmaul77d536c2023-02-11 17:30:59 -0800304 ":foxglove_image_converter_lib",
James Kuszmaul59a308f2023-01-28 19:14:07 -0800305 "//aos:configuration",
306 "//aos/events:simulated_event_loop",
307 "//aos/testing:googletest",
308 "//aos/testing:path",
309 "//aos/testing:tmpdir",
310 ],
311)
James Kuszmaul7e958812023-02-11 15:34:31 -0800312
313cc_library(
314 name = "intrinsics_calibration_lib",
315 srcs = [
316 "intrinsics_calibration_lib.cc",
317 ],
318 hdrs = [
319 "intrinsics_calibration_lib.h",
320 ],
321 target_compatible_with = ["@platforms//os:linux"],
322 deps = [
323 "//aos/events:event_loop",
324 "//frc971/control_loops/drivetrain:improved_down_estimator",
325 "//frc971/vision:charuco_lib",
326 "//frc971/vision:vision_fbs",
327 "//frc971/wpilib:imu_batch_fbs",
328 "//frc971/wpilib:imu_fbs",
329 "//third_party:opencv",
330 "@com_google_absl//absl/strings:str_format",
331 "@org_tuxfamily_eigen//:eigen",
332 ],
333)
334
335cc_binary(
336 name = "intrinsics_calibration",
337 srcs = [
338 "intrinsics_calibration.cc",
339 ],
340 target_compatible_with = ["@platforms//os:linux"],
341 visibility = [
342 "//y2020:__subpackages__",
343 "//y2022:__subpackages__",
344 "//y2023:__subpackages__",
345 ],
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)