Austin Schuh | 085eab9 | 2020-11-26 13:54:51 -0800 | [diff] [blame] | 1 | #!/usr/bin/python3 |
Sabina Davis | 6b9d84a | 2020-02-02 14:51:35 -0800 | [diff] [blame] | 2 | |
| 3 | from aos.util.trapezoid_profile import TrapezoidProfile |
| 4 | from frc971.control_loops.python import control_loop |
| 5 | from frc971.control_loops.python import angular_system |
| 6 | from frc971.control_loops.python import controls |
| 7 | import numpy |
| 8 | import sys |
| 9 | from matplotlib import pylab |
| 10 | import gflags |
| 11 | import glog |
| 12 | |
| 13 | FLAGS = gflags.FLAGS |
| 14 | |
| 15 | try: |
| 16 | gflags.DEFINE_bool('plot', False, 'If true, plot the loop response.') |
| 17 | except gflags.DuplicateFlagError: |
| 18 | pass |
| 19 | |
Sabina Davis | 6b9d84a | 2020-02-02 14:51:35 -0800 | [diff] [blame] | 20 | kIntake = angular_system.AngularSystemParams( |
| 21 | name='Intake', |
| 22 | motor=control_loop.BAG(), |
Austin Schuh | 8aacbef | 2021-10-16 23:15:14 -0700 | [diff] [blame^] | 23 | G=(12.0 / 24.0) * (1.0 / 5.0) * (1.0 / 5.0) * (16.0 / 32.0), |
| 24 | J=8 * 0.139 * 0.139, |
Austin Schuh | 989a313 | 2020-02-20 18:20:06 -0800 | [diff] [blame] | 25 | q_pos=0.40, |
| 26 | q_vel=20.0, |
Sabina Davis | 6b9d84a | 2020-02-02 14:51:35 -0800 | [diff] [blame] | 27 | kalman_q_pos=0.12, |
| 28 | kalman_q_vel=2.0, |
| 29 | kalman_q_voltage=4.0, |
| 30 | kalman_r_position=0.05) |
| 31 | |
| 32 | |
| 33 | def main(argv): |
| 34 | if FLAGS.plot: |
| 35 | R = numpy.matrix([[numpy.pi / 2.0], [0.0]]) |
| 36 | angular_system.PlotKick(kIntake, R) |
| 37 | angular_system.PlotMotion(kIntake, R) |
| 38 | |
| 39 | # Write the generated constants out to a file. |
| 40 | if len(argv) != 5: |
| 41 | glog.fatal( |
| 42 | 'Expected .h file name and .cc file name for the intake and integral intake.' |
| 43 | ) |
| 44 | else: |
| 45 | namespaces = ['y2020', 'control_loops', 'superstructure', 'intake'] |
| 46 | angular_system.WriteAngularSystem(kIntake, argv[1:3], argv[3:5], |
| 47 | namespaces) |
| 48 | |
| 49 | |
| 50 | if __name__ == '__main__': |
| 51 | argv = FLAGS(sys.argv) |
| 52 | glog.init() |
| 53 | sys.exit(main(argv)) |