Henry Speiser | 354d278 | 2022-07-22 13:56:48 -0700 | [diff] [blame] | 1 | #!/usr/bin/python3 |
| 2 | |
| 3 | from __future__ import print_function |
| 4 | from frc971.control_loops.python import drivetrain |
| 5 | from frc971.control_loops.python import control_loop |
| 6 | import sys |
| 7 | |
| 8 | import gflags |
| 9 | import glog |
| 10 | |
| 11 | FLAGS = gflags.FLAGS |
| 12 | |
| 13 | gflags.DEFINE_bool('plot', False, 'If true, plot the loop response.') |
| 14 | |
| 15 | kDrivetrain = drivetrain.DrivetrainParams( |
| 16 | J=6.0, |
Austin Schuh | d28c002 | 2023-03-25 16:20:31 -0700 | [diff] [blame] | 17 | mass=28.0, |
Henry Speiser | 354d278 | 2022-07-22 13:56:48 -0700 | [diff] [blame] | 18 | # TODO(austin): Measure radius a bit better. |
| 19 | robot_radius=0.39, |
| 20 | wheel_radius=2.5 * 0.0254, |
| 21 | motor_type=control_loop.Falcon(), |
| 22 | num_motors=3, |
| 23 | G=(14.0 / 54.0) * (22.0 / 56.0), |
| 24 | q_pos=0.24, |
| 25 | q_vel=2.5, |
| 26 | efficiency=0.80, |
Austin Schuh | fafdd93 | 2023-04-09 17:03:36 -0700 | [diff] [blame] | 27 | has_imu=False, |
Henry Speiser | 354d278 | 2022-07-22 13:56:48 -0700 | [diff] [blame] | 28 | force=True, |
| 29 | kf_q_voltage=1.0, |
| 30 | controller_poles=[0.82, 0.82]) |
| 31 | |
| 32 | |
| 33 | def main(argv): |
| 34 | argv = FLAGS(argv) |
| 35 | glog.init() |
| 36 | |
| 37 | if FLAGS.plot: |
| 38 | drivetrain.PlotDrivetrainMotions(kDrivetrain) |
James Kuszmaul | eeb98e9 | 2024-01-14 22:15:32 -0800 | [diff] [blame^] | 39 | elif len(argv) != 7: |
| 40 | print("Expected .h, .cc, and .json filenames") |
Henry Speiser | 354d278 | 2022-07-22 13:56:48 -0700 | [diff] [blame] | 41 | else: |
| 42 | # Write the generated constants out to a file. |
James Kuszmaul | eeb98e9 | 2024-01-14 22:15:32 -0800 | [diff] [blame^] | 43 | drivetrain.WriteDrivetrain(argv[1:4], argv[4:7], 'y2022_bot3', |
henry | 0168ec3 | 2022-08-12 11:09:34 -0700 | [diff] [blame] | 44 | kDrivetrain) |
Henry Speiser | 354d278 | 2022-07-22 13:56:48 -0700 | [diff] [blame] | 45 | |
| 46 | |
| 47 | if __name__ == '__main__': |
| 48 | sys.exit(main(sys.argv)) |