blob: 28c46daaf1a50e9cbf1a61755ec58a532d42cadf [file] [log] [blame]
Austin Schuh085eab92020-11-26 13:54:51 -08001#!/usr/bin/python3
Stephan Massaltd021f972020-01-05 20:41:23 -08002
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 Schuhcadb3292021-01-23 20:24:17 -080017 mass=58.0,
Austin Schuhc1c957a2020-02-20 17:47:58 -080018 # TODO(austin): Measure radius a bit better.
19 robot_radius=0.7 / 2.0,
Austin Schuh34b1d2e2021-11-07 17:39:36 -080020 wheel_radius=6.0 * 0.0254 / 2.0 * 0.99,
Austin Schuhc1c957a2020-02-20 17:47:58 -080021 motor_type=control_loop.Falcon(),
22 G=(8.0 / 70.0) * (17.0 / 24.0),
Austin Schuhcadb3292021-01-23 20:24:17 -080023 q_pos=0.24,
24 q_vel=2.5,
Stephan Massaltd021f972020-01-05 20:41:23 -080025 efficiency=0.80,
26 has_imu=True,
27 force=True,
Austin Schuhcadb3292021-01-23 20:24:17 -080028 kf_q_voltage=1.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)
James Kuszmauleeb98e92024-01-14 22:15:32 -080038 elif len(argv) != 7:
39 print("Expected .h, .cc, and .json filenames")
Stephan Massaltd021f972020-01-05 20:41:23 -080040 else:
41 # Write the generated constants out to a file.
James Kuszmauleeb98e92024-01-14 22:15:32 -080042 drivetrain.WriteDrivetrain(argv[1:4], argv[4:7], 'y2020', kDrivetrain)
Stephan Massaltd021f972020-01-05 20:41:23 -080043
Austin Schuh989a3132020-02-20 18:20:06 -080044
Stephan Massaltd021f972020-01-05 20:41:23 -080045if __name__ == '__main__':
46 sys.exit(main(sys.argv))