Allow constructing control loops from flatbuffers

The core changes here are to:
* Allow constructing StateFeedbackLoop's from flatbuffers using the
  code in *state_feedback_loop_converters.*
* Add constructors to the single-dof subsystem class to make use of
  this.
* Add code to control_loops.py to generate JSON files with the requisite
  constants (these end up containing identical information to the
  generated .cc files).
* Add interfaces to actually support the new JSON codegen to single-dof
  subsystem classes.
* Convert all of the drivetrains over to generating these. This I mostly
  do so that I can write a test where Iconfirm that the .cc files and
  the JSON files generate exactly the same content.

Change-Id: Iceac48f25ecac96200b7bf992c8f34a15fe6800c
Signed-off-by: James Kuszmaul <jabukuszmaul+collab@gmail.com>
diff --git a/frc971/control_loops/BUILD b/frc971/control_loops/BUILD
index 53d6b27..1c1b797 100644
--- a/frc971/control_loops/BUILD
+++ b/frc971/control_loops/BUILD
@@ -392,6 +392,7 @@
     ],
     deps = [
         ":control_loops_ts_fbs",
+        ":state_feedback_loop_ts_fbs",
     ],
 )
 
@@ -403,6 +404,7 @@
     target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":control_loops_fbs",
+        ":state_feedback_loop_fbs",
     ],
 )
 
@@ -420,6 +422,8 @@
         ":profiled_subsystem_fbs",
         ":simple_capped_state_feedback_loop",
         ":state_feedback_loop",
+        ":state_feedback_loop_converters",
+        "//aos:flatbuffer_merge",
         "//aos/util:trapezoid_profile",
         "//frc971/control_loops:control_loop",
         "//frc971/zeroing",
@@ -549,8 +553,10 @@
     outs = [
         "static_zeroing_single_dof_profiled_subsystem_test_plant.h",
         "static_zeroing_single_dof_profiled_subsystem_test_plant.cc",
+        "static_zeroing_single_dof_profiled_subsystem_test_plant.json",
         "static_zeroing_single_dof_profiled_subsystem_test_integral_plant.h",
         "static_zeroing_single_dof_profiled_subsystem_test_integral_plant.cc",
+        "static_zeroing_single_dof_profiled_subsystem_test_integral_plant.json",
     ],
     cmd = "$(location //frc971/control_loops/python:static_zeroing_single_dof_profiled_subsystem_test) $(OUTS)",
     target_compatible_with = ["@platforms//os:linux"],
@@ -686,3 +692,36 @@
     ],
     target_compatible_with = ["@platforms//os:linux"],
 )
+
+static_flatbuffer(
+    name = "state_feedback_loop_fbs",
+    srcs = ["state_feedback_loop.fbs"],
+    deps = ["//frc971/math:matrix_fbs"],
+)
+
+flatbuffer_ts_library(
+    name = "state_feedback_loop_ts_fbs",
+    srcs = ["state_feedback_loop.fbs"],
+    deps = ["//frc971/math:matrix_ts_fbs"],
+)
+
+cc_library(
+    name = "hybrid_state_feedback_loop_converters",
+    srcs = ["hybrid_state_feedback_loop_converters.h"],
+    deps = [
+        ":hybrid_state_feedback_loop",
+        ":state_feedback_loop_converters",
+        ":state_feedback_loop_fbs",
+        "//frc971/math:flatbuffers_matrix",
+    ],
+)
+
+cc_library(
+    name = "state_feedback_loop_converters",
+    srcs = ["state_feedback_loop_converters.h"],
+    deps = [
+        ":state_feedback_loop",
+        ":state_feedback_loop_fbs",
+        "//frc971/math:flatbuffers_matrix",
+    ],
+)