Sabina Davis | 2ca9228 | 2020-02-09 14:24:16 -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 | #TODO(sabina): update moment |
| 21 | kControlPanel = angular_system.AngularSystemParams( |
| 22 | name='ControlPanel', |
| 23 | motor=control_loop.BAG(), |
| 24 | G=(1.0), |
| 25 | J=0.3, |
| 26 | q_pos=0.20, |
| 27 | q_vel=5.0, |
| 28 | kalman_q_pos=0.12, |
| 29 | kalman_q_vel=2.0, |
| 30 | kalman_q_voltage=4.0, |
| 31 | kalman_r_position=0.05) |
| 32 | |
| 33 | |
| 34 | def main(argv): |
| 35 | if FLAGS.plot: |
| 36 | R = numpy.matrix([[numpy.pi / 2.0], [0.0]]) |
| 37 | angular_system.PlotKick(kControlPanel, R) |
| 38 | angular_system.PlotMotion(kControlPanel, R) |
| 39 | |
| 40 | # Write the generated constants out to a file. |
| 41 | if len(argv) != 5: |
| 42 | glog.fatal( |
| 43 | 'Expected .h file name and .cc file name for the control_panel and integral control_panel.' |
| 44 | ) |
| 45 | else: |
| 46 | namespaces = ['y2020', 'control_loops', 'superstructure', 'control_panel'] |
| 47 | angular_system.WriteAngularSystem(kControlPanel, argv[1:3], argv[3:5], |
| 48 | namespaces) |
| 49 | |
| 50 | |
| 51 | if __name__ == '__main__': |
| 52 | argv = FLAGS(sys.argv) |
| 53 | glog.init() |
| 54 | sys.exit(main(argv)) |