Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | |
Campbell Crowley | 73a8677 | 2017-12-29 15:17:33 -0800 | [diff] [blame^] | 3 | from frc971.control_loops.python import drivetrain |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 4 | import sys |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 5 | |
Austin Schuh | e456f15 | 2015-11-27 13:44:39 -0800 | [diff] [blame] | 6 | import gflags |
| 7 | import glog |
| 8 | |
| 9 | FLAGS = gflags.FLAGS |
| 10 | |
| 11 | gflags.DEFINE_bool('plot', False, 'If true, plot the loop response.') |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 12 | |
Campbell Crowley | 73a8677 | 2017-12-29 15:17:33 -0800 | [diff] [blame^] | 13 | kDrivetrain = drivetrain.DrivetrainParams(J = 2.8, |
| 14 | mass = 68, |
| 15 | robot_radius = 0.647998644 / 2.0, |
| 16 | wheel_radius = .04445, |
| 17 | G_high = 28.0 / 50.0 * 18.0 / 50.0, |
| 18 | G_low = 18.0 / 60.0 * 18.0 / 50.0, |
| 19 | q_pos_low = 0.12, |
| 20 | q_pos_high = 0.12, |
| 21 | q_vel_low = 1.0, |
| 22 | q_vel_high = 1.0, |
| 23 | dt = 0.005, |
| 24 | controller_poles = [0.7, 0.7]) |
Austin Schuh | 572ff40 | 2015-11-08 12:17:50 -0800 | [diff] [blame] | 25 | |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 26 | def main(argv): |
Austin Schuh | e456f15 | 2015-11-27 13:44:39 -0800 | [diff] [blame] | 27 | argv = FLAGS(argv) |
Austin Schuh | 2965923 | 2015-11-26 13:55:30 -0800 | [diff] [blame] | 28 | |
Austin Schuh | e456f15 | 2015-11-27 13:44:39 -0800 | [diff] [blame] | 29 | if FLAGS.plot: |
Campbell Crowley | 73a8677 | 2017-12-29 15:17:33 -0800 | [diff] [blame^] | 30 | drivetrain.PlotDrivetrainMotions(kDrivetrain) |
| 31 | elif len(argv) != 5: |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 32 | print "Expected .h file name and .cc file name" |
| 33 | else: |
Campbell Crowley | 73a8677 | 2017-12-29 15:17:33 -0800 | [diff] [blame^] | 34 | # Write the generated constants out to a file. |
| 35 | drivetrain.WriteDrivetrain(argv[1:3], argv[3:5], 'y2014', kDrivetrain) |
Austin Schuh | 572ff40 | 2015-11-08 12:17:50 -0800 | [diff] [blame] | 36 | |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 37 | if __name__ == '__main__': |
| 38 | sys.exit(main(sys.argv)) |