Add third robot python files
Signed-off-by: thiagom <oculusdev124@gmail.com>
Change-Id: I2382ce370ac2c93a4e168d3147c67ead61331b2f
diff --git a/y2022_bot3/control_loops/python/BUILD b/y2022_bot3/control_loops/python/BUILD
index e3e1beb..b2ce1be 100644
--- a/y2022_bot3/control_loops/python/BUILD
+++ b/y2022_bot3/control_loops/python/BUILD
@@ -48,6 +48,38 @@
],
)
+py_binary(
+ name = "climber",
+ srcs = [
+ "climber.py",
+ ],
+ legacy_create_init = False,
+ target_compatible_with = ["@platforms//cpu:x86_64"],
+ deps = [
+ ":python_init",
+ "//external:python-gflags",
+ "//external:python-glog",
+ "//frc971/control_loops/python:controls",
+ "//frc971/control_loops/python:linear_system",
+ ],
+)
+
+py_binary(
+ name = "intake",
+ srcs = [
+ "intake.py",
+ ],
+ legacy_create_init = False,
+ target_compatible_with = ["@platforms//cpu:x86_64"],
+ 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/y2022_bot3/control_loops/python/climber.py b/y2022_bot3/control_loops/python/climber.py
new file mode 100644
index 0000000..9a444c3
--- /dev/null
+++ b/y2022_bot3/control_loops/python/climber.py
@@ -0,0 +1,57 @@
+#!/usr/bin/python3
+
+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
+
+kClimber = linear_system.LinearSystemParams(
+ name='Climber',
+ motor=control_loop.Falcon(),
+ # TODO(Thiago): Change gear ratios when we have all of them
+ G=(1.0 / 4.0) * (1.0 / 3.0) * (1.0 / 3.0),
+ radius=22 * 0.25 / numpy.pi / 2.0 * 0.0254,
+ mass=2.0,
+ q_pos=0.10,
+ q_vel=1.35,
+ kalman_q_pos=0.12,
+ kalman_q_vel=2.00,
+ kalman_q_voltage=35.0,
+ kalman_r_position=0.05)
+
+
+def main(argv):
+ if FLAGS.plot:
+ R = numpy.matrix([[0.2], [0.0]])
+ linear_system.PlotKick(kClimber, R, plant_params=kClimber)
+ linear_system.PlotMotion(kClimber,
+ R,
+ max_velocity=5.0,
+ plant_params=kClimber)
+
+ # Write the generated constants out to a file.
+ if len(argv) != 5:
+ glog.fatal(
+ 'Expected .h file name and .cc file name for the climber and integral climber.'
+ )
+ else:
+ namespaces = [
+ 'y2022_bot3', 'control_loops', 'superstructure', 'climber'
+ ]
+ linear_system.WriteLinearSystem(kClimber, argv[1:3], argv[3:5],
+ namespaces)
+
+
+if __name__ == '__main__':
+ argv = FLAGS(sys.argv)
+ glog.init()
+ sys.exit(main(argv))
diff --git a/y2022_bot3/control_loops/python/intake.py b/y2022_bot3/control_loops/python/intake.py
new file mode 100644
index 0000000..9f23227
--- /dev/null
+++ b/y2022_bot3/control_loops/python/intake.py
@@ -0,0 +1,57 @@
+#!/usr/bin/python3
+
+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
+
+kIntake = angular_system.AngularSystemParams(
+ name='Intake',
+ motor=control_loop.Falcon(),
+ # TODO(Thiago): Change gear ratios when we have all of them
+ G=0.02,
+ J=0.34,
+ q_pos=0.40,
+ q_vel=20.0,
+ kalman_q_pos=0.12,
+ kalman_q_vel=2.0,
+ kalman_q_voltage=4.0,
+ kalman_r_position=0.05,
+ radius=13 * 0.0254)
+
+
+def main(argv):
+ if FLAGS.plot:
+ R = numpy.matrix([[numpy.pi / 2.0], [0.0]])
+ angular_system.PlotKick(kIntake, R)
+ angular_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 intake and integral intake.'
+ )
+ else:
+ namespaces = [
+ 'y2022_bot3', 'control_loops', 'superstructure', 'intake'
+ ]
+ angular_system.WriteAngularSystem(kIntake, argv[1:3], argv[3:5],
+ namespaces)
+
+
+if __name__ == '__main__':
+ argv = FLAGS(sys.argv)
+ glog.init()
+ sys.exit(main(argv))