Kai Tinkess | 8a7b8a6 | 2020-02-01 14:38:33 -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 copy |
| 8 | import numpy |
| 9 | import sys |
| 10 | from matplotlib import pylab |
| 11 | import gflags |
| 12 | import glog |
| 13 | |
| 14 | FLAGS = gflags.FLAGS |
| 15 | |
| 16 | try: |
| 17 | gflags.DEFINE_bool('plot', False, 'If true, plot the loop response.') |
| 18 | except gflags.DuplicateFlagError: |
| 19 | pass |
| 20 | |
| 21 | kTurret = angular_system.AngularSystemParams( |
| 22 | name='Turret', |
| 23 | motor=control_loop.Vex775Pro(), |
| 24 | #TODO: Update Gear Ratios when they are ready |
| 25 | G=(6.0 / 60.0) * (20.0 / 100.0) * (24.0 / 84.0), |
| 26 | #TODO: Get number from Bryan (moment of inertia) |
| 27 | J=0.30, |
| 28 | q_pos=0.20, |
| 29 | q_vel=5.0, |
| 30 | kalman_q_pos=0.12, |
| 31 | kalman_q_vel=2.0, |
| 32 | kalman_q_voltage=4.0, |
| 33 | kalman_r_position=0.05) |
| 34 | |
| 35 | def main(argv): |
| 36 | # Write the generated constants out to a file. |
| 37 | if len(argv) != 5: |
| 38 | glog.fatal( |
| 39 | 'Expected .h file name and .cc file name for the turret.' |
| 40 | ) |
| 41 | else: |
| 42 | namespaces = ['y2020', 'control_loops', 'superstructure', 'turret'] |
| 43 | angular_system.WriteAngularSystem([kTurret], |
| 44 | argv[1:3], argv[3:5], namespaces) |
| 45 | |
| 46 | |
| 47 | if __name__ == '__main__': |
| 48 | argv = FLAGS(sys.argv) |
| 49 | glog.init() |
| 50 | sys.exit(main(argv)) |