blob: 0d46bb96f4f4994780d795d81e0d8d9354aa7d41 [file] [log] [blame]
Sabina Davisedf89472020-02-17 15:27:37 -08001#!/usr/bin/python
2
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# Inertia for a single 4" diameter, 2" wide neopreme wheel.
17J_wheel = 0.000319 * 2.0
18# Gear ratio to the final wheel.
19# 40 tooth on the flywheel
20# 48 for the falcon.
21# 60 tooth on the outer wheel.
22G = 48.0 / 40.0
23# Overall flywheel inertia.
24J = J_wheel * (1.0 + (40.0 / 60.0)**2.0)
25
26# The position and velocity are measured for the final wheel.
Sabina Davisedf89472020-02-17 15:27:37 -080027kFinisher = flywheel.FlywheelParams(
28 name='Finisher',
29 motor=control_loop.Falcon(),
Austin Schuhc1c957a2020-02-20 17:47:58 -080030 G=G,
31 J=J,
Sabina Davisedf89472020-02-17 15:27:37 -080032 q_pos=0.08,
33 q_vel=4.00,
Austin Schuh989a3132020-02-20 18:20:06 -080034 q_voltage=0.4,
Sabina Davisedf89472020-02-17 15:27:37 -080035 r_pos=0.05,
Austin Schuh989a3132020-02-20 18:20:06 -080036 controller_poles=[.80])
Sabina Davisedf89472020-02-17 15:27:37 -080037
38
39def main(argv):
40 if FLAGS.plot:
Austin Schuhc1c957a2020-02-20 17:47:58 -080041 R = numpy.matrix([[0.0], [500.0], [0.0]])
Sabina Davisedf89472020-02-17 15:27:37 -080042 flywheel.PlotSpinup(params=kFinisher, goal=R, iterations=200)
43 return 0
44
45 if len(argv) != 5:
46 glog.fatal('Expected .h file name and .cc file name')
47 else:
48 namespaces = ['y2020', 'control_loops', 'superstructure', 'finisher']
49 flywheel.WriteFlywheel(kFinisher, argv[1:3], argv[3:5], namespaces)
50
51
52if __name__ == '__main__':
53 argv = FLAGS(sys.argv)
54 sys.exit(main(argv))