blob: 26cb0431357295bfb0bd90378e8dc77664655123 [file] [log] [blame]
Ariv Diggi0af59c02023-10-07 13:15:39 -07001#!/usr/bin/python3
2
3from __future__ import print_function
4from frc971.control_loops.python import drivetrain
5from frc971.control_loops.python import control_loop
6import sys
7
8import gflags
9import glog
10
11FLAGS = gflags.FLAGS
12
13gflags.DEFINE_bool('plot', False, 'If true, plot the loop response.')
14
15# TODO(max): Change constants based on robot / CAD
16kDrivetrain = drivetrain.DrivetrainParams(
Mirabel Wangf4e42672023-10-14 13:12:49 -070017 J=2.2,
18 mass=44.7,
Ariv Diggi0af59c02023-10-07 13:15:39 -070019 # TODO(austin): Measure radius a bit better.
Mirabel Wangf4e42672023-10-14 13:12:49 -070020 robot_radius=0.25,
Ariv Diggi0af59c02023-10-07 13:15:39 -070021 wheel_radius=2.5 * 0.0254,
22 motor_type=control_loop.Falcon(),
Mirabel Wangf4e42672023-10-14 13:12:49 -070023 num_motors=2,
24 G=(14.0 / 68.0) * (30.0 / 54.0),
Ariv Diggi0af59c02023-10-07 13:15:39 -070025 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
34def 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
48if __name__ == '__main__':
49 sys.exit(main(sys.argv))