Allow pre-compiling arm trajectories

The robot takes a while before it's usable because it has to re-optimize
the arm trajectories when it runs. This commit takes the outputted c++
from graph_codegen and optimizes the trajectories before the robot
runs. It then puts them into a bfbs which is able to be placed on the
robot and read.

Signed-off-by: Maxwell Henderson <mxwhenderson@gmail.com>
Change-Id: Ic75f9d590d6b89bfd5eed8b804e73c8c84ecec6b
diff --git a/y2023/control_loops/superstructure/arm/BUILD b/y2023/control_loops/superstructure/arm/BUILD
index e1e3392..44b2aac 100644
--- a/y2023/control_loops/superstructure/arm/BUILD
+++ b/y2023/control_loops/superstructure/arm/BUILD
@@ -1,3 +1,5 @@
+load("@com_github_google_flatbuffers//:build_defs.bzl", "flatbuffer_cc_library")
+
 cc_library(
     name = "arm",
     srcs = [
@@ -24,6 +26,39 @@
 )
 
 genrule(
+    name = "generated_arm_trajectory_genrule",
+    outs = [
+        "arm_trajectories_generated.bfbs",
+    ],
+    cmd = "$(location //y2023/control_loops/superstructure/arm:arm_trajectory_generator) --output $(OUTS)",
+    target_compatible_with = ["@platforms//os:linux"],
+    tools = [
+        "//y2023/control_loops/superstructure/arm:arm_trajectory_generator",
+    ],
+    visibility = ["//visibility:public"],
+)
+
+cc_binary(
+    name = "arm_trajectory_generator",
+    srcs = [
+        "arm_trajectory_gen.cc",
+    ],
+    target_compatible_with = ["@platforms//os:linux"],
+    visibility = ["//visibility:public"],
+    deps = [
+        ":arm_constants",
+        ":arm_trajectories_fbs",
+        "//aos:flatbuffers",
+        "//aos:json_to_flatbuffer",
+        "//frc971/control_loops/double_jointed_arm:graph",
+        "//y2023:constants",
+        "//y2023/control_loops/superstructure/arm:generated_graph",
+        "//y2023/control_loops/superstructure/arm:trajectory",
+        "//y2023/control_loops/superstructure/roll:roll_plants",
+    ],
+)
+
+genrule(
     name = "generated_graph_genrule",
     outs = [
         "generated_graph.h",
@@ -36,6 +71,15 @@
     ],
 )
 
+flatbuffer_cc_library(
+    name = "arm_trajectories_fbs",
+    srcs = [
+        "arm_trajectories.fbs",
+    ],
+    gen_reflections = 1,
+    visibility = ["//visibility:public"],
+)
+
 cc_library(
     name = "generated_graph",
     srcs = [
@@ -86,6 +130,7 @@
     srcs = ["trajectory.cc"],
     hdrs = ["trajectory.h"],
     target_compatible_with = ["@platforms//os:linux"],
+    visibility = ["//visibility:public"],
     deps = [
         "//frc971/control_loops:binomial",
         "//frc971/control_loops:dlqr",
@@ -93,6 +138,7 @@
         "//frc971/control_loops:hybrid_state_feedback_loop",
         "//frc971/control_loops/double_jointed_arm:dynamics",
         "//frc971/control_loops/double_jointed_arm:ekf",
+        "//y2023/control_loops/superstructure/arm:arm_trajectories_fbs",
         "@org_tuxfamily_eigen//:eigen",
     ],
 )