Austin Schuh | 085eab9 | 2020-11-26 13:54:51 -0800 | [diff] [blame] | 1 | #!/usr/bin/python3 |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 2 | |
Austin Schuh | ce7e03d | 2020-11-20 22:32:44 -0800 | [diff] [blame] | 3 | from __future__ import print_function |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 4 | from frc971.control_loops.python import drivetrain |
Austin Schuh | c1c957a | 2020-02-20 17:47:58 -0800 | [diff] [blame] | 5 | from frc971.control_loops.python import control_loop |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 6 | import sys |
| 7 | |
| 8 | import gflags |
| 9 | import glog |
| 10 | |
| 11 | FLAGS = gflags.FLAGS |
| 12 | |
| 13 | gflags.DEFINE_bool('plot', False, 'If true, plot the loop response.') |
| 14 | |
| 15 | kDrivetrain = drivetrain.DrivetrainParams( |
Austin Schuh | c1c957a | 2020-02-20 17:47:58 -0800 | [diff] [blame] | 16 | J=6.0, |
Austin Schuh | cadb329 | 2021-01-23 20:24:17 -0800 | [diff] [blame] | 17 | mass=58.0, |
Austin Schuh | c1c957a | 2020-02-20 17:47:58 -0800 | [diff] [blame] | 18 | # TODO(austin): Measure radius a bit better. |
| 19 | robot_radius=0.7 / 2.0, |
Austin Schuh | 34b1d2e | 2021-11-07 17:39:36 -0800 | [diff] [blame] | 20 | wheel_radius=6.0 * 0.0254 / 2.0 * 0.99, |
Austin Schuh | c1c957a | 2020-02-20 17:47:58 -0800 | [diff] [blame] | 21 | motor_type=control_loop.Falcon(), |
| 22 | G=(8.0 / 70.0) * (17.0 / 24.0), |
Austin Schuh | cadb329 | 2021-01-23 20:24:17 -0800 | [diff] [blame] | 23 | q_pos=0.24, |
| 24 | q_vel=2.5, |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 25 | efficiency=0.80, |
| 26 | has_imu=True, |
| 27 | force=True, |
Austin Schuh | cadb329 | 2021-01-23 20:24:17 -0800 | [diff] [blame] | 28 | kf_q_voltage=1.0, |
Austin Schuh | 989a313 | 2020-02-20 18:20:06 -0800 | [diff] [blame] | 29 | controller_poles=[0.82, 0.82]) |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 30 | |
| 31 | |
| 32 | def main(argv): |
| 33 | argv = FLAGS(argv) |
| 34 | glog.init() |
| 35 | |
| 36 | if FLAGS.plot: |
| 37 | drivetrain.PlotDrivetrainMotions(kDrivetrain) |
James Kuszmaul | eeb98e9 | 2024-01-14 22:15:32 -0800 | [diff] [blame] | 38 | elif len(argv) != 7: |
| 39 | print("Expected .h, .cc, and .json filenames") |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 40 | else: |
| 41 | # Write the generated constants out to a file. |
James Kuszmaul | eeb98e9 | 2024-01-14 22:15:32 -0800 | [diff] [blame] | 42 | drivetrain.WriteDrivetrain(argv[1:4], argv[4:7], 'y2020', kDrivetrain) |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 43 | |
Austin Schuh | 989a313 | 2020-02-20 18:20:06 -0800 | [diff] [blame] | 44 | |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 45 | if __name__ == '__main__': |
| 46 | sys.exit(main(sys.argv)) |