Austin Schuh | 085eab9 | 2020-11-26 13:54:51 -0800 | [diff] [blame^] | 1 | #!/usr/bin/python3 |
Austin Schuh | f2a9c1a | 2019-01-21 16:42:28 -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 | |
| 20 | kIntake = angular_system.AngularSystemParams( |
| 21 | name='Intake', |
| 22 | motor=control_loop.BAG(), |
Alex Perry | 5fb5ff2 | 2019-02-09 21:53:17 -0800 | [diff] [blame] | 23 | G=(1.0 / 7.0) * (1.0 / 4.0) * (1.0 / 4.0)* (18.0 / 38.0), |
suneel | 2bc345d | 2019-02-09 20:00:56 -0800 | [diff] [blame] | 24 | # Suneel: Sampled moment of inertia at 6 different positions |
| 25 | # J = the average of the six. |
| 26 | # 1. 0.686 |
| 27 | # 2. 0.637 |
| 28 | # 3. 0.514 |
| 29 | # 4. 0.332 |
| 30 | # 5. 0.183 |
| 31 | # 6. 0.149 |
| 32 | J=0.3, |
Austin Schuh | f2a9c1a | 2019-01-21 16:42:28 -0800 | [diff] [blame] | 33 | q_pos=0.20, |
| 34 | q_vel=5.0, |
| 35 | kalman_q_pos=0.12, |
| 36 | kalman_q_vel=2.0, |
| 37 | kalman_q_voltage=4.0, |
| 38 | kalman_r_position=0.05) |
| 39 | |
| 40 | |
| 41 | def main(argv): |
| 42 | if FLAGS.plot: |
| 43 | R = numpy.matrix([[numpy.pi / 2.0], [0.0]]) |
Austin Schuh | f2a9c1a | 2019-01-21 16:42:28 -0800 | [diff] [blame] | 44 | angular_system.PlotKick(kIntake, R) |
Austin Schuh | ba23ba9 | 2019-02-15 23:03:10 -0800 | [diff] [blame] | 45 | angular_system.PlotMotion(kIntake, R) |
Austin Schuh | f2a9c1a | 2019-01-21 16:42:28 -0800 | [diff] [blame] | 46 | |
| 47 | # Write the generated constants out to a file. |
| 48 | if len(argv) != 5: |
| 49 | glog.fatal( |
| 50 | 'Expected .h file name and .cc file name for the intake and integral intake.' |
| 51 | ) |
| 52 | else: |
| 53 | namespaces = ['y2019', 'control_loops', 'superstructure', 'intake'] |
| 54 | angular_system.WriteAngularSystem(kIntake, argv[1:3], argv[3:5], |
| 55 | namespaces) |
| 56 | |
| 57 | |
| 58 | if __name__ == '__main__': |
| 59 | argv = FLAGS(sys.argv) |
| 60 | glog.init() |
| 61 | sys.exit(main(argv)) |