Merge changes If4369697,I4390f59e

* changes:
  Add Turret BUILD and turret.py
  Turret Messages
diff --git a/y2020/control_loops/python/BUILD b/y2020/control_loops/python/BUILD
index 492326b..2d1af66 100644
--- a/y2020/control_loops/python/BUILD
+++ b/y2020/control_loops/python/BUILD
@@ -81,6 +81,21 @@
     ],
 )
 
+py_binary(
+    name = "turret",
+    srcs = [
+        "turret.py",
+    ],
+    legacy_create_init = False,
+    restricted_to = ["//tools:k8"],
+    deps = [
+        ":python_init",
+        "//external:python-gflags",
+        "//external:python-glog",
+        "//frc971/control_loops/python:angular_system",
+        "//frc971/control_loops/python:controls",
+    ],
+)
 
 py_library(
     name = "python_init",
diff --git a/y2020/control_loops/python/turret.py b/y2020/control_loops/python/turret.py
new file mode 100644
index 0000000..58ea7d8
--- /dev/null
+++ b/y2020/control_loops/python/turret.py
@@ -0,0 +1,50 @@
+#!/usr/bin/python
+
+from aos.util.trapezoid_profile import TrapezoidProfile
+from frc971.control_loops.python import control_loop
+from frc971.control_loops.python import angular_system
+from frc971.control_loops.python import controls
+import copy
+import numpy
+import sys
+from matplotlib import pylab
+import gflags
+import glog
+
+FLAGS = gflags.FLAGS
+
+try:
+    gflags.DEFINE_bool('plot', False, 'If true, plot the loop response.')
+except gflags.DuplicateFlagError:
+    pass
+
+kTurret = angular_system.AngularSystemParams(
+    name='Turret',
+    motor=control_loop.Vex775Pro(),
+    #TODO: Update Gear Ratios when they are ready
+    G=(6.0 / 60.0) * (20.0 / 100.0) * (24.0 / 84.0),
+    #TODO: Get number from Bryan (moment of inertia)
+    J=0.30,
+    q_pos=0.20,
+    q_vel=5.0,
+    kalman_q_pos=0.12,
+    kalman_q_vel=2.0,
+    kalman_q_voltage=4.0,
+    kalman_r_position=0.05)
+
+def main(argv):
+    # Write the generated constants out to a file.
+    if len(argv) != 5:
+        glog.fatal(
+            'Expected .h file name and .cc file name for the turret.'
+        )
+    else:
+        namespaces = ['y2020', 'control_loops', 'superstructure', 'turret']
+        angular_system.WriteAngularSystem([kTurret],
+                                          argv[1:3], argv[3:5], namespaces)
+
+
+if __name__ == '__main__':
+    argv = FLAGS(sys.argv)
+    glog.init()
+    sys.exit(main(argv))
diff --git a/y2020/control_loops/superstructure/superstructure_goal.fbs b/y2020/control_loops/superstructure/superstructure_goal.fbs
index c1b3b5a..d6693ca 100644
--- a/y2020/control_loops/superstructure/superstructure_goal.fbs
+++ b/y2020/control_loops/superstructure/superstructure_goal.fbs
@@ -9,8 +9,14 @@
   //0 = Linkage on sprocket is pointing straight up
   //Positive = forward
   intake:frc971.control_loops.StaticZeroingSingleDOFProfiledSubsystemGoal;
+
   //Positive is rollers intaking to Washing Machine.
   roller_voltage:float;
+
+  // 0 = facing the front of the robot. Positive rotates counterclockwise.
+  // TODO(Kai): Define which wrap of the shooter is 0 if it can rotate past
+  // forward more than once.
+  turret:frc971.control_loops.StaticZeroingSingleDOFProfiledSubsystemGoal;
 }
 
 root_type Goal;
diff --git a/y2020/control_loops/superstructure/superstructure_output.fbs b/y2020/control_loops/superstructure/superstructure_output.fbs
index e887cf5..abb15dc 100644
--- a/y2020/control_loops/superstructure/superstructure_output.fbs
+++ b/y2020/control_loops/superstructure/superstructure_output.fbs
@@ -9,6 +9,10 @@
 
   // Voltage sent to rollers on intake. Positive rolls inward.
   intake_roller_voltage:double;
+
+  //Voltage sent to the motors.
+  //Positive rotates counterclockwise from a birds eye view.
+  turret_voltage:double;
 }
 
 root_type Output;
diff --git a/y2020/control_loops/superstructure/superstructure_position.fbs b/y2020/control_loops/superstructure/superstructure_position.fbs
index 62754df..aabcd43 100644
--- a/y2020/control_loops/superstructure/superstructure_position.fbs
+++ b/y2020/control_loops/superstructure/superstructure_position.fbs
@@ -8,6 +8,9 @@
 
   // Position of the intake. 0 when four-bar is vertical, positive extended.
   intake_joint:frc971.AbsolutePosition;
+
+  // See goal for definition of 0
+  turret:frc971.PotAndAbsolutePosition;
 }
 
 root_type Position;
diff --git a/y2020/control_loops/superstructure/superstructure_status.fbs b/y2020/control_loops/superstructure/superstructure_status.fbs
index a230528..f231f17 100644
--- a/y2020/control_loops/superstructure/superstructure_status.fbs
+++ b/y2020/control_loops/superstructure/superstructure_status.fbs
@@ -13,6 +13,7 @@
   //Subsystem status.
   hood:frc971.control_loops.AbsoluteEncoderProfiledJointStatus;
   intake:frc971.control_loops.AbsoluteEncoderProfiledJointStatus;
+  turret:frc971.control_loops.PotAndAbsoluteEncoderProfiledJointStatus;
 }
 
 root_type Status;
diff --git a/y2020/control_loops/superstructure/turret/BUILD b/y2020/control_loops/superstructure/turret/BUILD
new file mode 100644
index 0000000..894d418
--- /dev/null
+++ b/y2020/control_loops/superstructure/turret/BUILD
@@ -0,0 +1,32 @@
+package(default_visibility = ["//y2020:__subpackages__"])
+
+genrule(
+    name = "genrule_turret",
+    outs = [
+        "turret_plant.h",
+        "turret_plant.cc",
+        "integral_turret_plant.h",
+        "integral_turret_plant.cc",
+    ],
+    cmd = "$(location //y2020/control_loops/python:turret) $(OUTS)",
+    tools = [
+        "//y2020/control_loops/python:turret",
+    ],
+)
+
+cc_library(
+    name = "turret_plants",
+    srcs = [
+        "integral_turret_plant.cc",
+        "turret_plant.cc",
+    ],
+    hdrs = [
+        "integral_turret_plant.h",
+        "turret_plant.h",
+    ],
+    visibility = ["//visibility:public"],
+    deps = [
+        "//frc971/control_loops:hybrid_state_feedback_loop",
+        "//frc971/control_loops:state_feedback_loop",
+    ],
+)