Austin Schuh | 085eab9 | 2020-11-26 13:54:51 -0800 | [diff] [blame] | 1 | #!/usr/bin/python3 |
Diana Vandenberg | 223703d | 2017-01-28 17:39:53 -0800 | [diff] [blame] | 2 | |
Austin Schuh | ce7e03d | 2020-11-20 22:32:44 -0800 | [diff] [blame] | 3 | from __future__ import print_function |
Campbell Crowley | 33e0e3d | 2017-12-27 17:55:40 -0800 | [diff] [blame] | 4 | from frc971.control_loops.python import drivetrain |
Diana Vandenberg | 223703d | 2017-01-28 17:39:53 -0800 | [diff] [blame] | 5 | import sys |
Diana Vandenberg | 223703d | 2017-01-28 17:39:53 -0800 | [diff] [blame] | 6 | |
| 7 | import gflags |
| 8 | import glog |
| 9 | |
| 10 | FLAGS = gflags.FLAGS |
| 11 | |
| 12 | gflags.DEFINE_bool('plot', False, 'If true, plot the loop response.') |
| 13 | |
Ravago Jones | 5127ccc | 2022-07-31 16:32:45 -0700 | [diff] [blame] | 14 | kDrivetrain = drivetrain.DrivetrainParams(J=6.0, |
| 15 | mass=52, |
| 16 | robot_radius=0.59055 / 2.0, |
| 17 | wheel_radius=0.08255 / 2.0, |
| 18 | G=11.0 / 60.0, |
| 19 | q_pos_low=0.12, |
| 20 | q_pos_high=0.14, |
| 21 | q_vel_low=1.0, |
| 22 | q_vel_high=0.95, |
| 23 | has_imu=False) |
| 24 | |
Diana Vandenberg | 223703d | 2017-01-28 17:39:53 -0800 | [diff] [blame] | 25 | |
| 26 | def main(argv): |
Austin Schuh | ecc92a0 | 2019-01-20 17:42:19 -0800 | [diff] [blame] | 27 | argv = FLAGS(argv) |
| 28 | glog.init() |
Diana Vandenberg | 223703d | 2017-01-28 17:39:53 -0800 | [diff] [blame] | 29 | |
Austin Schuh | ecc92a0 | 2019-01-20 17:42:19 -0800 | [diff] [blame] | 30 | if FLAGS.plot: |
| 31 | drivetrain.PlotDrivetrainMotions(kDrivetrain) |
| 32 | elif len(argv) != 5: |
Austin Schuh | ce7e03d | 2020-11-20 22:32:44 -0800 | [diff] [blame] | 33 | print("Expected .h file name and .cc file name") |
Austin Schuh | ecc92a0 | 2019-01-20 17:42:19 -0800 | [diff] [blame] | 34 | else: |
| 35 | # Write the generated constants out to a file. |
| 36 | drivetrain.WriteDrivetrain(argv[1:3], argv[3:5], 'y2017', kDrivetrain) |
Diana Vandenberg | 223703d | 2017-01-28 17:39:53 -0800 | [diff] [blame] | 37 | |
Ravago Jones | 5127ccc | 2022-07-31 16:32:45 -0700 | [diff] [blame] | 38 | |
Diana Vandenberg | 223703d | 2017-01-28 17:39:53 -0800 | [diff] [blame] | 39 | if __name__ == '__main__': |
Austin Schuh | ecc92a0 | 2019-01-20 17:42:19 -0800 | [diff] [blame] | 40 | sys.exit(main(sys.argv)) |