blob: a26c5075d9a3144cab52a4ef3087ac97d2906245 [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
152cc_library(
milind-udb98afa2022-03-01 19:54:57 -0800153 name = "geometry_lib",
154 hdrs = [
155 "geometry.h",
156 ],
157 target_compatible_with = ["@platforms//os:linux"],
158 visibility = ["//y2022:__subpackages__"],
159 deps = [
160 "//aos/util:math",
161 "//third_party:opencv",
162 "@com_github_google_glog//:glog",
163 ],
164)
165
166cc_test(
167 name = "geometry_test",
168 srcs = [
169 "geometry_test.cc",
170 ],
171 deps = [
172 ":geometry_lib",
173 "//aos/testing:googletest",
174 ],
175)
176
177cc_library(
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800178 name = "blob_detector_lib",
179 srcs = [
180 "blob_detector.cc",
181 ],
182 hdrs = [
183 "blob_detector.h",
184 ],
185 target_compatible_with = ["@platforms//os:linux"],
186 visibility = ["//y2022:__subpackages__"],
187 deps = [
milind-udb98afa2022-03-01 19:54:57 -0800188 ":geometry_lib",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800189 "//aos/network:team_number",
Milind Upadhyaye7aa40c2022-01-29 22:36:21 -0800190 "//aos/time",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800191 "//third_party:opencv",
192 ],
193)
194
milind-u92195982022-01-22 20:29:31 -0800195cc_library(
196 name = "target_estimator_lib",
197 srcs = [
198 "target_estimator.cc",
199 ],
200 hdrs = [
201 "target_estimator.h",
202 ],
203 target_compatible_with = ["@platforms//os:linux"],
204 visibility = ["//y2022:__subpackages__"],
205 deps = [
Milind Upadhyay8f38ad82022-03-03 10:06:18 -0800206 ":blob_detector_lib",
Milind Upadhyaye2f40d72022-02-24 13:55:53 -0800207 ":calibration_fbs",
milind-u92195982022-01-22 20:29:31 -0800208 ":target_estimate_fbs",
Milind Upadhyayf61e1482022-02-11 20:42:55 -0800209 "//aos/logging",
210 "//aos/time",
211 "//frc971/control_loops:quaternion_utils",
milind-u92195982022-01-22 20:29:31 -0800212 "//third_party:opencv",
milind-ucafdd5d2022-03-01 19:58:57 -0800213 "//y2022:constants",
Milind Upadhyayf61e1482022-02-11 20:42:55 -0800214 "@com_google_absl//absl/strings:str_format",
215 "@com_google_ceres_solver//:ceres",
216 "@org_tuxfamily_eigen//:eigen",
milind-u92195982022-01-22 20:29:31 -0800217 ],
218)
219
220flatbuffer_cc_library(
221 name = "target_estimate_fbs",
222 srcs = ["target_estimate.fbs"],
223 gen_reflections = 1,
Milind Upadhyaye2f40d72022-02-24 13:55:53 -0800224 includes = [
225 ":calibration_fbs_includes",
226 ],
milind-u92195982022-01-22 20:29:31 -0800227 target_compatible_with = ["@platforms//os:linux"],
228 visibility = ["//y2022:__subpackages__"],
229)
230
Milind Upadhyayd836bce2022-03-25 21:49:57 -0700231flatbuffer_ts_library(
232 name = "target_estimate_ts_fbs",
233 srcs = ["target_estimate.fbs"],
234 target_compatible_with = ["@platforms//os:linux"],
235 deps = [
236 ":calibration_ts_fbs",
237 ],
238)
239
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800240cc_binary(
241 name = "viewer",
242 srcs = [
243 "viewer.cc",
244 ],
245 data = [
Austin Schuhc5fa6d92022-02-25 14:36:28 -0800246 "//y2022:aos_config",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800247 ],
248 target_compatible_with = ["@platforms//os:linux"],
249 visibility = ["//y2022:__subpackages__"],
250 deps = [
251 ":blob_detector_lib",
milind-ucafdd5d2022-03-01 19:58:57 -0800252 ":calibration_data",
milind-u92195982022-01-22 20:29:31 -0800253 ":target_estimator_lib",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800254 "//aos:init",
255 "//aos/events:shm_event_loop",
Jim Ostrowski977850f2022-01-22 21:04:22 -0800256 "//frc971/vision:vision_fbs",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800257 "//third_party:opencv",
Jim Ostrowskiff0f5e42022-01-22 01:35:31 -0800258 ],
259)
Austin Schuh3e145882022-02-26 16:48:43 -0800260
261cc_binary(
Milind Upadhyayb7e3c242022-03-12 20:05:25 -0800262 name = "viewer_replay",
263 srcs = [
264 "viewer_replay.cc",
265 ],
266 data = [
267 "//y2022:aos_config",
268 ],
269 target_compatible_with = ["@platforms//os:linux"],
270 visibility = ["//y2022:__subpackages__"],
271 deps = [
272 ":blob_detector_lib",
273 "//aos:init",
274 "//aos/events:simulated_event_loop",
275 "//aos/events/logging:log_reader",
Milind Upadhyaye3215862022-03-24 19:59:19 -0700276 "//frc971/control_loops:control_loops_fbs",
277 "//frc971/control_loops:profiled_subsystem_fbs",
278 "//frc971/control_loops/drivetrain:drivetrain_status_fbs",
279 "//frc971/input:joystick_state_fbs",
Milind Upadhyayb7e3c242022-03-12 20:05:25 -0800280 "//frc971/vision:vision_fbs",
281 "//third_party:opencv",
Milind Upadhyaye3215862022-03-24 19:59:19 -0700282 "//y2022/control_loops/superstructure:superstructure_status_fbs",
Milind Upadhyayb7e3c242022-03-12 20:05:25 -0800283 ],
284)
285
286cc_binary(
Austin Schuh3e145882022-02-26 16:48:43 -0800287 name = "extrinsics_calibration",
288 srcs = [
289 "extrinsics_calibration.cc",
290 ],
291 target_compatible_with = ["@platforms//os:linux"],
292 visibility = ["//y2022:__subpackages__"],
293 deps = [
294 "//aos:init",
295 "//aos/events/logging:log_reader",
296 "//frc971/control_loops:profiled_subsystem_fbs",
297 "//frc971/vision:extrinsics_calibration",
298 "//y2022/control_loops/superstructure:superstructure_status_fbs",
299 ],
300)
James Kuszmaul3eb753d2022-03-12 15:21:12 -0800301
302cc_binary(
303 name = "image_decimator",
304 srcs = ["image_decimator.cc"],
305 visibility = ["//y2022:__subpackages__"],
306 deps = [
307 "//aos:flatbuffers",
308 "//aos:init",
309 "//aos/events:shm_event_loop",
310 "//frc971/vision:vision_fbs",
311 ],
312)