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