Sabina Davis | 5ae0c7c | 2017-10-21 20:51:55 -0700 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | |
Campbell Crowley | 0160eef | 2017-12-28 16:58:39 -0800 | [diff] [blame] | 3 | from frc971.control_loops.python import drivetrain |
Sabina Davis | 5ae0c7c | 2017-10-21 20:51:55 -0700 | [diff] [blame] | 4 | import sys |
Sabina Davis | 5ae0c7c | 2017-10-21 20:51:55 -0700 | [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 | 0160eef | 2017-12-28 16:58:39 -0800 | [diff] [blame] | 13 | #TODO(Neil): Update robot moment of inertia, mass, and robot radius |
| 14 | kDrivetrain = drivetrain.DrivetrainParams(J = 6.0, |
| 15 | mass = 52, |
| 16 | robot_radius = 0.59055 / 2.0, |
| 17 | wheel_radius = 4 * 0.0254 / 2, |
| 18 | G_high = 14.0 / 40.0 * 34.0 / 50.0 * 52.0 / 60.0, |
| 19 | G_low = 14.0 / 40.0 * 24.0 / 60.0 * 52.0 / 60.0, |
| 20 | q_pos_low = 0.12, |
| 21 | q_pos_high = 0.14, |
| 22 | q_vel_low = 1.0, |
Diana Burgess | d0180f1 | 2018-03-21 21:24:17 -0700 | [diff] [blame] | 23 | q_vel_high = 0.95, |
| 24 | has_imu = False) |
Sabina Davis | 5ae0c7c | 2017-10-21 20:51:55 -0700 | [diff] [blame] | 25 | |
| 26 | def main(argv): |
| 27 | argv = FLAGS(argv) |
| 28 | glog.init() |
| 29 | |
Sabina Davis | 5ae0c7c | 2017-10-21 20:51:55 -0700 | [diff] [blame] | 30 | if FLAGS.plot: |
Campbell Crowley | 0160eef | 2017-12-28 16:58:39 -0800 | [diff] [blame] | 31 | drivetrain.PlotDrivetrainMotions(kDrivetrain) |
| 32 | elif len(argv) != 5: |
Sabina Davis | 5ae0c7c | 2017-10-21 20:51:55 -0700 | [diff] [blame] | 33 | print "Expected .h file name and .cc file name" |
| 34 | else: |
Campbell Crowley | 0160eef | 2017-12-28 16:58:39 -0800 | [diff] [blame] | 35 | # Write the generated constants out to a file. |
| 36 | drivetrain.WriteDrivetrain(argv[1:3], argv[3:5], 'y2017_bot3', kDrivetrain) |
Sabina Davis | 5ae0c7c | 2017-10-21 20:51:55 -0700 | [diff] [blame] | 37 | |
| 38 | if __name__ == '__main__': |
| 39 | sys.exit(main(sys.argv)) |