blob: efb080f26adcbab13eabd81951f8508dd3523d9b [file] [log] [blame]
Austin Schuh085eab92020-11-26 13:54:51 -08001#!/usr/bin/python3
Michael Schuhab42b0a2019-01-07 16:33:43 -08002
Austin Schuhce7e03d2020-11-20 22:32:44 -08003from __future__ import print_function
Michael Schuhab42b0a2019-01-07 16:33:43 -08004from frc971.control_loops.python import drivetrain
5import sys
6
7import gflags
8import glog
9
10FLAGS = gflags.FLAGS
11
12gflags.DEFINE_bool('plot', False, 'If true, plot the loop response.')
13
14#update mass (120lbs right now)
15#robot radius needs confirming(set as distance of center wheels from each other)
16#J needs updating
17
Austin Schuh378483c2019-01-20 16:36:40 -080018# TODO(austin): wpilib
19# Encoder is on a 24 tooth gear attached to the output gear.
20
Michael Schuhab42b0a2019-01-07 16:33:43 -080021kDrivetrain = drivetrain.DrivetrainParams(
Austin Schuh834302a2019-02-16 15:47:25 -080022 J=1.5,
23 mass=38.5,
Austin Schuh378483c2019-01-20 16:36:40 -080024 # TODO(austin): Measure.
Austin Schuh834302a2019-02-16 15:47:25 -080025 robot_radius=0.45 / 2.0,
Austin Schuh378483c2019-01-20 16:36:40 -080026 wheel_radius=4.0 * 0.0254 / 2.0,
27 G=9.0 / 52.0,
Austin Schuh3dd77072019-03-22 22:17:44 -070028 q_pos=0.14,
29 q_vel=1.30,
Austin Schuh378483c2019-01-20 16:36:40 -080030 efficiency=0.80,
Michael Schuhab42b0a2019-01-07 16:33:43 -080031 has_imu=True,
32 force=True,
33 kf_q_voltage=13.0,
34 controller_poles=[0.82, 0.82],
Austin Schuh378483c2019-01-20 16:36:40 -080035 robot_cg_offset=0.0)
Michael Schuhab42b0a2019-01-07 16:33:43 -080036
37
38def main(argv):
39 argv = FLAGS(argv)
40 glog.init()
41
42 if FLAGS.plot:
43 drivetrain.PlotDrivetrainMotions(kDrivetrain)
James Kuszmauleeb98e92024-01-14 22:15:32 -080044 elif len(argv) != 7:
45 print("Expected .h, .cc, and .json filenames")
Michael Schuhab42b0a2019-01-07 16:33:43 -080046 else:
47 # Write the generated constants out to a file.
James Kuszmauleeb98e92024-01-14 22:15:32 -080048 drivetrain.WriteDrivetrain(argv[1:4], argv[4:7], 'y2019', kDrivetrain)
Michael Schuhab42b0a2019-01-07 16:33:43 -080049
Ravago Jones5127ccc2022-07-31 16:32:45 -070050
Michael Schuhab42b0a2019-01-07 16:33:43 -080051if __name__ == '__main__':
52 sys.exit(main(sys.argv))