Austin Schuh | 47a0ee1 | 2019-01-21 16:01:32 -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 |
Austin Schuh | ba23ba9 | 2019-02-15 23:03:10 -0800 | [diff] [blame^] | 7 | import copy |
Austin Schuh | 47a0ee1 | 2019-01-21 16:01:32 -0800 | [diff] [blame] | 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 | |
suneel | 2bc345d | 2019-02-09 20:00:56 -0800 | [diff] [blame] | 21 | # Wrist alone |
| 22 | # 0.1348 |
| 23 | # Wrist with ball |
| 24 | # 0.3007 |
| 25 | # Wrist with hatch |
| 26 | # 0.446 |
| 27 | |
Austin Schuh | 47a0ee1 | 2019-01-21 16:01:32 -0800 | [diff] [blame] | 28 | kWrist = angular_system.AngularSystemParams( |
| 29 | name='Wrist', |
| 30 | motor=control_loop.BAG(), |
| 31 | G=(6.0 / 60.0) * (20.0 / 100.0) * (24.0 / 84.0), |
suneel | 2bc345d | 2019-02-09 20:00:56 -0800 | [diff] [blame] | 32 | J=0.27, |
Austin Schuh | 47a0ee1 | 2019-01-21 16:01:32 -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 | |
Austin Schuh | ba23ba9 | 2019-02-15 23:03:10 -0800 | [diff] [blame^] | 40 | kWristModel = copy.copy(kWrist) |
| 41 | kWristModel.J = 0.1348 |
| 42 | |
Austin Schuh | 47a0ee1 | 2019-01-21 16:01:32 -0800 | [diff] [blame] | 43 | |
| 44 | def main(argv): |
| 45 | if FLAGS.plot: |
| 46 | R = numpy.matrix([[numpy.pi / 2.0], [0.0]]) |
Austin Schuh | ba23ba9 | 2019-02-15 23:03:10 -0800 | [diff] [blame^] | 47 | angular_system.PlotKick(kWrist, R, plant_params=kWristModel) |
| 48 | angular_system.PlotMotion(kWrist, R, plant_params=kWristModel) |
Austin Schuh | 47a0ee1 | 2019-01-21 16:01:32 -0800 | [diff] [blame] | 49 | |
| 50 | # Write the generated constants out to a file. |
| 51 | if len(argv) != 5: |
| 52 | glog.fatal( |
| 53 | 'Expected .h file name and .cc file name for the wrist and integral wrist.' |
| 54 | ) |
| 55 | else: |
| 56 | namespaces = ['y2019', 'control_loops', 'superstructure', 'wrist'] |
| 57 | angular_system.WriteAngularSystem(kWrist, argv[1:3], argv[3:5], |
| 58 | namespaces) |
| 59 | |
| 60 | |
| 61 | if __name__ == '__main__': |
| 62 | argv = FLAGS(sys.argv) |
| 63 | glog.init() |
| 64 | sys.exit(main(argv)) |