blob: 035586a654093761405f6840331a4a966c0477e0 [file] [log] [blame]
Austin Schuh085eab92020-11-26 13:54:51 -08001#!/usr/bin/python3
Sabina Davisedf89472020-02-17 15:27:37 -08002
3from frc971.control_loops.python import control_loop
4from y2020.control_loops.python import flywheel
5import numpy
6
7import sys
8
9import gflags
10import glog
11
12FLAGS = gflags.FLAGS
13
14gflags.DEFINE_bool('plot', False, 'If true, plot the loop response.')
15
Austin Schuhc1c957a2020-02-20 17:47:58 -080016# Gear ratio to the final wheel.
17# 40 tooth on the flywheel
18# 48 for the falcon.
19# 60 tooth on the outer wheel.
20G = 48.0 / 40.0
21# Overall flywheel inertia.
Austin Schuh0ad31d72021-03-06 17:07:04 -080022J = 0.00507464
Austin Schuhc1c957a2020-02-20 17:47:58 -080023
24# The position and velocity are measured for the final wheel.
Sabina Davisedf89472020-02-17 15:27:37 -080025kFinisher = flywheel.FlywheelParams(
26 name='Finisher',
Austin Schuh0ad31d72021-03-06 17:07:04 -080027 motor=control_loop.NMotor(control_loop.Falcon(), 2),
Austin Schuhc1c957a2020-02-20 17:47:58 -080028 G=G,
29 J=J,
Austin Schuh43b9ae92020-02-29 23:08:38 -080030 q_pos=0.01,
31 q_vel=100.0,
32 q_voltage=6.0,
Sabina Davisedf89472020-02-17 15:27:37 -080033 r_pos=0.05,
Austin Schuh0ad31d72021-03-06 17:07:04 -080034 controller_poles=[.90])
Sabina Davisedf89472020-02-17 15:27:37 -080035
36
37def main(argv):
38 if FLAGS.plot:
Austin Schuhc1c957a2020-02-20 17:47:58 -080039 R = numpy.matrix([[0.0], [500.0], [0.0]])
Austin Schuh43b9ae92020-02-29 23:08:38 -080040 flywheel.PlotSpinup(params=kFinisher, goal=R, iterations=400)
Sabina Davisedf89472020-02-17 15:27:37 -080041 return 0
42
43 if len(argv) != 5:
44 glog.fatal('Expected .h file name and .cc file name')
45 else:
46 namespaces = ['y2020', 'control_loops', 'superstructure', 'finisher']
47 flywheel.WriteFlywheel(kFinisher, argv[1:3], argv[3:5], namespaces)
48
49
50if __name__ == '__main__':
51 argv = FLAGS(sys.argv)
52 sys.exit(main(argv))