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/y2018/vision/BUILD b/y2018/vision/BUILD
index 8e5e950..7bcd402 100644
--- a/y2018/vision/BUILD
+++ b/y2018/vision/BUILD
@@ -1,4 +1,4 @@
-load("//aos/build:queues.bzl", "queue_library")
+load("@com_github_google_flatbuffers//:build_defs.bzl", "flatbuffer_cc_library")
 
 cc_binary(
     name = "image_streamer",
@@ -17,11 +17,12 @@
     ],
 )
 
-queue_library(
-    name = "vision_queue",
+flatbuffer_cc_library(
+    name = "vision_fbs",
     srcs = [
-        "vision.q",
+        "vision.fbs",
     ],
+    gen_reflections = 1,
     visibility = ["//visibility:public"],
 )
 
@@ -32,11 +33,10 @@
     ],
     visibility = ["//visibility:public"],
     deps = [
-        ":vision_queue",
+        ":vision_fbs",
         "//aos:init",
-        "//aos/events:shm-event-loop",
+        "//aos/events:shm_event_loop",
         "//aos/logging",
-        "//aos/logging:queue_logging",
         "//aos/time",
         "//aos/vision/events:udp",
         "//y2018:vision_proto",
diff --git a/y2018/vision/vision.fbs b/y2018/vision/vision.fbs
new file mode 100644
index 0000000..14f8a45
--- /dev/null
+++ b/y2018/vision/vision.fbs
@@ -0,0 +1,9 @@
+namespace y2018.vision;
+
+// Published on ".y2018.vision.vision_status"
+table VisionStatus {
+  high_frame_count:uint;
+  low_frame_count:uint;
+}
+
+root_type VisionStatus;
diff --git a/y2018/vision/vision.q b/y2018/vision/vision.q
deleted file mode 100644
index fb59d69..0000000
--- a/y2018/vision/vision.q
+++ /dev/null
@@ -1,7 +0,0 @@
-package y2018.vision;
-
-// Published on ".y2018.vision.vision_status"
-message VisionStatus {
-  uint32_t high_frame_count;
-  uint32_t low_frame_count;
-};
diff --git a/y2018/vision/vision_status.cc b/y2018/vision/vision_status.cc
index 2f358c5..fdd6ffe 100644
--- a/y2018/vision/vision_status.cc
+++ b/y2018/vision/vision_status.cc
@@ -1,13 +1,12 @@
 #include <netdb.h>
 
-#include "aos/events/shm-event-loop.h"
+#include "aos/events/shm_event_loop.h"
 #include "aos/init.h"
 #include "aos/logging/logging.h"
-#include "aos/logging/queue_logging.h"
 #include "aos/time/time.h"
 #include "aos/vision/events/udp.h"
 #include "y2018/vision.pb.h"
-#include "y2018/vision/vision.q.h"
+#include "y2018/vision/vision_generated.h"
 
 namespace y2018 {
 namespace vision {
@@ -15,23 +14,28 @@
 using aos::monotonic_clock;
 
 int Main() {
+  aos::FlatbufferDetachedBuffer<aos::Configuration> config =
+      aos::configuration::ReadConfig("config.json");
+
   ::aos::events::RXUdpSocket video_rx(5001);
   char data[65507];
   ::y2018::VisionStatus status;
-  ::aos::ShmEventLoop event_loop;
-  ::aos::Sender<::y2018::vision::VisionStatus> vision_status_sender_ =
-      event_loop.MakeSender<::y2018::vision::VisionStatus>(
-          ".y2018.vision.vision_status");
+
+  ::aos::ShmEventLoop event_loop(&config.message());
+  ::aos::Sender<VisionStatus> vision_status_sender_ =
+      event_loop.MakeSender<VisionStatus>("/superstructure");
 
   while (true) {
     const ssize_t rx_size = video_rx.Recv(data, sizeof(data));
     if (rx_size > 0) {
       status.ParseFromArray(data, rx_size);
-      auto new_vision_status = vision_status_sender_.MakeMessage();
-      new_vision_status->high_frame_count = status.high_frame_count();
-      new_vision_status->low_frame_count = status.low_frame_count();
-      AOS_LOG_STRUCT(DEBUG, "vision", *new_vision_status);
-      if (!new_vision_status.Send()) {
+
+      auto builder = vision_status_sender_.MakeBuilder();
+      VisionStatus::Builder vision_status_builder =
+          builder.MakeBuilder<VisionStatus>();
+      vision_status_builder.add_high_frame_count(status.high_frame_count());
+      vision_status_builder.add_low_frame_count(status.low_frame_count());
+      if (!builder.Send(vision_status_builder.Finish())) {
         AOS_LOG(ERROR, "Failed to send vision information\n");
       }
     }