blob: dab2754c1034b2e5ba6d871cbbcdec13de8b8993 [file] [log] [blame]
Austin Schuh9642a1d2019-01-21 16:54:14 -08001#!/usr/bin/python
2
3from frc971.control_loops.python import control_loop
4from frc971.control_loops.python import linear_system
5import numpy
6import sys
7import gflags
8import glog
9
10FLAGS = gflags.FLAGS
11
12try:
13 gflags.DEFINE_bool('plot', False, 'If true, plot the loop response.')
14except gflags.DuplicateFlagError:
15 pass
16
17kLift = linear_system.LinearSystemParams(
18 name='Lift',
19 motor=control_loop.Vex775Pro(),
20 G=(12.0 / 100.0) * (14.0 / 52.0),
21 # 5mm pitch, 18 tooth
22 radius=0.005 * 18.0 / (2.0 * numpy.pi),
23 # Or, 2.34 lb * 2 (2.1 kg) when lifting back up
24 mass=40.0,
25 q_pos=0.070,
26 q_vel=1.2,
27 kalman_q_pos=0.12,
28 kalman_q_vel=2.00,
29 kalman_q_voltage=35.0,
30 kalman_r_position=0.05,
31 dt=0.00505)
32
33
34def main(argv):
35 if FLAGS.plot:
36 R = numpy.matrix([[1.5], [0.0]])
37 linear_system.PlotKick(kLift, R)
38 linear_system.PlotMotion(kLift, R, max_velocity=5.0)
39
40 # Write the generated constants out to a file.
41 if len(argv) != 5:
42 glog.fatal(
43 'Expected .h file name and .cc file name for the elevator and integral elevator.'
44 )
45 else:
46 namespaces = ['y2019', 'control_loops', 'superstructure', 'lift']
47 linear_system.WriteLinearSystem(kLift, argv[1:3], argv[3:5],
48 namespaces)
49
50
51if __name__ == '__main__':
52 argv = FLAGS(sys.argv)
53 glog.init()
54 sys.exit(main(argv))