Add Turret BUILD and turret.py
Create turret.py based on the 2019 season's wrist, and turret/BUILD in the superstructure.
Change-Id: If4369697fc1dc8a01740a50b90d9ae5d2491a476
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))