Niko Sohmers | 1101711 | 2024-02-18 16:03:58 -0800 | [diff] [blame] | 1 | #!/usr/bin/python3 |
| 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 | gflags.DEFINE_bool('hybrid', False, 'If true, make it hybrid.') |
| 21 | |
| 22 | kAltitude = angular_system.AngularSystemParams( |
| 23 | name='Altitude', |
| 24 | motor=control_loop.KrakenFOC(), |
| 25 | G=(16.0 / 60.0) * (16.0 / 162.0), |
| 26 | # 4340 in^ lb |
Austin Schuh | 4ad11a6 | 2024-03-02 13:10:27 -0800 | [diff] [blame] | 27 | J=1.2, |
James Kuszmaul | c27f2c9 | 2024-04-05 17:33:55 -0700 | [diff] [blame] | 28 | q_pos=0.40, |
Austin Schuh | 087613b | 2024-02-19 12:39:08 -0800 | [diff] [blame] | 29 | q_vel=8.0, |
Niko Sohmers | 1101711 | 2024-02-18 16:03:58 -0800 | [diff] [blame] | 30 | kalman_q_pos=0.12, |
| 31 | kalman_q_vel=2.0, |
James Kuszmaul | c27f2c9 | 2024-04-05 17:33:55 -0700 | [diff] [blame] | 32 | kalman_q_voltage=3.0, |
Niko Sohmers | 1101711 | 2024-02-18 16:03:58 -0800 | [diff] [blame] | 33 | kalman_r_position=0.05, |
Austin Schuh | 65b4f9d | 2024-03-17 16:03:10 -0700 | [diff] [blame] | 34 | radius=10.5 * 0.0254, |
| 35 | dt=0.005) |
Niko Sohmers | 1101711 | 2024-02-18 16:03:58 -0800 | [diff] [blame] | 36 | |
| 37 | |
| 38 | def main(argv): |
| 39 | if FLAGS.plot: |
| 40 | R = numpy.matrix([[numpy.pi / 2.0], [0.0]]) |
| 41 | angular_system.PlotKick(kAltitude, R) |
| 42 | angular_system.PlotMotion(kAltitude, R) |
| 43 | return |
| 44 | |
| 45 | # Write the generated constants out to a file. |
| 46 | if len(argv) != 7: |
| 47 | glog.fatal( |
| 48 | 'Expected .h file name and .cc file name for the intake and integral intake.' |
| 49 | ) |
| 50 | else: |
| 51 | namespaces = ['y2024', 'control_loops', 'superstructure', 'altitude'] |
| 52 | angular_system.WriteAngularSystem(kAltitude, argv[1:4], argv[4:7], |
| 53 | namespaces) |
| 54 | |
| 55 | |
| 56 | if __name__ == '__main__': |
| 57 | argv = FLAGS(sys.argv) |
| 58 | glog.init() |
| 59 | sys.exit(main(argv)) |