Switch to c++11 enums for flatbuffers

Change-Id: I99171464bf54efbb7eb322c556760dee86648f5e
diff --git a/y2019/control_loops/drivetrain/localized_drivetrain_test.cc b/y2019/control_loops/drivetrain/localized_drivetrain_test.cc
index 3a6bec7..24dd6c2 100644
--- a/y2019/control_loops/drivetrain/localized_drivetrain_test.cc
+++ b/y2019/control_loops/drivetrain/localized_drivetrain_test.cc
@@ -212,7 +212,7 @@
 
     Goal::Builder drivetrain_builder = builder.MakeBuilder<Goal>();
     drivetrain_builder.add_controller_type(
-        frc971::control_loops::drivetrain::ControllerType_MOTION_PROFILE);
+        frc971::control_loops::drivetrain::ControllerType::MOTION_PROFILE);
     drivetrain_builder.add_left_goal(-1.0);
     drivetrain_builder.add_right_goal(1.0);
 
@@ -233,7 +233,7 @@
 
     Goal::Builder drivetrain_builder = builder.MakeBuilder<Goal>();
     drivetrain_builder.add_controller_type(
-        frc971::control_loops::drivetrain::ControllerType_MOTION_PROFILE);
+        frc971::control_loops::drivetrain::ControllerType::MOTION_PROFILE);
     drivetrain_builder.add_left_goal(-1.0);
     drivetrain_builder.add_right_goal(1.0);
 
@@ -253,7 +253,7 @@
 
     Goal::Builder drivetrain_builder = builder.MakeBuilder<Goal>();
     drivetrain_builder.add_controller_type(
-        frc971::control_loops::drivetrain::ControllerType_MOTION_PROFILE);
+        frc971::control_loops::drivetrain::ControllerType::MOTION_PROFILE);
     drivetrain_builder.add_left_goal(-1.0);
     drivetrain_builder.add_right_goal(1.0);
 
@@ -275,7 +275,7 @@
 
     Goal::Builder drivetrain_builder = builder.MakeBuilder<Goal>();
     drivetrain_builder.add_controller_type(
-        frc971::control_loops::drivetrain::ControllerType_MOTION_PROFILE);
+        frc971::control_loops::drivetrain::ControllerType::MOTION_PROFILE);
     drivetrain_builder.add_left_goal(-1.0);
     drivetrain_builder.add_right_goal(1.0);
 
@@ -304,7 +304,7 @@
 
     Goal::Builder drivetrain_builder = builder.MakeBuilder<Goal>();
     drivetrain_builder.add_controller_type(
-        frc971::control_loops::drivetrain::ControllerType_MOTION_PROFILE);
+        frc971::control_loops::drivetrain::ControllerType::MOTION_PROFILE);
     drivetrain_builder.add_left_goal(-1.0);
     drivetrain_builder.add_right_goal(1.0);
 
@@ -340,7 +340,7 @@
 
     Goal::Builder drivetrain_builder = builder.MakeBuilder<Goal>();
     drivetrain_builder.add_controller_type(
-        frc971::control_loops::drivetrain::ControllerType_MOTION_PROFILE);
+        frc971::control_loops::drivetrain::ControllerType::MOTION_PROFILE);
     drivetrain_builder.add_left_goal(-1.0);
     drivetrain_builder.add_right_goal(1.0);
 
@@ -368,7 +368,7 @@
 
     Goal::Builder drivetrain_builder = builder.MakeBuilder<Goal>();
     drivetrain_builder.add_controller_type(
-        frc971::control_loops::drivetrain::ControllerType_LINE_FOLLOWER);
+        frc971::control_loops::drivetrain::ControllerType::LINE_FOLLOWER);
     drivetrain_builder.add_throttle(0.5);
 
     EXPECT_TRUE(builder.Send(drivetrain_builder.Finish()));
diff --git a/y2019/control_loops/drivetrain/localizer_test.cc b/y2019/control_loops/drivetrain/localizer_test.cc
index fbce275..319065e 100644
--- a/y2019/control_loops/drivetrain/localizer_test.cc
+++ b/y2019/control_loops/drivetrain/localizer_test.cc
@@ -178,7 +178,7 @@
 
       goal_builder.add_spline(spline_offset);
       goal_builder.add_controller_type(
-          frc971::control_loops::drivetrain::ControllerType_SPLINE_FOLLOWER);
+          frc971::control_loops::drivetrain::ControllerType::SPLINE_FOLLOWER);
       goal_builder.add_spline_handle(1);
 
       fbb.Finish(goal_builder.Finish());
@@ -211,7 +211,7 @@
           status(fbb.Release());
 
       if (status.message().trajectory_logging()->planning_state() ==
-          ::frc971::control_loops::drivetrain::PlanningState_PLANNED) {
+          ::frc971::control_loops::drivetrain::PlanningState::PLANNED) {
         break;
       }
     }
diff --git a/y2019/control_loops/drivetrain/target_selector.cc b/y2019/control_loops/drivetrain/target_selector.cc
index 7f2259d..87115ae 100644
--- a/y2019/control_loops/drivetrain/target_selector.cc
+++ b/y2019/control_loops/drivetrain/target_selector.cc
@@ -28,9 +28,8 @@
   if (hint_fetcher_.Fetch()) {
     VLOG(1) << "selector_hint: " << aos::FlatbufferToJson(hint_fetcher_.get());
     // suggested_target is unsigned so we don't check for >= 0.
-    if (hint_fetcher_->suggested_target() < 4) {
-      target_hint_ =
-          static_cast<SelectionHint>(hint_fetcher_->suggested_target());
+    if (hint_fetcher_->suggested_target() < drivetrain::SelectionHint::MAX) {
+      target_hint_ = hint_fetcher_->suggested_target();
     } else {
       AOS_LOG(ERROR, "Got invalid suggested target.\n");
     }
@@ -64,30 +63,30 @@
       continue;
     }
     switch (target_hint_) {
-      case SelectionHint::kNearShip:
+      case drivetrain::SelectionHint::NEAR_SHIP:
         if (view.target->target_type() !=
             Target::TargetType::kNearSideCargoBay) {
           continue;
         }
         break;
-      case SelectionHint::kMidShip:
+      case drivetrain::SelectionHint::MID_SHIP:
         if (view.target->target_type() !=
             Target::TargetType::kMidSideCargoBay) {
           continue;
         }
         break;
-      case SelectionHint::kFarShip:
+      case drivetrain::SelectionHint::FAR_SHIP:
         if (view.target->target_type() !=
             Target::TargetType::kFarSideCargoBay) {
           continue;
         }
         break;
-      case SelectionHint::kFarRocket:
+      case drivetrain::SelectionHint::FAR_ROCKET:
         if (view.target->target_type() != Target::TargetType::kFarRocket) {
           continue;
         }
         break;
-      case SelectionHint::kNone:
+      case drivetrain::SelectionHint::NONE:
       default:
         break;
     }
diff --git a/y2019/control_loops/drivetrain/target_selector.fbs b/y2019/control_loops/drivetrain/target_selector.fbs
index d264992..f7a3291 100644
--- a/y2019/control_loops/drivetrain/target_selector.fbs
+++ b/y2019/control_loops/drivetrain/target_selector.fbs
@@ -1,7 +1,7 @@
 namespace y2019.control_loops.drivetrain;
 
 // These should match the SelectionHint enum in target_selector.h.
-enum SelectionHint : byte {
+enum SelectionHint : ubyte {
   // No selection, we should just default to whatever.
   NONE,
   // Near, middle, and far targets.
diff --git a/y2019/control_loops/drivetrain/target_selector.h b/y2019/control_loops/drivetrain/target_selector.h
index e75e122..4ab65ef 100644
--- a/y2019/control_loops/drivetrain/target_selector.h
+++ b/y2019/control_loops/drivetrain/target_selector.h
@@ -29,16 +29,6 @@
   typedef TypedCamera<y2019::constants::Field::kNumTargets,
                       /*num_obstacles=*/0, double> FakeCamera;
 
-  enum class SelectionHint {
-    // No hint
-    kNone = 0,
-    // Cargo ship bays
-    kNearShip = 1,
-    kMidShip = 2,
-    kFarShip = 3,
-    kFarRocket = 4,
-  };
-
   TargetSelector(::aos::EventLoop *event_loop);
 
   bool UpdateSelection(const ::Eigen::Matrix<double, 5, 1> &state,
@@ -72,7 +62,7 @@
 
   // Whether we are currently in ball mode.
   bool ball_mode_ = false;
-  SelectionHint target_hint_ = SelectionHint::kNone;
+  drivetrain::SelectionHint target_hint_ = drivetrain::SelectionHint::NONE;
 };
 
 }  // namespace control_loops
diff --git a/y2019/control_loops/drivetrain/target_selector_test.cc b/y2019/control_loops/drivetrain/target_selector_test.cc
index 90ca830..43a0456 100644
--- a/y2019/control_loops/drivetrain/target_selector_test.cc
+++ b/y2019/control_loops/drivetrain/target_selector_test.cc
@@ -118,7 +118,7 @@
         // targets:
         TestParams{(State() << 0.0, 0.0, 0.0, 1.0, 1.0).finished(),
                    /*ball_mode=*/false,
-                   drivetrain::SelectionHint_NONE,
+                   drivetrain::SelectionHint::NONE,
                    1.0,
                    false,
                    {},
@@ -127,43 +127,43 @@
         // anything.
         TestParams{(State() << 4.0, 2.0, M_PI, 0.05, 0.05).finished(),
                    /*ball_mode=*/false,
-                   drivetrain::SelectionHint_NONE,
+                   drivetrain::SelectionHint::NONE,
                    0.05,
                    false,
                    {},
                    /*expected_radius=*/0.0},
         TestParams{(State() << 4.0, 2.0, M_PI, -0.05, -0.05).finished(),
                    /*ball_mode=*/false,
-                   drivetrain::SelectionHint_NONE,
+                   drivetrain::SelectionHint::NONE,
                    -0.05,
                    false,
                    {},
                    /*expected_radius=*/0.0},
         TestParams{(State() << 4.0, 2.0, M_PI, 0.5, 0.5).finished(),
-                   /*ball_mode=*/false, drivetrain::SelectionHint_NONE, 1.0,
+                   /*ball_mode=*/false, drivetrain::SelectionHint::NONE, 1.0,
                    true, HPSlotLeft(), /*expected_radius=*/0.0},
         // Put ourselves between the rocket and cargo ship; we should see the
         // hatches driving one direction and the near cargo ship port the other.
         // We also command a speed opposite the current direction of motion and
         // confirm that that behaves as expected.
         TestParams{(State() << 6.0, 2.0, -M_PI_2, -0.5, -0.5).finished(),
-                   /*ball_mode=*/false, drivetrain::SelectionHint_NONE, 1.0,
+                   /*ball_mode=*/false, drivetrain::SelectionHint::NONE, 1.0,
                    true, CargoNearLeft(), /*expected_radius=*/HatchRadius()},
         TestParams{(State() << 6.0, 2.0, M_PI_2, 0.5, 0.5).finished(),
-                   /*ball_mode=*/false, drivetrain::SelectionHint_NONE, -1.0,
+                   /*ball_mode=*/false, drivetrain::SelectionHint::NONE, -1.0,
                    true, CargoNearLeft(), /*expected_radius=*/HatchRadius()},
         TestParams{(State() << 6.0, 2.0, -M_PI_2, 0.5, 0.5).finished(),
-                   /*ball_mode=*/false, drivetrain::SelectionHint_NONE, -1.0,
+                   /*ball_mode=*/false, drivetrain::SelectionHint::NONE, -1.0,
                    true, RocketHatchFarLeft(),
                    /*expected_radius=*/HatchRadius()},
         TestParams{(State() << 6.0, 2.0, M_PI_2, -0.5, -0.5).finished(),
-                   /*ball_mode=*/false, drivetrain::SelectionHint_NONE, 1.0,
+                   /*ball_mode=*/false, drivetrain::SelectionHint::NONE, 1.0,
                    true, RocketHatchFarLeft(),
                    /*expected_radius=*/HatchRadius()},
         // And we shouldn't see anything spinning in place:
         TestParams{(State() << 6.0, 2.0, M_PI_2, -0.5, 0.5).finished(),
                    /*ball_mode=*/false,
-                   drivetrain::SelectionHint_NONE,
+                   drivetrain::SelectionHint::NONE,
                    0.0,
                    false,
                    {},
@@ -171,7 +171,7 @@
         // Drive backwards off the field--we should not see anything.
         TestParams{(State() << -0.1, 0.0, 0.0, -0.5, -0.5).finished(),
                    /*ball_mode=*/false,
-                   drivetrain::SelectionHint_NONE,
+                   drivetrain::SelectionHint::NONE,
                    -1.0,
                    false,
                    {},
@@ -179,12 +179,12 @@
         // In ball mode, we should be able to see the portal, and get zero
         // radius.
         TestParams{(State() << 6.0, 2.0, M_PI_2, 0.5, 0.5).finished(),
-                   /*ball_mode=*/true, drivetrain::SelectionHint_NONE, 1.0,
+                   /*ball_mode=*/true, drivetrain::SelectionHint::NONE, 1.0,
                    true, RocketPortal(),
                    /*expected_radius=*/0.0},
         // Reversing direction should get cargo ship with zero radius.
         TestParams{(State() << 6.0, 2.0, M_PI_2, 0.5, 0.5).finished(),
-                   /*ball_mode=*/true, drivetrain::SelectionHint_NONE, -1.0,
+                   /*ball_mode=*/true, drivetrain::SelectionHint::NONE, -1.0,
                    true, CargoNearLeft(),
                    /*expected_radius=*/0.0}));