Ariv Diggi | 0af59c0 | 2023-10-07 13:15:39 -0700 | [diff] [blame] | 1 | #!/usr/bin/python3 |
| 2 | |
| 3 | from __future__ import print_function |
| 4 | from frc971.control_loops.python import drivetrain |
| 5 | from frc971.control_loops.python import control_loop |
| 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 | # TODO(max): Change constants based on robot / CAD |
| 16 | kDrivetrain = drivetrain.DrivetrainParams( |
Mirabel Wang | f4e4267 | 2023-10-14 13:12:49 -0700 | [diff] [blame] | 17 | J=2.2, |
| 18 | mass=44.7, |
Ariv Diggi | 0af59c0 | 2023-10-07 13:15:39 -0700 | [diff] [blame] | 19 | # TODO(austin): Measure radius a bit better. |
Mirabel Wang | f4e4267 | 2023-10-14 13:12:49 -0700 | [diff] [blame] | 20 | robot_radius=0.25, |
Ariv Diggi | 0af59c0 | 2023-10-07 13:15:39 -0700 | [diff] [blame] | 21 | wheel_radius=2.5 * 0.0254, |
| 22 | motor_type=control_loop.Falcon(), |
Mirabel Wang | f4e4267 | 2023-10-14 13:12:49 -0700 | [diff] [blame] | 23 | num_motors=2, |
| 24 | G=(14.0 / 68.0) * (30.0 / 54.0), |
Ariv Diggi | 0af59c0 | 2023-10-07 13:15:39 -0700 | [diff] [blame] | 25 | q_pos=0.24, |
| 26 | q_vel=2.5, |
| 27 | efficiency=0.92, |
| 28 | has_imu=False, |
| 29 | force=True, |
| 30 | kf_q_voltage=1.0, |
| 31 | controller_poles=[0.82, 0.82]) |
| 32 | |
| 33 | |
| 34 | def main(argv): |
| 35 | argv = FLAGS(argv) |
| 36 | glog.init() |
| 37 | |
| 38 | if FLAGS.plot: |
| 39 | drivetrain.PlotDrivetrainMotions(kDrivetrain) |
| 40 | elif len(argv) != 5: |
| 41 | print("Expected .h file name and .cc file name") |
| 42 | else: |
| 43 | # Write the generated constants out to a file. |
| 44 | drivetrain.WriteDrivetrain(argv[1:3], argv[3:5], 'y2023_bot3', |
| 45 | kDrivetrain) |
| 46 | |
| 47 | |
| 48 | if __name__ == '__main__': |
| 49 | sys.exit(main(sys.argv)) |