Add StaticZeroingSingleDOFProfiledSubsystem
Change-Id: I7ad67ed8719a229f4f08d8255d4675fa3ee49f18
diff --git a/frc971/control_loops/python/BUILD b/frc971/control_loops/python/BUILD
index a0ee825..b3aa2c0 100644
--- a/frc971/control_loops/python/BUILD
+++ b/frc971/control_loops/python/BUILD
@@ -97,7 +97,7 @@
deps = [
":libspline",
":python_init",
- ]
+ ],
)
py_library(
@@ -166,15 +166,15 @@
py_binary(
name = "path_edit",
srcs = [
- "path_edit.py",
"basic_window.py",
"color.py",
+ "path_edit.py",
],
- visibility = ["//visibility:public"],
restricted_to = ["//tools:k8"],
+ visibility = ["//visibility:public"],
deps = [
- ":python_init",
":libspline",
+ ":python_init",
"@python_gtk",
],
)
@@ -183,10 +183,10 @@
name = "basic_window",
srcs = [
"basic_window.py",
- "color.py"
+ "color.py",
],
- visibility = ["//visibility:public"],
restricted_to = ["//tools:k8"],
+ visibility = ["//visibility:public"],
deps = [
":python_init",
"@python_gtk",
@@ -198,9 +198,25 @@
srcs = [
"color.py",
],
- visibility = ["//visibility:public"],
restricted_to = ["//tools:k8"],
+ visibility = ["//visibility:public"],
deps = [
":python_init",
],
)
+
+py_binary(
+ name = "static_zeroing_single_dof_profiled_subsystem_test",
+ srcs = [
+ "static_zeroing_single_dof_profiled_subsystem_test.py",
+ ],
+ legacy_create_init = False,
+ restricted_to = ["//tools:k8"],
+ deps = [
+ ":controls",
+ ":linear_system",
+ ":python_init",
+ "//external:python-gflags",
+ "//external:python-glog",
+ ],
+)
diff --git a/frc971/control_loops/python/static_zeroing_single_dof_profiled_subsystem_test.py b/frc971/control_loops/python/static_zeroing_single_dof_profiled_subsystem_test.py
new file mode 100644
index 0000000..caa3082
--- /dev/null
+++ b/frc971/control_loops/python/static_zeroing_single_dof_profiled_subsystem_test.py
@@ -0,0 +1,56 @@
+#!/usr/bin/python
+
+# Generates profiled subsystem for use in
+# static_zeroing_single_dof_profiled_subsystem_test
+
+from frc971.control_loops.python import control_loop
+from frc971.control_loops.python import linear_system
+import numpy
+import sys
+import gflags
+import glog
+
+FLAGS = gflags.FLAGS
+
+try:
+ gflags.DEFINE_bool('plot', False, 'If true, plot the loop response.')
+except gflags.DuplicateFlagError:
+ pass
+
+kIntake = linear_system.LinearSystemParams(
+ name='TestIntakeSystem',
+ motor=control_loop.Vex775Pro(),
+ # (1 / 35.0) * (20.0 / 40.0) -> 16 tooth sprocket on #25 chain
+ G=(1.0 / 35.0) * (20.0 / 40.0),
+ radius=16.0 * 0.25 / (2.0 * numpy.pi) * 0.0254,
+ mass=5.4,
+ q_pos=0.015,
+ q_vel=0.3,
+ kalman_q_pos=0.12,
+ kalman_q_vel=2.00,
+ kalman_q_voltage=40.0,
+ kalman_r_position=0.05)
+
+
+def main(argv):
+ if FLAGS.plot:
+ R = numpy.matrix([[0.1], [0.0]])
+ linear_system.PlotMotion(kIntake, 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 \
+ static_zeroing_single_dof_profiled_subsystem_test and integral \
+ static_zeroing_single_dof_profiled_subsystem_test.'
+ )
+ else:
+ namespaces = ['frc971', 'control_loops']
+ linear_system.WriteLinearSystem(kIntake, argv[1:3], argv[3:5],
+ namespaces)
+
+
+if __name__ == '__main__':
+ argv = FLAGS(sys.argv)
+ glog.init()
+ sys.exit(main(argv))