blob: 396a2eb76a983654df0829ce8bb4e670c5d4806a [file] [log] [blame]
Austin Schuha1d006e2022-09-14 21:50:42 -07001load("@com_github_google_flatbuffers//:build_defs.bzl", "flatbuffer_cc_library", "flatbuffer_py_library")
2load("@com_github_google_flatbuffers//:typescript.bzl", "flatbuffer_ts_library")
James Kuszmaulb35e2342022-03-06 15:44:00 -08003load("@npm//@bazel/typescript:index.bzl", "ts_library")
milind-u92195982022-01-22 20:29:31 -08004
Jim Ostrowski007e2ea2022-01-30 13:13:26 -08005flatbuffer_cc_library(
6 name = "calibration_fbs",
7 srcs = ["calibration.fbs"],
8 gen_reflections = 1,
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -08009 target_compatible_with = ["@platforms//os:linux"],
10 visibility = ["//y2022:__subpackages__"],
Jim Ostrowski007e2ea2022-01-30 13:13:26 -080011)
12
Milind Upadhyayd836bce2022-03-25 21:49:57 -070013flatbuffer_ts_library(
14 name = "calibration_ts_fbs",
15 srcs = ["calibration.fbs"],
16 target_compatible_with = ["@platforms//os:linux"],
17)
18
Jim Ostrowski007e2ea2022-01-30 13:13:26 -080019flatbuffer_py_library(
20 name = "calibration_fbs_python",
21 srcs = [
22 "calibration.fbs",
23 ],
24 namespace = "frc971.vision.calibration",
25 tables = [
26 "CalibrationData",
27 "CameraCalibration",
28 "TransformationMatrix",
29 ],
30 target_compatible_with = ["@platforms//os:linux"],
31 visibility = ["//visibility:public"],
32)
33
James Kuszmaulb35e2342022-03-06 15:44:00 -080034ts_library(
35 name = "vision_plotter",
36 srcs = ["vision_plotter.ts"],
37 target_compatible_with = ["@platforms//os:linux"],
38 visibility = ["//visibility:public"],
39 deps = [
Milind Upadhyayd836bce2022-03-25 21:49:57 -070040 ":target_estimate_ts_fbs",
41 "//aos:configuration_ts_fbs",
James Kuszmaulb35e2342022-03-06 15:44:00 -080042 "//aos/network/www:aos_plotter",
43 "//aos/network/www:colors",
44 "//aos/network/www:proxy",
Milind Upadhyayd836bce2022-03-25 21:49:57 -070045 "//aos/network/www:reflection_ts",
46 "@com_github_google_flatbuffers//reflection:reflection_ts_fbs",
47 "@com_github_google_flatbuffers//ts:flatbuffers_ts",
James Kuszmaulb35e2342022-03-06 15:44:00 -080048 ],
49)
50
Jim Ostrowski007e2ea2022-01-30 13:13:26 -080051py_library(
52 name = "camera_definition",
53 srcs = [
54 "camera_definition.py",
55 ],
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -080056 deps = [
Jim Ostrowski007e2ea2022-01-30 13:13:26 -080057 "//external:python-glog",
58 ],
59)
60
61py_binary(
62 name = "create_calib_file",
63 srcs = [
64 "create_calib_file.py",
65 ],
66 args = [
67 "calibration_data.h",
68 ],
69 data = glob(["calib_files/*.json"]),
70 target_compatible_with = ["@platforms//os:linux"],
71 deps = [
72 ":camera_definition",
73 "//external:python-glog",
74 "//y2022/vision:calibration_fbs_python",
75 "@bazel_tools//tools/python/runfiles",
76 "@opencv_contrib_nonfree_amd64//:python_opencv",
77 ],
78)
79
80genrule(
81 name = "run_calibration_data",
82 outs = [
83 "calibration_data.h",
84 ],
85 cmd = " ".join([
86 "$(location :create_calib_file)",
87 "$(location calibration_data.h)",
88 ]),
89 target_compatible_with = ["@platforms//os:linux"],
90 tools = [
91 ":create_calib_file",
92 ],
93)
94
95cc_library(
96 name = "calibration_data",
97 hdrs = [
98 "calibration_data.h",
99 ],
100 target_compatible_with = ["@platforms//os:linux"],
101 visibility = ["//visibility:public"],
102 deps = [
103 "@com_google_absl//absl/types:span",
Jim Ostrowskiff7b3de2022-01-22 22:20:26 -0800104 ],
105)
106
107cc_library(
108 name = "camera_reader_lib",
109 srcs = [
110 "camera_reader.cc",
111 ],
112 hdrs = [
113 "camera_reader.h",
Jim Ostrowski2a483b32022-02-15 18:19:14 -0800114 "gpio.h",
Jim Ostrowskiff7b3de2022-01-22 22:20:26 -0800115 ],
116 data = [
Austin Schuhc5fa6d92022-02-25 14:36:28 -0800117 "//y2022:aos_config",
Jim Ostrowskiff7b3de2022-01-22 22:20:26 -0800118 ],
119 target_compatible_with = ["@platforms//os:linux"],
120 visibility = ["//y2022:__subpackages__"],
121 deps = [
milind-u92195982022-01-22 20:29:31 -0800122 ":blob_detector_lib",
Jim Ostrowski007e2ea2022-01-30 13:13:26 -0800123 ":calibration_data",
124 ":calibration_fbs",
milind-udb98afa2022-03-01 19:54:57 -0800125 ":geometry_lib",
Henry Speisere45e7a22022-02-04 23:17:01 -0800126 ":target_estimate_fbs",
milind-u92195982022-01-22 20:29:31 -0800127 ":target_estimator_lib",
Jim Ostrowskiff7b3de2022-01-22 22:20:26 -0800128 "//aos:flatbuffer_merge",
129 "//aos/events:event_loop",
Henry Speiser1f34eea2022-01-30 14:35:21 -0800130 "//aos/events:shm_event_loop",
Jim Ostrowskiff7b3de2022-01-22 22:20:26 -0800131 "//aos/network:team_number",
132 "//frc971/vision:v4l2_reader",
133 "//frc971/vision:vision_fbs",
134 "//third_party:opencv",
Milind Upadhyayd67e9cf2022-03-13 13:56:57 -0700135 "//y2022/localizer:localizer_output_fbs",
Jim Ostrowski007e2ea2022-01-30 13:13:26 -0800136 ],
137)
138
139cc_binary(
140 name = "camera_reader",
141 srcs = [
142 "camera_reader_main.cc",
143 ],
144 target_compatible_with = ["@platforms//os:linux"],
145 visibility = ["//y2022:__subpackages__"],
146 deps = [
147 ":camera_reader_lib",
148 "//aos:init",
149 "//aos/events:shm_event_loop",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800150 ],
151)
152
Ravago Jones32bd3cb2022-03-26 15:45:03 -0700153cc_binary(
154 name = "ball_color_detector",
155 srcs = [
156 "ball_color_main.cc",
157 ],
158 target_compatible_with = ["@platforms//os:linux"],
159 visibility = ["//y2022:__subpackages__"],
160 deps = [
161 ":ball_color_lib",
162 "//aos:init",
163 "//aos/events:shm_event_loop",
164 ],
165)
166
167cc_test(
168 name = "ball_color_test",
169 srcs = [
170 "ball_color_test.cc",
171 ],
172 data = [
173 "test_ball_color_image.jpg",
174 ],
175 deps = [
176 ":ball_color_lib",
177 "//aos:json_to_flatbuffer",
178 "//aos/events:simulated_event_loop",
179 "//aos/testing:googletest",
180 "//aos/testing:test_logging",
181 "//y2022:constants",
182 ],
183)
184
185cc_library(
186 name = "ball_color_lib",
187 srcs = [
188 "ball_color.cc",
189 ],
190 hdrs = [
191 "ball_color.h",
192 ],
193 data = [
194 "//y2022:aos_config",
195 ],
196 target_compatible_with = ["@platforms//os:linux"],
197 visibility = ["//y2022:__subpackages__"],
198 deps = [
199 ":ball_color_fbs",
200 "//aos/events:event_loop",
201 "//aos/events:shm_event_loop",
Ravago Jones32bd3cb2022-03-26 15:45:03 -0700202 "//frc971/input:joystick_state_fbs",
203 "//frc971/vision:vision_fbs",
204 "//third_party:opencv",
Milind Upadhyayc76bb4c2022-09-21 09:31:48 -0700205 "//y2022:constants",
Ravago Jones32bd3cb2022-03-26 15:45:03 -0700206 ],
207)
208
209flatbuffer_cc_library(
210 name = "ball_color_fbs",
211 srcs = ["ball_color.fbs"],
212 gen_reflections = 1,
213 includes = [
214 "//frc971/input:joystick_state_fbs_includes",
215 ],
216 target_compatible_with = ["@platforms//os:linux"],
217 visibility = ["//y2022:__subpackages__"],
218)
219
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800220cc_library(
milind-udb98afa2022-03-01 19:54:57 -0800221 name = "geometry_lib",
222 hdrs = [
223 "geometry.h",
224 ],
225 target_compatible_with = ["@platforms//os:linux"],
226 visibility = ["//y2022:__subpackages__"],
227 deps = [
228 "//aos/util:math",
229 "//third_party:opencv",
230 "@com_github_google_glog//:glog",
231 ],
232)
233
234cc_test(
235 name = "geometry_test",
236 srcs = [
237 "geometry_test.cc",
238 ],
239 deps = [
240 ":geometry_lib",
241 "//aos/testing:googletest",
242 ],
243)
244
245cc_library(
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800246 name = "blob_detector_lib",
247 srcs = [
248 "blob_detector.cc",
249 ],
250 hdrs = [
251 "blob_detector.h",
252 ],
253 target_compatible_with = ["@platforms//os:linux"],
254 visibility = ["//y2022:__subpackages__"],
255 deps = [
milind-udb98afa2022-03-01 19:54:57 -0800256 ":geometry_lib",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800257 "//aos/network:team_number",
Milind Upadhyaye7aa40c2022-01-29 22:36:21 -0800258 "//aos/time",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800259 "//third_party:opencv",
260 ],
261)
262
milind-u92195982022-01-22 20:29:31 -0800263cc_library(
264 name = "target_estimator_lib",
265 srcs = [
266 "target_estimator.cc",
267 ],
268 hdrs = [
269 "target_estimator.h",
270 ],
271 target_compatible_with = ["@platforms//os:linux"],
272 visibility = ["//y2022:__subpackages__"],
273 deps = [
Milind Upadhyay8f38ad82022-03-03 10:06:18 -0800274 ":blob_detector_lib",
Milind Upadhyaye2f40d72022-02-24 13:55:53 -0800275 ":calibration_fbs",
milind-u92195982022-01-22 20:29:31 -0800276 ":target_estimate_fbs",
Milind Upadhyayf61e1482022-02-11 20:42:55 -0800277 "//aos/logging",
278 "//aos/time",
279 "//frc971/control_loops:quaternion_utils",
milind-u92195982022-01-22 20:29:31 -0800280 "//third_party:opencv",
milind-ucafdd5d2022-03-01 19:58:57 -0800281 "//y2022:constants",
Milind Upadhyayf61e1482022-02-11 20:42:55 -0800282 "@com_google_absl//absl/strings:str_format",
283 "@com_google_ceres_solver//:ceres",
284 "@org_tuxfamily_eigen//:eigen",
milind-u92195982022-01-22 20:29:31 -0800285 ],
286)
287
288flatbuffer_cc_library(
289 name = "target_estimate_fbs",
290 srcs = ["target_estimate.fbs"],
291 gen_reflections = 1,
Milind Upadhyaye2f40d72022-02-24 13:55:53 -0800292 includes = [
293 ":calibration_fbs_includes",
294 ],
milind-u92195982022-01-22 20:29:31 -0800295 target_compatible_with = ["@platforms//os:linux"],
296 visibility = ["//y2022:__subpackages__"],
297)
298
Milind Upadhyayd836bce2022-03-25 21:49:57 -0700299flatbuffer_ts_library(
300 name = "target_estimate_ts_fbs",
301 srcs = ["target_estimate.fbs"],
302 target_compatible_with = ["@platforms//os:linux"],
303 deps = [
304 ":calibration_ts_fbs",
305 ],
306)
307
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800308cc_binary(
309 name = "viewer",
310 srcs = [
311 "viewer.cc",
312 ],
313 data = [
Austin Schuhc5fa6d92022-02-25 14:36:28 -0800314 "//y2022:aos_config",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800315 ],
316 target_compatible_with = ["@platforms//os:linux"],
317 visibility = ["//y2022:__subpackages__"],
318 deps = [
319 ":blob_detector_lib",
milind-ucafdd5d2022-03-01 19:58:57 -0800320 ":calibration_data",
Milind Upadhyaya31f0272022-04-03 13:55:22 -0700321 ":camera_reader_lib",
milind-u92195982022-01-22 20:29:31 -0800322 ":target_estimator_lib",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800323 "//aos:init",
324 "//aos/events:shm_event_loop",
Jim Ostrowski977850f2022-01-22 21:04:22 -0800325 "//frc971/vision:vision_fbs",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800326 "//third_party:opencv",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800327 ],
328)
Austin Schuh3e145882022-02-26 16:48:43 -0800329
330cc_binary(
Milind Upadhyayb7e3c242022-03-12 20:05:25 -0800331 name = "viewer_replay",
332 srcs = [
333 "viewer_replay.cc",
334 ],
335 data = [
336 "//y2022:aos_config",
337 ],
338 target_compatible_with = ["@platforms//os:linux"],
339 visibility = ["//y2022:__subpackages__"],
340 deps = [
341 ":blob_detector_lib",
342 "//aos:init",
343 "//aos/events:simulated_event_loop",
344 "//aos/events/logging:log_reader",
Milind Upadhyaye3215862022-03-24 19:59:19 -0700345 "//frc971/control_loops:control_loops_fbs",
346 "//frc971/control_loops:profiled_subsystem_fbs",
347 "//frc971/control_loops/drivetrain:drivetrain_status_fbs",
348 "//frc971/input:joystick_state_fbs",
Milind Upadhyayb7e3c242022-03-12 20:05:25 -0800349 "//frc971/vision:vision_fbs",
350 "//third_party:opencv",
Milind Upadhyaye3215862022-03-24 19:59:19 -0700351 "//y2022/control_loops/superstructure:superstructure_status_fbs",
Milind Upadhyayb7e3c242022-03-12 20:05:25 -0800352 ],
353)
354
355cc_binary(
Austin Schuh3e145882022-02-26 16:48:43 -0800356 name = "extrinsics_calibration",
357 srcs = [
358 "extrinsics_calibration.cc",
359 ],
360 target_compatible_with = ["@platforms//os:linux"],
361 visibility = ["//y2022:__subpackages__"],
362 deps = [
363 "//aos:init",
364 "//aos/events/logging:log_reader",
365 "//frc971/control_loops:profiled_subsystem_fbs",
366 "//frc971/vision:extrinsics_calibration",
367 "//y2022/control_loops/superstructure:superstructure_status_fbs",
368 ],
369)
James Kuszmaul3eb753d2022-03-12 15:21:12 -0800370
371cc_binary(
372 name = "image_decimator",
373 srcs = ["image_decimator.cc"],
374 visibility = ["//y2022:__subpackages__"],
375 deps = [
376 "//aos:flatbuffers",
377 "//aos:init",
378 "//aos/events:shm_event_loop",
379 "//frc971/vision:vision_fbs",
380 ],
381)