blob: 65ab20ce1b121af5b1c6ef81f0214d1d5cbecc35 [file] [log] [blame]
Milind Upadhyayd836bce2022-03-25 21:49:57 -07001load("@com_github_google_flatbuffers//:build_defs.bzl", "flatbuffer_cc_library", "flatbuffer_py_library", "flatbuffer_ts_library")
James Kuszmaulb35e2342022-03-06 15:44:00 -08002load("@npm//@bazel/typescript:index.bzl", "ts_library")
milind-u92195982022-01-22 20:29:31 -08003
Jim Ostrowski007e2ea2022-01-30 13:13:26 -08004flatbuffer_cc_library(
5 name = "calibration_fbs",
6 srcs = ["calibration.fbs"],
7 gen_reflections = 1,
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -08008 target_compatible_with = ["@platforms//os:linux"],
9 visibility = ["//y2022:__subpackages__"],
Jim Ostrowski007e2ea2022-01-30 13:13:26 -080010)
11
Milind Upadhyayd836bce2022-03-25 21:49:57 -070012flatbuffer_ts_library(
13 name = "calibration_ts_fbs",
14 srcs = ["calibration.fbs"],
15 target_compatible_with = ["@platforms//os:linux"],
16)
17
Jim Ostrowski007e2ea2022-01-30 13:13:26 -080018flatbuffer_py_library(
19 name = "calibration_fbs_python",
20 srcs = [
21 "calibration.fbs",
22 ],
23 namespace = "frc971.vision.calibration",
24 tables = [
25 "CalibrationData",
26 "CameraCalibration",
27 "TransformationMatrix",
28 ],
29 target_compatible_with = ["@platforms//os:linux"],
30 visibility = ["//visibility:public"],
31)
32
James Kuszmaulb35e2342022-03-06 15:44:00 -080033ts_library(
34 name = "vision_plotter",
35 srcs = ["vision_plotter.ts"],
36 target_compatible_with = ["@platforms//os:linux"],
37 visibility = ["//visibility:public"],
38 deps = [
Milind Upadhyayd836bce2022-03-25 21:49:57 -070039 ":target_estimate_ts_fbs",
40 "//aos:configuration_ts_fbs",
James Kuszmaulb35e2342022-03-06 15:44:00 -080041 "//aos/network/www:aos_plotter",
42 "//aos/network/www:colors",
43 "//aos/network/www:proxy",
Milind Upadhyayd836bce2022-03-25 21:49:57 -070044 "//aos/network/www:reflection_ts",
45 "@com_github_google_flatbuffers//reflection:reflection_ts_fbs",
46 "@com_github_google_flatbuffers//ts:flatbuffers_ts",
James Kuszmaulb35e2342022-03-06 15:44:00 -080047 ],
48)
49
Jim Ostrowski007e2ea2022-01-30 13:13:26 -080050py_library(
51 name = "camera_definition",
52 srcs = [
53 "camera_definition.py",
54 ],
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -080055 deps = [
Jim Ostrowski007e2ea2022-01-30 13:13:26 -080056 "//external:python-glog",
57 ],
58)
59
60py_binary(
61 name = "create_calib_file",
62 srcs = [
63 "create_calib_file.py",
64 ],
65 args = [
66 "calibration_data.h",
67 ],
68 data = glob(["calib_files/*.json"]),
69 target_compatible_with = ["@platforms//os:linux"],
70 deps = [
71 ":camera_definition",
72 "//external:python-glog",
73 "//y2022/vision:calibration_fbs_python",
74 "@bazel_tools//tools/python/runfiles",
75 "@opencv_contrib_nonfree_amd64//:python_opencv",
76 ],
77)
78
79genrule(
80 name = "run_calibration_data",
81 outs = [
82 "calibration_data.h",
83 ],
84 cmd = " ".join([
85 "$(location :create_calib_file)",
86 "$(location calibration_data.h)",
87 ]),
88 target_compatible_with = ["@platforms//os:linux"],
89 tools = [
90 ":create_calib_file",
91 ],
92)
93
94cc_library(
95 name = "calibration_data",
96 hdrs = [
97 "calibration_data.h",
98 ],
99 target_compatible_with = ["@platforms//os:linux"],
100 visibility = ["//visibility:public"],
101 deps = [
102 "@com_google_absl//absl/types:span",
Jim Ostrowskiff7b3de2022-01-22 22:20:26 -0800103 ],
104)
105
106cc_library(
107 name = "camera_reader_lib",
108 srcs = [
109 "camera_reader.cc",
110 ],
111 hdrs = [
112 "camera_reader.h",
Jim Ostrowski2a483b32022-02-15 18:19:14 -0800113 "gpio.h",
Jim Ostrowskiff7b3de2022-01-22 22:20:26 -0800114 ],
115 data = [
Austin Schuhc5fa6d92022-02-25 14:36:28 -0800116 "//y2022:aos_config",
Jim Ostrowskiff7b3de2022-01-22 22:20:26 -0800117 ],
118 target_compatible_with = ["@platforms//os:linux"],
119 visibility = ["//y2022:__subpackages__"],
120 deps = [
milind-u92195982022-01-22 20:29:31 -0800121 ":blob_detector_lib",
Jim Ostrowski007e2ea2022-01-30 13:13:26 -0800122 ":calibration_data",
123 ":calibration_fbs",
milind-udb98afa2022-03-01 19:54:57 -0800124 ":geometry_lib",
Henry Speisere45e7a22022-02-04 23:17:01 -0800125 ":target_estimate_fbs",
milind-u92195982022-01-22 20:29:31 -0800126 ":target_estimator_lib",
Jim Ostrowskiff7b3de2022-01-22 22:20:26 -0800127 "//aos:flatbuffer_merge",
128 "//aos/events:event_loop",
Henry Speiser1f34eea2022-01-30 14:35:21 -0800129 "//aos/events:shm_event_loop",
Jim Ostrowskiff7b3de2022-01-22 22:20:26 -0800130 "//aos/network:team_number",
131 "//frc971/vision:v4l2_reader",
132 "//frc971/vision:vision_fbs",
133 "//third_party:opencv",
Milind Upadhyayd67e9cf2022-03-13 13:56:57 -0700134 "//y2022/localizer:localizer_output_fbs",
Jim Ostrowski007e2ea2022-01-30 13:13:26 -0800135 ],
136)
137
138cc_binary(
139 name = "camera_reader",
140 srcs = [
141 "camera_reader_main.cc",
142 ],
143 target_compatible_with = ["@platforms//os:linux"],
144 visibility = ["//y2022:__subpackages__"],
145 deps = [
146 ":camera_reader_lib",
147 "//aos:init",
148 "//aos/events:shm_event_loop",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800149 ],
150)
151
Ravago Jones32bd3cb2022-03-26 15:45:03 -0700152cc_binary(
153 name = "ball_color_detector",
154 srcs = [
155 "ball_color_main.cc",
156 ],
157 target_compatible_with = ["@platforms//os:linux"],
158 visibility = ["//y2022:__subpackages__"],
159 deps = [
160 ":ball_color_lib",
161 "//aos:init",
162 "//aos/events:shm_event_loop",
163 ],
164)
165
166cc_test(
167 name = "ball_color_test",
168 srcs = [
169 "ball_color_test.cc",
170 ],
171 data = [
172 "test_ball_color_image.jpg",
173 ],
174 deps = [
175 ":ball_color_lib",
176 "//aos:json_to_flatbuffer",
177 "//aos/events:simulated_event_loop",
178 "//aos/testing:googletest",
179 "//aos/testing:test_logging",
180 "//y2022:constants",
181 ],
182)
183
184cc_library(
185 name = "ball_color_lib",
186 srcs = [
187 "ball_color.cc",
188 ],
189 hdrs = [
190 "ball_color.h",
191 ],
192 data = [
193 "//y2022:aos_config",
194 ],
195 target_compatible_with = ["@platforms//os:linux"],
196 visibility = ["//y2022:__subpackages__"],
197 deps = [
198 ":ball_color_fbs",
199 "//aos/events:event_loop",
200 "//aos/events:shm_event_loop",
201 "//aos/network:team_number",
202 "//frc971/input:joystick_state_fbs",
203 "//frc971/vision:vision_fbs",
204 "//third_party:opencv",
205 ],
206)
207
208flatbuffer_cc_library(
209 name = "ball_color_fbs",
210 srcs = ["ball_color.fbs"],
211 gen_reflections = 1,
212 includes = [
213 "//frc971/input:joystick_state_fbs_includes",
214 ],
215 target_compatible_with = ["@platforms//os:linux"],
216 visibility = ["//y2022:__subpackages__"],
217)
218
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800219cc_library(
milind-udb98afa2022-03-01 19:54:57 -0800220 name = "geometry_lib",
221 hdrs = [
222 "geometry.h",
223 ],
224 target_compatible_with = ["@platforms//os:linux"],
225 visibility = ["//y2022:__subpackages__"],
226 deps = [
227 "//aos/util:math",
228 "//third_party:opencv",
229 "@com_github_google_glog//:glog",
230 ],
231)
232
233cc_test(
234 name = "geometry_test",
235 srcs = [
236 "geometry_test.cc",
237 ],
238 deps = [
239 ":geometry_lib",
240 "//aos/testing:googletest",
241 ],
242)
243
244cc_library(
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800245 name = "blob_detector_lib",
246 srcs = [
247 "blob_detector.cc",
248 ],
249 hdrs = [
250 "blob_detector.h",
251 ],
252 target_compatible_with = ["@platforms//os:linux"],
253 visibility = ["//y2022:__subpackages__"],
254 deps = [
milind-udb98afa2022-03-01 19:54:57 -0800255 ":geometry_lib",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800256 "//aos/network:team_number",
Milind Upadhyaye7aa40c2022-01-29 22:36:21 -0800257 "//aos/time",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800258 "//third_party:opencv",
259 ],
260)
261
milind-u92195982022-01-22 20:29:31 -0800262cc_library(
263 name = "target_estimator_lib",
264 srcs = [
265 "target_estimator.cc",
266 ],
267 hdrs = [
268 "target_estimator.h",
269 ],
270 target_compatible_with = ["@platforms//os:linux"],
271 visibility = ["//y2022:__subpackages__"],
272 deps = [
Milind Upadhyay8f38ad82022-03-03 10:06:18 -0800273 ":blob_detector_lib",
Milind Upadhyaye2f40d72022-02-24 13:55:53 -0800274 ":calibration_fbs",
milind-u92195982022-01-22 20:29:31 -0800275 ":target_estimate_fbs",
Milind Upadhyayf61e1482022-02-11 20:42:55 -0800276 "//aos/logging",
277 "//aos/time",
278 "//frc971/control_loops:quaternion_utils",
milind-u92195982022-01-22 20:29:31 -0800279 "//third_party:opencv",
milind-ucafdd5d2022-03-01 19:58:57 -0800280 "//y2022:constants",
Milind Upadhyayf61e1482022-02-11 20:42:55 -0800281 "@com_google_absl//absl/strings:str_format",
282 "@com_google_ceres_solver//:ceres",
283 "@org_tuxfamily_eigen//:eigen",
milind-u92195982022-01-22 20:29:31 -0800284 ],
285)
286
287flatbuffer_cc_library(
288 name = "target_estimate_fbs",
289 srcs = ["target_estimate.fbs"],
290 gen_reflections = 1,
Milind Upadhyaye2f40d72022-02-24 13:55:53 -0800291 includes = [
292 ":calibration_fbs_includes",
293 ],
milind-u92195982022-01-22 20:29:31 -0800294 target_compatible_with = ["@platforms//os:linux"],
295 visibility = ["//y2022:__subpackages__"],
296)
297
Milind Upadhyayd836bce2022-03-25 21:49:57 -0700298flatbuffer_ts_library(
299 name = "target_estimate_ts_fbs",
300 srcs = ["target_estimate.fbs"],
301 target_compatible_with = ["@platforms//os:linux"],
302 deps = [
303 ":calibration_ts_fbs",
304 ],
305)
306
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800307cc_binary(
308 name = "viewer",
309 srcs = [
310 "viewer.cc",
311 ],
312 data = [
Austin Schuhc5fa6d92022-02-25 14:36:28 -0800313 "//y2022:aos_config",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800314 ],
315 target_compatible_with = ["@platforms//os:linux"],
316 visibility = ["//y2022:__subpackages__"],
317 deps = [
318 ":blob_detector_lib",
milind-ucafdd5d2022-03-01 19:58:57 -0800319 ":calibration_data",
milind-u92195982022-01-22 20:29:31 -0800320 ":target_estimator_lib",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800321 "//aos:init",
322 "//aos/events:shm_event_loop",
Jim Ostrowski977850f2022-01-22 21:04:22 -0800323 "//frc971/vision:vision_fbs",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800324 "//third_party:opencv",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800325 ],
326)
Austin Schuh3e145882022-02-26 16:48:43 -0800327
328cc_binary(
Milind Upadhyayb7e3c242022-03-12 20:05:25 -0800329 name = "viewer_replay",
330 srcs = [
331 "viewer_replay.cc",
332 ],
333 data = [
334 "//y2022:aos_config",
335 ],
336 target_compatible_with = ["@platforms//os:linux"],
337 visibility = ["//y2022:__subpackages__"],
338 deps = [
339 ":blob_detector_lib",
340 "//aos:init",
341 "//aos/events:simulated_event_loop",
342 "//aos/events/logging:log_reader",
Milind Upadhyaye3215862022-03-24 19:59:19 -0700343 "//frc971/control_loops:control_loops_fbs",
344 "//frc971/control_loops:profiled_subsystem_fbs",
345 "//frc971/control_loops/drivetrain:drivetrain_status_fbs",
346 "//frc971/input:joystick_state_fbs",
Milind Upadhyayb7e3c242022-03-12 20:05:25 -0800347 "//frc971/vision:vision_fbs",
348 "//third_party:opencv",
Milind Upadhyaye3215862022-03-24 19:59:19 -0700349 "//y2022/control_loops/superstructure:superstructure_status_fbs",
Milind Upadhyayb7e3c242022-03-12 20:05:25 -0800350 ],
351)
352
353cc_binary(
Austin Schuh3e145882022-02-26 16:48:43 -0800354 name = "extrinsics_calibration",
355 srcs = [
356 "extrinsics_calibration.cc",
357 ],
358 target_compatible_with = ["@platforms//os:linux"],
359 visibility = ["//y2022:__subpackages__"],
360 deps = [
361 "//aos:init",
362 "//aos/events/logging:log_reader",
363 "//frc971/control_loops:profiled_subsystem_fbs",
364 "//frc971/vision:extrinsics_calibration",
365 "//y2022/control_loops/superstructure:superstructure_status_fbs",
366 ],
367)
James Kuszmaul3eb753d2022-03-12 15:21:12 -0800368
369cc_binary(
370 name = "image_decimator",
371 srcs = ["image_decimator.cc"],
372 visibility = ["//y2022:__subpackages__"],
373 deps = [
374 "//aos:flatbuffers",
375 "//aos:init",
376 "//aos/events:shm_event_loop",
377 "//frc971/vision:vision_fbs",
378 ],
379)