Austin Schuh | 085eab9 | 2020-11-26 13:54:51 -0800 | [diff] [blame] | 1 | #!/usr/bin/python3 |
Michael Schuh | ab42b0a | 2019-01-07 16:33:43 -0800 | [diff] [blame] | 2 | |
Austin Schuh | ce7e03d | 2020-11-20 22:32:44 -0800 | [diff] [blame] | 3 | from __future__ import print_function |
Michael Schuh | ab42b0a | 2019-01-07 16:33: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 | 378483c | 2019-01-20 16:36:40 -0800 | [diff] [blame] | 18 | # TODO(austin): wpilib |
| 19 | # Encoder is on a 24 tooth gear attached to the output gear. |
| 20 | |
Michael Schuh | ab42b0a | 2019-01-07 16:33:43 -0800 | [diff] [blame] | 21 | kDrivetrain = drivetrain.DrivetrainParams( |
Austin Schuh | 834302a | 2019-02-16 15:47:25 -0800 | [diff] [blame] | 22 | J=1.5, |
| 23 | mass=38.5, |
Austin Schuh | 378483c | 2019-01-20 16:36:40 -0800 | [diff] [blame] | 24 | # TODO(austin): Measure. |
Austin Schuh | 834302a | 2019-02-16 15:47:25 -0800 | [diff] [blame] | 25 | robot_radius=0.45 / 2.0, |
Austin Schuh | 378483c | 2019-01-20 16:36:40 -0800 | [diff] [blame] | 26 | wheel_radius=4.0 * 0.0254 / 2.0, |
| 27 | G=9.0 / 52.0, |
Austin Schuh | 3dd7707 | 2019-03-22 22:17:44 -0700 | [diff] [blame] | 28 | q_pos=0.14, |
| 29 | q_vel=1.30, |
Austin Schuh | 378483c | 2019-01-20 16:36:40 -0800 | [diff] [blame] | 30 | efficiency=0.80, |
Michael Schuh | ab42b0a | 2019-01-07 16:33:43 -0800 | [diff] [blame] | 31 | has_imu=True, |
| 32 | force=True, |
| 33 | kf_q_voltage=13.0, |
| 34 | controller_poles=[0.82, 0.82], |
Austin Schuh | 378483c | 2019-01-20 16:36:40 -0800 | [diff] [blame] | 35 | robot_cg_offset=0.0) |
Michael Schuh | ab42b0a | 2019-01-07 16:33:43 -0800 | [diff] [blame] | 36 | |
| 37 | |
| 38 | def main(argv): |
| 39 | argv = FLAGS(argv) |
| 40 | glog.init() |
| 41 | |
| 42 | if FLAGS.plot: |
| 43 | drivetrain.PlotDrivetrainMotions(kDrivetrain) |
James Kuszmaul | eeb98e9 | 2024-01-14 22:15:32 -0800 | [diff] [blame] | 44 | elif len(argv) != 7: |
| 45 | print("Expected .h, .cc, and .json filenames") |
Michael Schuh | ab42b0a | 2019-01-07 16:33:43 -0800 | [diff] [blame] | 46 | else: |
| 47 | # Write the generated constants out to a file. |
James Kuszmaul | eeb98e9 | 2024-01-14 22:15:32 -0800 | [diff] [blame] | 48 | drivetrain.WriteDrivetrain(argv[1:4], argv[4:7], 'y2019', kDrivetrain) |
Michael Schuh | ab42b0a | 2019-01-07 16:33:43 -0800 | [diff] [blame] | 49 | |
Ravago Jones | 5127ccc | 2022-07-31 16:32:45 -0700 | [diff] [blame] | 50 | |
Michael Schuh | ab42b0a | 2019-01-07 16:33:43 -0800 | [diff] [blame] | 51 | if __name__ == '__main__': |
| 52 | sys.exit(main(sys.argv)) |