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/constants/7971.json b/y2023/constants/7971.json
new file mode 100644
index 0000000..ded4869
--- /dev/null
+++ b/y2023/constants/7971.json
@@ -0,0 +1,16 @@
+{
+  "cameras": [
+    {
+      "calibration": {% include 'y2023/vision/calib_files/calibration_pi-7971-1_2021-06-12_15-35-39.636386620.json' %}
+    },
+    {
+      "calibration": {% include 'y2023/vision/calib_files/calibration_pi-7971-2_2021-06-12_15-30-20.325393444.json' %}
+    },
+    {
+      "calibration": {% include 'y2023/vision/calib_files/calibration_pi-7971-3_2021-06-12_15-33-31.977365877.json' %}
+    },
+    {
+      "calibration": {% include 'y2023/vision/calib_files/calibration_pi-7971-4_2021-06-12_15-37-25.706564865.json' %}
+    }
+  ]
+}
diff --git a/y2023/constants/BUILD b/y2023/constants/BUILD
new file mode 100644
index 0000000..360ecc2
--- /dev/null
+++ b/y2023/constants/BUILD
@@ -0,0 +1,54 @@
+load("@com_github_google_flatbuffers//:build_defs.bzl", "flatbuffer_cc_library")
+load("//tools/build_rules:template.bzl", "jinja2_template")
+
+cc_library(
+    name = "simulated_constants_sender",
+    testonly = True,
+    srcs = ["simulated_constants_sender.h"],
+    hdrs = ["simulated_constants_sender.cc"],
+    deps = [
+        ":constants_fbs",
+        ":constants_list_fbs",
+        "//aos/events:simulated_event_loop",
+        "//aos/testing:path",
+        "//frc971/constants:constants_sender_lib",
+    ],
+)
+
+jinja2_template(
+    name = "constants.json",
+    src = "constants.jinja2.json",
+    includes = ["//y2023/vision/calib_files"] + ["7971.json"],
+    parameters = {},
+    visibility = ["//visibility:public"],
+)
+
+flatbuffer_cc_library(
+    name = "constants_fbs",
+    srcs = ["constants.fbs"],
+    gen_reflections = True,
+    visibility = ["//visibility:public"],
+    deps = ["//frc971/vision:calibration_fbs"],
+)
+
+flatbuffer_cc_library(
+    name = "constants_list_fbs",
+    srcs = ["constants_list.fbs"],
+    gen_reflections = True,
+    visibility = ["//visibility:public"],
+    deps = [":constants_fbs"],
+)
+
+cc_binary(
+    name = "constants_sender",
+    srcs = ["constants_sender.cc"],
+    visibility = ["//visibility:public"],
+    deps = [
+        ":constants_fbs",
+        ":constants_list_fbs",
+        "//aos:init",
+        "//aos/events:shm_event_loop",
+        "//aos/testing:path",
+        "//frc971/constants:constants_sender_lib",
+    ],
+)
diff --git a/y2023/constants/constants.fbs b/y2023/constants/constants.fbs
new file mode 100644
index 0000000..e62e253
--- /dev/null
+++ b/y2023/constants/constants.fbs
@@ -0,0 +1,13 @@
+include "frc971/vision/calibration.fbs";
+
+namespace y2023;
+
+table CameraConfiguration {
+  calibration:frc971.vision.calibration.CameraCalibration (id: 0);
+}
+
+table Constants {
+  cameras:[CameraConfiguration] (id: 0);
+}
+
+root_type Constants;
diff --git a/y2023/constants/constants.jinja2.json b/y2023/constants/constants.jinja2.json
new file mode 100644
index 0000000..6a8cde9
--- /dev/null
+++ b/y2023/constants/constants.jinja2.json
@@ -0,0 +1,16 @@
+{
+  "constants": [
+    {
+      "team": 7971,
+      "data": {% include 'y2023/constants/7971.json' %}
+    },
+    {
+      "team": 971,
+      "data": {}
+    },
+    {
+      "team": 9971,
+      "data": {}
+    }
+  ]
+}
diff --git a/y2023/constants/constants_list.fbs b/y2023/constants/constants_list.fbs
new file mode 100644
index 0000000..aec10d8
--- /dev/null
+++ b/y2023/constants/constants_list.fbs
@@ -0,0 +1,14 @@
+include "y2023/constants/constants.fbs";
+
+namespace y2023;
+
+table TeamAndConstants {
+  team:long (id: 0);
+  data:Constants (id: 1);
+}
+
+table ConstantsList {
+  constants:[TeamAndConstants] (id: 0);
+}
+
+root_type ConstantsList;
diff --git a/y2023/constants/constants_sender.cc b/y2023/constants/constants_sender.cc
new file mode 100644
index 0000000..77fb24d
--- /dev/null
+++ b/y2023/constants/constants_sender.cc
@@ -0,0 +1,23 @@
+#include "aos/configuration.h"
+#include "aos/events/shm_event_loop.h"
+#include "aos/init.h"
+#include "aos/json_to_flatbuffer.h"
+#include "frc971/constants/constants_sender_lib.h"
+#include "gflags/gflags.h"
+#include "glog/logging.h"
+#include "y2023/constants/constants_generated.h"
+#include "y2023/constants/constants_list_generated.h"
+
+DEFINE_string(config, "aos_config.json", "Path to the AOS config.");
+DEFINE_string(constants_path, "constants.json", "Path to the constant file");
+
+int main(int argc, char **argv) {
+  aos::InitGoogle(&argc, &argv);
+  aos::FlatbufferDetachedBuffer<aos::Configuration> config =
+      aos::configuration::ReadConfig(FLAGS_config);
+  aos::ShmEventLoop event_loop(&config.message());
+  frc971::constants::ConstantSender<y2023::Constants, y2023::ConstantsList>
+      constants_sender(&event_loop, FLAGS_constants_path);
+  // Don't need to call Run().
+  return 0;
+}
diff --git a/y2023/constants/simulated_constants_sender.cc b/y2023/constants/simulated_constants_sender.cc
new file mode 100644
index 0000000..3086e99
--- /dev/null
+++ b/y2023/constants/simulated_constants_sender.cc
@@ -0,0 +1,18 @@
+#include "y2023/constants/constants_generated.h"
+#include "y2023/constants/constants_list_generated.h"
+#include "aos/events/simulated_event_loop.h"
+#include "aos/testing/path.h"
+
+namespace y2023 {
+void SendSimulationConstants(aos::SimulatedEventLoopFactory *factory, int team,
+                             std::string constants_path) {
+  for (const aos::Node *node : factory->nodes()) {
+    std::unique_ptr<aos::EventLoop> event_loop =
+        factory->MakeEventLoop("constants_sender", node);
+    frc971::constants::ConstantSender<Constants, ConstantsList> sender(
+        event_loop.get(), constants_path, team, "/constants");
+  }
+}
+}  // namespace y2023
+
+#endif  // Y2023_CONFIGURATION_SIMULATED_CONFIG_SENDER_H_
diff --git a/y2023/constants/simulated_constants_sender.h b/y2023/constants/simulated_constants_sender.h
new file mode 100644
index 0000000..10ea793
--- /dev/null
+++ b/y2023/constants/simulated_constants_sender.h
@@ -0,0 +1,13 @@
+#ifndef Y2023_CONSTANTS_SIMULATED_CONFIG_SENDER_H_
+#define Y2023_CONSTANTS_SIMULATED_CONFIG_SENDER_H_
+
+#include "aos/events/simulated_event_loop.h"
+#include "aos/testing/path.h"
+
+namespace y2023 {
+void SendSimulationConstants(aos::SimulatedEventLoopFactory *factory, int team,
+                             std::string constants_path = testing::ArtifactPath(
+                                 "y2023/constants/constants.json"));
+}  // namespace y2023
+
+#endif  // Y2023_CONSTANTS_SIMULATED_CONFIG_SENDER_H_