Sabina Davis | 24d94e0 | 2020-01-31 21:32:41 -0800 | [diff] [blame] | 1 | #!/usr/bin/python |
| 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 | ''' |
| 21 | Hood is an angular subsystem due to the mounting of the encoder on the hood joint. |
| 22 | We are currently electing to ignore potential non-linearity. |
| 23 | ''' |
| 24 | |
| 25 | #TODO: update constants |
| 26 | kHood = angular_system.AngularSystemParams( |
| 27 | name='Hood', |
| 28 | motor=control_loop.BAG(), |
| 29 | # meters / rad (used the displacement of the lead screw and the angle) |
| 30 | G=(0.1601 / 0.6457), |
| 31 | J=0.3, |
| 32 | q_pos=0.20, |
| 33 | q_vel=5.0, |
| 34 | kalman_q_pos=0.12, |
| 35 | kalman_q_vel=2.0, |
| 36 | kalman_q_voltage=4.0, |
| 37 | kalman_r_position=0.05) |
| 38 | |
| 39 | |
| 40 | def main(argv): |
| 41 | if FLAGS.plot: |
| 42 | R = numpy.matrix([[numpy.pi / 2.0], [0.0]]) |
| 43 | angular_system.PlotKick(kHood, R) |
| 44 | angular_system.PlotMotion(kHood, R) |
| 45 | |
| 46 | # Write the generated constants out to a file. |
| 47 | if len(argv) != 5: |
| 48 | glog.fatal( |
| 49 | 'Expected .h file name and .cc file name for the hood and integral hood.' |
| 50 | ) |
| 51 | else: |
| 52 | namespaces = ['y2020', 'control_loops', 'superstructure', 'hood'] |
| 53 | angular_system.WriteAngularSystem(kHood, argv[1:3], argv[3:5], |
| 54 | namespaces) |
| 55 | |
| 56 | |
| 57 | if __name__ == '__main__': |
| 58 | argv = FLAGS(sys.argv) |
| 59 | glog.init() |
| 60 | sys.exit(main(argv)) |