blob: 9381630051bcde9caed94d19f70a139aed652166 [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.
Austin Schuh43b9ae92020-02-29 23:08:38 -080017J_wheel = 0.000319 * 2.0 * 6.0
Austin Schuhc1c957a2020-02-20 17:47:58 -080018# 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,
Austin Schuh43b9ae92020-02-29 23:08:38 -080032 q_pos=0.01,
33 q_vel=100.0,
34 q_voltage=6.0,
Sabina Davisedf89472020-02-17 15:27:37 -080035 r_pos=0.05,
Austin Schuh43b9ae92020-02-29 23:08:38 -080036 controller_poles=[.92])
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]])
Austin Schuh43b9ae92020-02-29 23:08:38 -080042 flywheel.PlotSpinup(params=kFinisher, goal=R, iterations=400)
Sabina Davisedf89472020-02-17 15:27:37 -080043 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))