blob: 99fb95da5372a448dbde3edc2d1eb50f016bdf3e [file] [log] [blame]
Philipp Schrader3de4dfc2023-02-15 20:18:25 -08001load("//tools/build_rules:js.bzl", "ts_project")
milind-u2f101fc2023-01-21 12:28:49 -08002load("@com_github_google_flatbuffers//:build_defs.bzl", "flatbuffer_cc_library")
Austin Schuha1d006e2022-09-14 21:50:42 -07003load("@com_github_google_flatbuffers//:typescript.bzl", "flatbuffer_ts_library")
milind-u92195982022-01-22 20:29:31 -08004
Philipp Schrader3de4dfc2023-02-15 20:18:25 -08005ts_project(
James Kuszmaulb35e2342022-03-06 15:44:00 -08006 name = "vision_plotter",
7 srcs = ["vision_plotter.ts"],
8 target_compatible_with = ["@platforms//os:linux"],
9 visibility = ["//visibility:public"],
10 deps = [
Milind Upadhyayd836bce2022-03-25 21:49:57 -070011 ":target_estimate_ts_fbs",
12 "//aos:configuration_ts_fbs",
James Kuszmaulb35e2342022-03-06 15:44:00 -080013 "//aos/network/www:aos_plotter",
14 "//aos/network/www:colors",
15 "//aos/network/www:proxy",
Milind Upadhyayd836bce2022-03-25 21:49:57 -070016 "//aos/network/www:reflection_ts",
17 "@com_github_google_flatbuffers//reflection:reflection_ts_fbs",
18 "@com_github_google_flatbuffers//ts:flatbuffers_ts",
James Kuszmaulb35e2342022-03-06 15:44:00 -080019 ],
20)
21
Jim Ostrowski007e2ea2022-01-30 13:13:26 -080022py_library(
23 name = "camera_definition",
24 srcs = [
25 "camera_definition.py",
26 ],
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -080027 deps = [
Philipp Schraderebb658f2022-09-17 17:31:09 -070028 "@pip//glog",
Jim Ostrowski007e2ea2022-01-30 13:13:26 -080029 ],
30)
31
32py_binary(
33 name = "create_calib_file",
34 srcs = [
35 "create_calib_file.py",
36 ],
37 args = [
38 "calibration_data.h",
39 ],
40 data = glob(["calib_files/*.json"]),
41 target_compatible_with = ["@platforms//os:linux"],
42 deps = [
43 ":camera_definition",
milind-u2f101fc2023-01-21 12:28:49 -080044 "//frc971/vision:calibration_fbs_python",
Jim Ostrowski007e2ea2022-01-30 13:13:26 -080045 "@bazel_tools//tools/python/runfiles",
Philipp Schraderebb658f2022-09-17 17:31:09 -070046 "@pip//glog",
47 "@pip//opencv_python",
Jim Ostrowski007e2ea2022-01-30 13:13:26 -080048 ],
49)
50
51genrule(
52 name = "run_calibration_data",
53 outs = [
54 "calibration_data.h",
55 ],
56 cmd = " ".join([
57 "$(location :create_calib_file)",
58 "$(location calibration_data.h)",
59 ]),
60 target_compatible_with = ["@platforms//os:linux"],
61 tools = [
62 ":create_calib_file",
63 ],
64)
65
66cc_library(
67 name = "calibration_data",
68 hdrs = [
69 "calibration_data.h",
70 ],
71 target_compatible_with = ["@platforms//os:linux"],
72 visibility = ["//visibility:public"],
73 deps = [
74 "@com_google_absl//absl/types:span",
Jim Ostrowskiff7b3de2022-01-22 22:20:26 -080075 ],
76)
77
78cc_library(
79 name = "camera_reader_lib",
80 srcs = [
81 "camera_reader.cc",
82 ],
83 hdrs = [
84 "camera_reader.h",
Jim Ostrowski2a483b32022-02-15 18:19:14 -080085 "gpio.h",
Jim Ostrowskiff7b3de2022-01-22 22:20:26 -080086 ],
87 data = [
Austin Schuhc5fa6d92022-02-25 14:36:28 -080088 "//y2022:aos_config",
Jim Ostrowskiff7b3de2022-01-22 22:20:26 -080089 ],
90 target_compatible_with = ["@platforms//os:linux"],
91 visibility = ["//y2022:__subpackages__"],
92 deps = [
milind-u92195982022-01-22 20:29:31 -080093 ":blob_detector_lib",
Jim Ostrowski007e2ea2022-01-30 13:13:26 -080094 ":calibration_data",
Henry Speisere45e7a22022-02-04 23:17:01 -080095 ":target_estimate_fbs",
milind-u92195982022-01-22 20:29:31 -080096 ":target_estimator_lib",
Jim Ostrowskiff7b3de2022-01-22 22:20:26 -080097 "//aos:flatbuffer_merge",
98 "//aos/events:event_loop",
Henry Speiser1f34eea2022-01-30 14:35:21 -080099 "//aos/events:shm_event_loop",
Jim Ostrowskiff7b3de2022-01-22 22:20:26 -0800100 "//aos/network:team_number",
James Kuszmaule3df1ed2023-02-20 16:21:17 -0800101 "//frc971/control_loops/drivetrain/localization:localizer_output_fbs",
milind-u2f101fc2023-01-21 12:28:49 -0800102 "//frc971/vision:calibration_fbs",
Jim Ostrowskiff7b3de2022-01-22 22:20:26 -0800103 "//frc971/vision:v4l2_reader",
104 "//frc971/vision:vision_fbs",
105 "//third_party:opencv",
Jim Ostrowski007e2ea2022-01-30 13:13:26 -0800106 ],
107)
108
109cc_binary(
110 name = "camera_reader",
111 srcs = [
112 "camera_reader_main.cc",
113 ],
114 target_compatible_with = ["@platforms//os:linux"],
115 visibility = ["//y2022:__subpackages__"],
116 deps = [
117 ":camera_reader_lib",
118 "//aos:init",
119 "//aos/events:shm_event_loop",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800120 ],
121)
122
Ravago Jones32bd3cb2022-03-26 15:45:03 -0700123cc_binary(
124 name = "ball_color_detector",
125 srcs = [
126 "ball_color_main.cc",
127 ],
128 target_compatible_with = ["@platforms//os:linux"],
129 visibility = ["//y2022:__subpackages__"],
130 deps = [
131 ":ball_color_lib",
132 "//aos:init",
133 "//aos/events:shm_event_loop",
134 ],
135)
136
137cc_test(
138 name = "ball_color_test",
139 srcs = [
140 "ball_color_test.cc",
141 ],
142 data = [
143 "test_ball_color_image.jpg",
144 ],
145 deps = [
146 ":ball_color_lib",
147 "//aos:json_to_flatbuffer",
148 "//aos/events:simulated_event_loop",
149 "//aos/testing:googletest",
150 "//aos/testing:test_logging",
151 "//y2022:constants",
152 ],
153)
154
155cc_library(
156 name = "ball_color_lib",
157 srcs = [
158 "ball_color.cc",
159 ],
160 hdrs = [
161 "ball_color.h",
162 ],
163 data = [
164 "//y2022:aos_config",
165 ],
166 target_compatible_with = ["@platforms//os:linux"],
167 visibility = ["//y2022:__subpackages__"],
168 deps = [
169 ":ball_color_fbs",
170 "//aos/events:event_loop",
171 "//aos/events:shm_event_loop",
Ravago Jones32bd3cb2022-03-26 15:45:03 -0700172 "//frc971/input:joystick_state_fbs",
173 "//frc971/vision:vision_fbs",
174 "//third_party:opencv",
Milind Upadhyayc76bb4c2022-09-21 09:31:48 -0700175 "//y2022:constants",
Ravago Jones32bd3cb2022-03-26 15:45:03 -0700176 ],
177)
178
179flatbuffer_cc_library(
180 name = "ball_color_fbs",
181 srcs = ["ball_color.fbs"],
182 gen_reflections = 1,
183 includes = [
184 "//frc971/input:joystick_state_fbs_includes",
185 ],
186 target_compatible_with = ["@platforms//os:linux"],
187 visibility = ["//y2022:__subpackages__"],
188)
189
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800190cc_library(
191 name = "blob_detector_lib",
192 srcs = [
193 "blob_detector.cc",
194 ],
195 hdrs = [
196 "blob_detector.h",
197 ],
198 target_compatible_with = ["@platforms//os:linux"],
199 visibility = ["//y2022:__subpackages__"],
200 deps = [
201 "//aos/network:team_number",
Milind Upadhyaye7aa40c2022-01-29 22:36:21 -0800202 "//aos/time",
Milind Upadhyayb67c6182022-10-22 13:45:45 -0700203 "//frc971/vision:geometry_lib",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800204 "//third_party:opencv",
205 ],
206)
207
milind-u92195982022-01-22 20:29:31 -0800208cc_library(
209 name = "target_estimator_lib",
210 srcs = [
211 "target_estimator.cc",
212 ],
213 hdrs = [
214 "target_estimator.h",
215 ],
216 target_compatible_with = ["@platforms//os:linux"],
217 visibility = ["//y2022:__subpackages__"],
218 deps = [
Milind Upadhyay8f38ad82022-03-03 10:06:18 -0800219 ":blob_detector_lib",
milind-u92195982022-01-22 20:29:31 -0800220 ":target_estimate_fbs",
Milind Upadhyayf61e1482022-02-11 20:42:55 -0800221 "//aos/logging",
222 "//aos/time",
223 "//frc971/control_loops:quaternion_utils",
milind-u2f101fc2023-01-21 12:28:49 -0800224 "//frc971/vision:calibration_fbs",
Milind Upadhyayb67c6182022-10-22 13:45:45 -0700225 "//frc971/vision:geometry_lib",
milind-u92195982022-01-22 20:29:31 -0800226 "//third_party:opencv",
milind-ucafdd5d2022-03-01 19:58:57 -0800227 "//y2022:constants",
Milind Upadhyayf61e1482022-02-11 20:42:55 -0800228 "@com_google_absl//absl/strings:str_format",
229 "@com_google_ceres_solver//:ceres",
230 "@org_tuxfamily_eigen//:eigen",
milind-u92195982022-01-22 20:29:31 -0800231 ],
232)
233
234flatbuffer_cc_library(
235 name = "target_estimate_fbs",
236 srcs = ["target_estimate.fbs"],
237 gen_reflections = 1,
Milind Upadhyaye2f40d72022-02-24 13:55:53 -0800238 includes = [
milind-u2f101fc2023-01-21 12:28:49 -0800239 "//frc971/vision:calibration_fbs_includes",
Milind Upadhyaye2f40d72022-02-24 13:55:53 -0800240 ],
milind-u92195982022-01-22 20:29:31 -0800241 target_compatible_with = ["@platforms//os:linux"],
242 visibility = ["//y2022:__subpackages__"],
243)
244
Milind Upadhyayd836bce2022-03-25 21:49:57 -0700245flatbuffer_ts_library(
246 name = "target_estimate_ts_fbs",
247 srcs = ["target_estimate.fbs"],
248 target_compatible_with = ["@platforms//os:linux"],
249 deps = [
milind-u2f101fc2023-01-21 12:28:49 -0800250 "//frc971/vision:calibration_ts_fbs",
Milind Upadhyayd836bce2022-03-25 21:49:57 -0700251 ],
252)
253
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800254cc_binary(
255 name = "viewer",
256 srcs = [
257 "viewer.cc",
258 ],
259 data = [
Austin Schuhc5fa6d92022-02-25 14:36:28 -0800260 "//y2022:aos_config",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800261 ],
262 target_compatible_with = ["@platforms//os:linux"],
263 visibility = ["//y2022:__subpackages__"],
264 deps = [
265 ":blob_detector_lib",
milind-ucafdd5d2022-03-01 19:58:57 -0800266 ":calibration_data",
Milind Upadhyaya31f0272022-04-03 13:55:22 -0700267 ":camera_reader_lib",
milind-u92195982022-01-22 20:29:31 -0800268 ":target_estimator_lib",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800269 "//aos:init",
270 "//aos/events:shm_event_loop",
Jim Ostrowski977850f2022-01-22 21:04:22 -0800271 "//frc971/vision:vision_fbs",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800272 "//third_party:opencv",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800273 ],
274)
Austin Schuh3e145882022-02-26 16:48:43 -0800275
276cc_binary(
Milind Upadhyayb7e3c242022-03-12 20:05:25 -0800277 name = "viewer_replay",
278 srcs = [
279 "viewer_replay.cc",
280 ],
281 data = [
282 "//y2022:aos_config",
283 ],
284 target_compatible_with = ["@platforms//os:linux"],
285 visibility = ["//y2022:__subpackages__"],
286 deps = [
287 ":blob_detector_lib",
288 "//aos:init",
289 "//aos/events:simulated_event_loop",
290 "//aos/events/logging:log_reader",
Milind Upadhyaye3215862022-03-24 19:59:19 -0700291 "//frc971/control_loops:control_loops_fbs",
292 "//frc971/control_loops:profiled_subsystem_fbs",
293 "//frc971/control_loops/drivetrain:drivetrain_status_fbs",
294 "//frc971/input:joystick_state_fbs",
Milind Upadhyayb7e3c242022-03-12 20:05:25 -0800295 "//frc971/vision:vision_fbs",
296 "//third_party:opencv",
Milind Upadhyaye3215862022-03-24 19:59:19 -0700297 "//y2022/control_loops/superstructure:superstructure_status_fbs",
Milind Upadhyayb7e3c242022-03-12 20:05:25 -0800298 ],
299)
300
301cc_binary(
Jim Ostrowskiba2edd12022-12-03 15:44:37 -0800302 name = "calibrate_extrinsics",
Austin Schuh3e145882022-02-26 16:48:43 -0800303 srcs = [
Jim Ostrowskiba2edd12022-12-03 15:44:37 -0800304 "calibrate_extrinsics.cc",
Austin Schuh3e145882022-02-26 16:48:43 -0800305 ],
306 target_compatible_with = ["@platforms//os:linux"],
307 visibility = ["//y2022:__subpackages__"],
308 deps = [
309 "//aos:init",
310 "//aos/events/logging:log_reader",
311 "//frc971/control_loops:profiled_subsystem_fbs",
312 "//frc971/vision:extrinsics_calibration",
Jim Ostrowskiba2edd12022-12-03 15:44:37 -0800313 "//third_party:opencv",
Austin Schuh3e145882022-02-26 16:48:43 -0800314 "//y2022/control_loops/superstructure:superstructure_status_fbs",
315 ],
316)
James Kuszmaul3eb753d2022-03-12 15:21:12 -0800317
318cc_binary(
319 name = "image_decimator",
320 srcs = ["image_decimator.cc"],
321 visibility = ["//y2022:__subpackages__"],
322 deps = [
323 "//aos:flatbuffers",
324 "//aos:init",
325 "//aos/events:shm_event_loop",
326 "//frc971/vision:vision_fbs",
327 ],
328)
milind-ub0773e92023-02-05 15:57:43 -0800329
330filegroup(
331 name = "image_streamer_start",
332 srcs = ["image_streamer_start.sh"],
333 visibility = ["//visibility:public"],
334)