Sabina Davis | f4c5e76 | 2018-01-24 10:18:43 -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 |
Sabina Davis | f4c5e76 | 2018-01-24 10:18:43 -0800 | [diff] [blame] | 4 | from frc971.control_loops.python import drivetrain |
| 5 | import sys |
| 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 | |
| 14 | #update mass (120lbs right now) |
| 15 | #robot radius needs confirming(set as distance of center wheels from each other) |
| 16 | #J needs updating |
| 17 | |
Austin Schuh | e8a54c0 | 2018-03-05 00:25:58 -0800 | [diff] [blame] | 18 | kDrivetrain = drivetrain.DrivetrainParams( |
Diana Burgess | d0180f1 | 2018-03-21 21:24:17 -0700 | [diff] [blame] | 19 | J=6.0, |
Austin Schuh | e8a54c0 | 2018-03-05 00:25:58 -0800 | [diff] [blame] | 20 | mass=68.0, |
| 21 | robot_radius=0.616 / 2.0, |
Diana Burgess | d0180f1 | 2018-03-21 21:24:17 -0700 | [diff] [blame] | 22 | wheel_radius=0.127 / 2.0 * 120.0 / 118.0, |
Austin Schuh | e8a54c0 | 2018-03-05 00:25:58 -0800 | [diff] [blame] | 23 | G_low=46.0 / 60.0 * 20.0 / 48.0 * 14.0 / 62.0, |
| 24 | G_high=62.0 / 44.0 * 20.0 / 48.0 * 14.0 / 62.0, |
| 25 | q_pos_low=0.12, |
| 26 | q_pos_high=0.14, |
| 27 | q_vel_low=1.0, |
| 28 | q_vel_high=0.95, |
Diana Burgess | d0180f1 | 2018-03-21 21:24:17 -0700 | [diff] [blame] | 29 | efficiency=0.70, |
| 30 | has_imu=True, |
| 31 | force=True, |
| 32 | kf_q_voltage=13.0, |
Austin Schuh | e8a54c0 | 2018-03-05 00:25:58 -0800 | [diff] [blame] | 33 | controller_poles=[0.82, 0.82], |
Michael Schuh | 95fbcc5 | 2018-03-10 20:57:20 -0800 | [diff] [blame] | 34 | robot_cg_offset=0.0, |
Austin Schuh | e8a54c0 | 2018-03-05 00:25:58 -0800 | [diff] [blame] | 35 | ) |
| 36 | |
Sabina Davis | f4c5e76 | 2018-01-24 10:18:43 -0800 | [diff] [blame] | 37 | |
| 38 | def main(argv): |
Austin Schuh | e8a54c0 | 2018-03-05 00:25:58 -0800 | [diff] [blame] | 39 | argv = FLAGS(argv) |
| 40 | glog.init() |
Sabina Davis | f4c5e76 | 2018-01-24 10:18:43 -0800 | [diff] [blame] | 41 | |
Austin Schuh | e8a54c0 | 2018-03-05 00:25:58 -0800 | [diff] [blame] | 42 | if FLAGS.plot: |
| 43 | drivetrain.PlotDrivetrainMotions(kDrivetrain) |
| 44 | elif len(argv) != 5: |
Austin Schuh | ce7e03d | 2020-11-20 22:32:44 -0800 | [diff] [blame] | 45 | print("Expected .h file name and .cc file name") |
Austin Schuh | e8a54c0 | 2018-03-05 00:25:58 -0800 | [diff] [blame] | 46 | else: |
| 47 | # Write the generated constants out to a file. |
| 48 | drivetrain.WriteDrivetrain(argv[1:3], argv[3:5], 'y2018', kDrivetrain) |
Sabina Davis | f4c5e76 | 2018-01-24 10:18:43 -0800 | [diff] [blame] | 49 | |
| 50 | if __name__ == '__main__': |
Austin Schuh | e8a54c0 | 2018-03-05 00:25:58 -0800 | [diff] [blame] | 51 | sys.exit(main(sys.argv)) |