Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | |
| 3 | from frc971.control_loops.python import drivetrain |
Austin Schuh | c1c957a | 2020-02-20 17:47:58 -0800 | [diff] [blame] | 4 | from frc971.control_loops.python import control_loop |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 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 | kDrivetrain = drivetrain.DrivetrainParams( |
Austin Schuh | c1c957a | 2020-02-20 17:47:58 -0800 | [diff] [blame] | 15 | J=6.0, |
Austin Schuh | 989a313 | 2020-02-20 18:20:06 -0800 | [diff] [blame] | 16 | mass=68.0, |
Austin Schuh | c1c957a | 2020-02-20 17:47:58 -0800 | [diff] [blame] | 17 | # TODO(austin): Measure radius a bit better. |
| 18 | robot_radius=0.7 / 2.0, |
| 19 | wheel_radius=6.0 * 0.0254 / 2.0, |
| 20 | motor_type=control_loop.Falcon(), |
| 21 | G=(8.0 / 70.0) * (17.0 / 24.0), |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 22 | q_pos=0.14, |
| 23 | q_vel=1.30, |
| 24 | efficiency=0.80, |
| 25 | has_imu=True, |
| 26 | force=True, |
| 27 | kf_q_voltage=13.0, |
Austin Schuh | 989a313 | 2020-02-20 18:20:06 -0800 | [diff] [blame] | 28 | controller_poles=[0.82, 0.82]) |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 29 | |
| 30 | |
| 31 | def main(argv): |
| 32 | argv = FLAGS(argv) |
| 33 | glog.init() |
| 34 | |
| 35 | if FLAGS.plot: |
| 36 | drivetrain.PlotDrivetrainMotions(kDrivetrain) |
| 37 | elif len(argv) != 5: |
| 38 | print "Expected .h file name and .cc file name" |
| 39 | else: |
| 40 | # Write the generated constants out to a file. |
| 41 | drivetrain.WriteDrivetrain(argv[1:3], argv[3:5], 'y2020', kDrivetrain) |
| 42 | |
Austin Schuh | 989a313 | 2020-02-20 18:20:06 -0800 | [diff] [blame] | 43 | |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 44 | if __name__ == '__main__': |
| 45 | sys.exit(main(sys.argv)) |