blob: e5b26fb197df3bac54534788790b8feb5d13ca12 [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, 1" wide neopreme wheel.
17J_wheel = 0.000319
18# Gear ratio between wheels (speed up!)
19G_per_wheel = 1.2
20# Gear ratio to the final wheel.
21G = (30.0 / 40.0) * numpy.power(G_per_wheel, 3.0)
22# Overall flywheel inertia.
23J = J_wheel * (
24 1.0 + numpy.power(G, -2.0) + numpy.power(G, -4.0) + numpy.power(G, -6.0))
25
26# The position and velocity are measured for the final wheel.
Sabina Davisedf89472020-02-17 15:27:37 -080027kAccelerator = flywheel.FlywheelParams(
28 name='Accelerator',
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,
34 q_voltage=0.3,
35 r_pos=0.05,
Austin Schuhc1c957a2020-02-20 17:47:58 -080036 controller_poles=[.87])
Sabina Davisedf89472020-02-17 15:27:37 -080037
38
39def main(argv):
40 if FLAGS.plot:
41 R = numpy.matrix([[0.0], [100.0], [0.0]])
42 flywheel.PlotSpinup(kAccelerator, 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 = [
49 'y2020', 'control_loops', 'superstructure', 'accelerator'
50 ]
51 flywheel.WriteFlywheel(kAccelerator, argv[1:3], argv[3:5], namespaces)
52
53
54if __name__ == '__main__':
55 argv = FLAGS(sys.argv)
56 sys.exit(main(argv))