blob: 41c05c6876d3ddf45016a54958c370b81540180e [file] [log] [blame]
Austin Schuhb0b6ccb2019-01-20 21:56:33 -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
suneel2bc345d2019-02-09 20:00:56 -080017first_stage_mass = 0.7957
18carriage_mass = 2.754
19
Austin Schuhb0b6ccb2019-01-20 21:56:33 -080020kElevator = linear_system.LinearSystemParams(
21 name='Elevator',
22 motor=control_loop.Vex775Pro(),
23 G=(8.0 / 82.0),
24 radius=2.25 * 0.0254 / 2.0,
suneel2bc345d2019-02-09 20:00:56 -080025 mass=first_stage_mass + carriage_mass,
Austin Schuhb0b6ccb2019-01-20 21:56:33 -080026 q_pos=0.070,
27 q_vel=1.2,
28 kalman_q_pos=0.12,
29 kalman_q_vel=2.00,
30 kalman_q_voltage=35.0,
31 kalman_r_position=0.05,
32 dt=0.00505)
33
34
35def main(argv):
36 if FLAGS.plot:
37 R = numpy.matrix([[1.5], [0.0]])
38 linear_system.PlotKick(kElevator, R)
39 linear_system.PlotMotion(kElevator, R, max_velocity=5.0)
40
41 # Write the generated constants out to a file.
42 if len(argv) != 5:
43 glog.fatal(
44 'Expected .h file name and .cc file name for the elevator and integral elevator.'
45 )
46 else:
47 namespaces = ['y2019', 'control_loops', 'superstructure', 'elevator']
48 linear_system.WriteLinearSystem(kElevator, argv[1:3], argv[3:5],
49 namespaces)
50
51
52if __name__ == '__main__':
53 argv = FLAGS(sys.argv)
54 glog.init()
55 sys.exit(main(argv))