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