blob: 72be90941ce6074a182dd05f3bae7b7b7f6b2ab6 [file] [log] [blame]
Stephan Massaltd021f972020-01-05 20:41:23 -08001#!/usr/bin/python
2
Austin Schuhce7e03d2020-11-20 22:32:44 -08003from __future__ import print_function
Stephan Massaltd021f972020-01-05 20:41:23 -08004from frc971.control_loops.python import drivetrain
Austin Schuhc1c957a2020-02-20 17:47:58 -08005from frc971.control_loops.python import control_loop
Stephan Massaltd021f972020-01-05 20:41:23 -08006import sys
7
8import gflags
9import glog
10
11FLAGS = gflags.FLAGS
12
13gflags.DEFINE_bool('plot', False, 'If true, plot the loop response.')
14
15kDrivetrain = drivetrain.DrivetrainParams(
Austin Schuhc1c957a2020-02-20 17:47:58 -080016 J=6.0,
Austin Schuh989a3132020-02-20 18:20:06 -080017 mass=68.0,
Austin Schuhc1c957a2020-02-20 17:47:58 -080018 # TODO(austin): Measure radius a bit better.
19 robot_radius=0.7 / 2.0,
20 wheel_radius=6.0 * 0.0254 / 2.0,
21 motor_type=control_loop.Falcon(),
22 G=(8.0 / 70.0) * (17.0 / 24.0),
Stephan Massaltd021f972020-01-05 20:41:23 -080023 q_pos=0.14,
24 q_vel=1.30,
25 efficiency=0.80,
26 has_imu=True,
27 force=True,
28 kf_q_voltage=13.0,
Austin Schuh989a3132020-02-20 18:20:06 -080029 controller_poles=[0.82, 0.82])
Stephan Massaltd021f972020-01-05 20:41:23 -080030
31
32def main(argv):
33 argv = FLAGS(argv)
34 glog.init()
35
36 if FLAGS.plot:
37 drivetrain.PlotDrivetrainMotions(kDrivetrain)
38 elif len(argv) != 5:
Austin Schuhce7e03d2020-11-20 22:32:44 -080039 print("Expected .h file name and .cc file name")
Stephan Massaltd021f972020-01-05 20:41:23 -080040 else:
41 # Write the generated constants out to a file.
42 drivetrain.WriteDrivetrain(argv[1:3], argv[3:5], 'y2020', kDrivetrain)
43
Austin Schuh989a3132020-02-20 18:20:06 -080044
Stephan Massaltd021f972020-01-05 20:41:23 -080045if __name__ == '__main__':
46 sys.exit(main(sys.argv))