Brian Silverman | c71537c | 2016-01-01 13:43:14 -0800 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | |
Austin Schuh | ce7e03d | 2020-11-20 22:32:44 -0800 | [diff] [blame^] | 3 | from __future__ import print_function |
Campbell Crowley | 97963f6 | 2017-12-29 15:42:58 -0800 | [diff] [blame] | 4 | from frc971.control_loops.python import drivetrain |
Brian Silverman | c71537c | 2016-01-01 13:43:14 -0800 | [diff] [blame] | 5 | import sys |
Brian Silverman | c71537c | 2016-01-01 13:43:14 -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 | |
Campbell Crowley | 97963f6 | 2017-12-29 15:42:58 -0800 | [diff] [blame] | 14 | kDrivetrain = drivetrain.DrivetrainParams(J = 1.5, |
| 15 | mass = 30, |
| 16 | robot_radius = 0.647998644 / 2.0, |
| 17 | wheel_radius = .04445, |
| 18 | G_high = 30.0 / 45.0 * 15.0 / 50.0, |
| 19 | G_low = 15.0 / 60.0 * 15.0 / 50.0, |
| 20 | q_pos_low = 0.12, |
| 21 | q_pos_high = 0.14, |
| 22 | q_vel_low = 1.0, |
| 23 | q_vel_high = 0.95, |
Diana Burgess | d0180f1 | 2018-03-21 21:24:17 -0700 | [diff] [blame] | 24 | has_imu = False, |
Campbell Crowley | 97963f6 | 2017-12-29 15:42:58 -0800 | [diff] [blame] | 25 | dt = 0.005, |
| 26 | controller_poles = [0.8, 0.8]) |
Brian Silverman | c71537c | 2016-01-01 13:43:14 -0800 | [diff] [blame] | 27 | |
| 28 | def main(argv): |
| 29 | argv = FLAGS(argv) |
Austin Schuh | 2a671df | 2016-11-26 15:00:06 -0800 | [diff] [blame] | 30 | glog.init() |
Brian Silverman | c71537c | 2016-01-01 13:43:14 -0800 | [diff] [blame] | 31 | |
Brian Silverman | c71537c | 2016-01-01 13:43:14 -0800 | [diff] [blame] | 32 | if FLAGS.plot: |
Campbell Crowley | 97963f6 | 2017-12-29 15:42:58 -0800 | [diff] [blame] | 33 | drivetrain.PlotDrivetrainMotions(kDrivetrain) |
| 34 | elif len(argv) != 5: |
Austin Schuh | ce7e03d | 2020-11-20 22:32:44 -0800 | [diff] [blame^] | 35 | print("Expected .h file name and .cc file name") |
Brian Silverman | c71537c | 2016-01-01 13:43:14 -0800 | [diff] [blame] | 36 | else: |
Campbell Crowley | 97963f6 | 2017-12-29 15:42:58 -0800 | [diff] [blame] | 37 | # Write the generated constants out to a file. |
| 38 | drivetrain.WriteDrivetrain(argv[1:3], argv[3:5], 'y2012', kDrivetrain) |
Brian Silverman | c71537c | 2016-01-01 13:43:14 -0800 | [diff] [blame] | 39 | |
| 40 | if __name__ == '__main__': |
| 41 | sys.exit(main(sys.argv)) |