Added control panel python and BUILD
Change-Id: I3a975634c7b1ed51aec09403e7ce4b87778da458
diff --git a/y2020/control_loops/python/BUILD b/y2020/control_loops/python/BUILD
index 2d1af66..b9dfbe0 100644
--- a/y2020/control_loops/python/BUILD
+++ b/y2020/control_loops/python/BUILD
@@ -97,6 +97,22 @@
],
)
+py_binary(
+ name = "control_panel",
+ srcs = [
+ "control_panel.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",
srcs = ["__init__.py"],
diff --git a/y2020/control_loops/python/control_panel.py b/y2020/control_loops/python/control_panel.py
new file mode 100644
index 0000000..206a39e
--- /dev/null
+++ b/y2020/control_loops/python/control_panel.py
@@ -0,0 +1,54 @@
+#!/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 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
+
+#TODO(sabina): update moment
+kControlPanel = angular_system.AngularSystemParams(
+ name='ControlPanel',
+ motor=control_loop.BAG(),
+ G=(1.0),
+ J=0.3,
+ 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):
+ if FLAGS.plot:
+ R = numpy.matrix([[numpy.pi / 2.0], [0.0]])
+ angular_system.PlotKick(kControlPanel, R)
+ angular_system.PlotMotion(kControlPanel, R)
+
+ # Write the generated constants out to a file.
+ if len(argv) != 5:
+ glog.fatal(
+ 'Expected .h file name and .cc file name for the control_panel and integral control_panel.'
+ )
+ else:
+ namespaces = ['y2020', 'control_loops', 'superstructure', 'control_panel']
+ angular_system.WriteAngularSystem(kControlPanel, 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/control_panel/BUILD b/y2020/control_loops/superstructure/control_panel/BUILD
new file mode 100644
index 0000000..75619ca
--- /dev/null
+++ b/y2020/control_loops/superstructure/control_panel/BUILD
@@ -0,0 +1,32 @@
+package(default_visibility = ["//y2020:__subpackages__"])
+
+genrule(
+ name = "genrule_control_panel",
+ outs = [
+ "control_panel_plant.h",
+ "control_panel_plant.cc",
+ "integral_control_panel_plant.h",
+ "integral_control_panel_plant.cc",
+ ],
+ cmd = "$(location //y2020/control_loops/python:control_panel) $(OUTS)",
+ tools = [
+ "//y2020/control_loops/python:control_panel",
+ ],
+)
+
+cc_library(
+ name = "control_panel_plants",
+ srcs = [
+ "control_panel_plant.cc",
+ "integral_control_panel_plant.cc",
+ ],
+ hdrs = [
+ "control_panel_plant.h",
+ "integral_control_panel_plant.h",
+ ],
+ visibility = ["//visibility:public"],
+ deps = [
+ "//frc971/control_loops:hybrid_state_feedback_loop",
+ "//frc971/control_loops:state_feedback_loop",
+ ],
+)