Convert aos over to flatbuffers

Everything builds, and all the tests pass.  I suspect that some entries
are missing from the config files, but those will be found pretty
quickly on startup.

There is no logging or live introspection of queue messages.

Change-Id: I496ee01ed68f202c7851bed7e8786cee30df29f5
diff --git a/y2017/control_loops/superstructure/intake/BUILD b/y2017/control_loops/superstructure/intake/BUILD
index 164a63b..43f4927 100644
--- a/y2017/control_loops/superstructure/intake/BUILD
+++ b/y2017/control_loops/superstructure/intake/BUILD
@@ -1,46 +1,46 @@
 genrule(
-  name = 'genrule_intake',
-  cmd = '$(location //y2017/control_loops/python:intake) $(OUTS)',
-  tools = [
-    '//y2017/control_loops/python:intake',
-  ],
-  outs = [
-    'intake_plant.h',
-    'intake_plant.cc',
-    'intake_integral_plant.h',
-    'intake_integral_plant.cc',
-  ],
+    name = "genrule_intake",
+    outs = [
+        "intake_plant.h",
+        "intake_plant.cc",
+        "intake_integral_plant.h",
+        "intake_integral_plant.cc",
+    ],
+    cmd = "$(location //y2017/control_loops/python:intake) $(OUTS)",
+    tools = [
+        "//y2017/control_loops/python:intake",
+    ],
 )
 
 cc_library(
-  name = 'intake_plants',
-  visibility = ['//visibility:public'],
-  srcs = [
-    'intake_plant.cc',
-    'intake_integral_plant.cc',
-  ],
-  hdrs = [
-    'intake_plant.h',
-    'intake_integral_plant.h',
-  ],
-  deps = [
-    '//frc971/control_loops:state_feedback_loop',
-  ],
+    name = "intake_plants",
+    srcs = [
+        "intake_integral_plant.cc",
+        "intake_plant.cc",
+    ],
+    hdrs = [
+        "intake_integral_plant.h",
+        "intake_plant.h",
+    ],
+    visibility = ["//visibility:public"],
+    deps = [
+        "//frc971/control_loops:state_feedback_loop",
+    ],
 )
 
 cc_library(
-  name = 'intake',
-  visibility = ['//visibility:public'],
-  srcs = [
-    'intake.cc',
-  ],
-  hdrs = [
-    'intake.h',
-  ],
-  deps = [
-    ':intake_plants',
-    '//frc971/control_loops:profiled_subsystem',
-    '//y2017/control_loops/superstructure:superstructure_queue',
-    '//y2017:constants',
-  ],
+    name = "intake",
+    srcs = [
+        "intake.cc",
+    ],
+    hdrs = [
+        "intake.h",
+    ],
+    visibility = ["//visibility:public"],
+    deps = [
+        ":intake_plants",
+        "//frc971/control_loops:profiled_subsystem",
+        "//y2017:constants",
+        "//y2017/control_loops/superstructure:superstructure_goal_fbs",
+    ],
 )
diff --git a/y2017/control_loops/superstructure/intake/intake.cc b/y2017/control_loops/superstructure/intake/intake.cc
index baa4693..ee631d7 100644
--- a/y2017/control_loops/superstructure/intake/intake.cc
+++ b/y2017/control_loops/superstructure/intake/intake.cc
@@ -29,10 +29,11 @@
   disable_count_ = 0;
 }
 
-void Intake::Iterate(
-    const control_loops::IntakeGoal *unsafe_goal,
-    const ::frc971::PotAndAbsolutePosition *position, double *output,
-    ::frc971::control_loops::PotAndAbsoluteEncoderProfiledJointStatus *status) {
+flatbuffers::Offset<
+    frc971::control_loops::PotAndAbsoluteEncoderProfiledJointStatus>
+Intake::Iterate(const IntakeGoal *unsafe_goal,
+                const ::frc971::PotAndAbsolutePosition *position,
+                double *output, flatbuffers::FlatBufferBuilder *fbb) {
   bool disable = output == nullptr;
   profiled_subsystem_.Correct(*position);
 
@@ -84,9 +85,9 @@
       }
 
       if (unsafe_goal) {
-        profiled_subsystem_.AdjustProfile(unsafe_goal->profile_params);
-        profiled_subsystem_.set_unprofiled_goal(unsafe_goal->distance);
-        if (unsafe_goal->disable_intake) {
+        profiled_subsystem_.AdjustProfile(unsafe_goal->profile_params());
+        profiled_subsystem_.set_unprofiled_goal(unsafe_goal->distance());
+        if (unsafe_goal->disable_intake()) {
           if (disable_count_ > 100) {
             disable = true;
           }
@@ -133,13 +134,16 @@
     *output = profiled_subsystem_.voltage();
   }
 
-  // Save debug/internal state.
-  // TODO(austin): Save more.
-  status->zeroed = profiled_subsystem_.zeroed();
+  frc971::control_loops::PotAndAbsoluteEncoderProfiledJointStatus::Builder
+      status_builder = profiled_subsystem_.BuildStatus<
+          frc971::control_loops::PotAndAbsoluteEncoderProfiledJointStatus::
+              Builder>(fbb);
 
-  profiled_subsystem_.PopulateStatus(status);
-  status->estopped = (state_ == State::ESTOP);
-  status->state = static_cast<int32_t>(state_);
+  // Save debug/internal state.
+  status_builder.add_estopped((state_ == State::ESTOP));
+  status_builder.add_state(static_cast<int32_t>(state_));
+
+  return status_builder.Finish();
 }
 
 }  // namespace intake
diff --git a/y2017/control_loops/superstructure/intake/intake.h b/y2017/control_loops/superstructure/intake/intake.h
index db1442a..cba3318 100644
--- a/y2017/control_loops/superstructure/intake/intake.h
+++ b/y2017/control_loops/superstructure/intake/intake.h
@@ -3,7 +3,7 @@
 
 #include "frc971/control_loops/profiled_subsystem.h"
 #include "y2017/constants.h"
-#include "y2017/control_loops/superstructure/superstructure.q.h"
+#include "y2017/control_loops/superstructure/superstructure_goal_generated.h"
 
 namespace y2017 {
 namespace control_loops {
@@ -32,10 +32,11 @@
   static constexpr double kZeroingVoltage = 2.5;
   static constexpr double kOperatingVoltage = 12.0;
 
-  void Iterate(const control_loops::IntakeGoal *unsafe_goal,
-               const ::frc971::PotAndAbsolutePosition *position, double *output,
-               ::frc971::control_loops::PotAndAbsoluteEncoderProfiledJointStatus
-                   *status);
+  flatbuffers::Offset<
+      ::frc971::control_loops::PotAndAbsoluteEncoderProfiledJointStatus>
+  Iterate(const IntakeGoal *unsafe_goal,
+          const ::frc971::PotAndAbsolutePosition *position, double *output,
+          flatbuffers::FlatBufferBuilder *fbb);
 
   void Reset();