Move y2023 vision code over to using constants sender
This removes the need for the generated calibration_data.h
Not tested on a pi yet, so I may've messed something up with the
deployment.
Change-Id: Ic46ba861db25033ac21f33f4898cf52afe02f1ab
Signed-off-by: James Kuszmaul <jabukuszmaul+collab@gmail.com>
diff --git a/y2023/vision/vision_util.cc b/y2023/vision/vision_util.cc
new file mode 100644
index 0000000..eed315a
--- /dev/null
+++ b/y2023/vision/vision_util.cc
@@ -0,0 +1,19 @@
+#include "y2023/vision/vision_util.h"
+
+#include "glog/logging.h"
+
+namespace y2023::vision {
+const frc971::vision::calibration::CameraCalibration *FindCameraCalibration(
+ const y2023::Constants &calibration_data, std::string_view node_name) {
+ CHECK(calibration_data.has_cameras());
+ for (const y2023::CameraConfiguration *candidate :
+ *calibration_data.cameras()) {
+ CHECK(candidate->has_calibration());
+ if (candidate->calibration()->node_name()->string_view() != node_name) {
+ continue;
+ }
+ return candidate->calibration();
+ }
+ LOG(FATAL) << ": Failed to find camera calibration for " << node_name;
+}
+} // namespace y2023::vision