Michael Schuh | ab42b0a | 2019-01-07 16:33:43 -0800 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | |
| 3 | from frc971.control_loops.python import drivetrain |
| 4 | import sys |
| 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 | |
| 13 | #update mass (120lbs right now) |
| 14 | #robot radius needs confirming(set as distance of center wheels from each other) |
| 15 | #J needs updating |
| 16 | |
Austin Schuh | 378483c | 2019-01-20 16:36:40 -0800 | [diff] [blame] | 17 | # TODO(austin): wpilib |
| 18 | # Encoder is on a 24 tooth gear attached to the output gear. |
| 19 | |
Michael Schuh | ab42b0a | 2019-01-07 16:33:43 -0800 | [diff] [blame] | 20 | kDrivetrain = drivetrain.DrivetrainParams( |
Austin Schuh | 834302a | 2019-02-16 15:47:25 -0800 | [diff] [blame^] | 21 | J=1.5, |
| 22 | mass=38.5, |
Austin Schuh | 378483c | 2019-01-20 16:36:40 -0800 | [diff] [blame] | 23 | # TODO(austin): Measure. |
Austin Schuh | 834302a | 2019-02-16 15:47:25 -0800 | [diff] [blame^] | 24 | robot_radius=0.45 / 2.0, |
Austin Schuh | 378483c | 2019-01-20 16:36:40 -0800 | [diff] [blame] | 25 | wheel_radius=4.0 * 0.0254 / 2.0, |
| 26 | G=9.0 / 52.0, |
| 27 | q_pos=0.14, |
| 28 | q_vel=0.95, |
| 29 | efficiency=0.80, |
Michael Schuh | ab42b0a | 2019-01-07 16:33:43 -0800 | [diff] [blame] | 30 | has_imu=True, |
| 31 | force=True, |
| 32 | kf_q_voltage=13.0, |
| 33 | controller_poles=[0.82, 0.82], |
Austin Schuh | 378483c | 2019-01-20 16:36:40 -0800 | [diff] [blame] | 34 | robot_cg_offset=0.0) |
Michael Schuh | ab42b0a | 2019-01-07 16:33:43 -0800 | [diff] [blame] | 35 | |
| 36 | |
| 37 | def main(argv): |
| 38 | argv = FLAGS(argv) |
| 39 | glog.init() |
| 40 | |
| 41 | if FLAGS.plot: |
| 42 | drivetrain.PlotDrivetrainMotions(kDrivetrain) |
| 43 | elif len(argv) != 5: |
| 44 | print "Expected .h file name and .cc file name" |
| 45 | else: |
| 46 | # Write the generated constants out to a file. |
Austin Schuh | 378483c | 2019-01-20 16:36:40 -0800 | [diff] [blame] | 47 | drivetrain.WriteDrivetrain(argv[1:3], argv[3:5], 'y2019', kDrivetrain) |
Michael Schuh | ab42b0a | 2019-01-07 16:33:43 -0800 | [diff] [blame] | 48 | |
| 49 | if __name__ == '__main__': |
| 50 | sys.exit(main(sys.argv)) |