blob: b07321c402172e03df11e584c7657f40c5a8bbc8 [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
Theo Bafrali6915f112019-02-08 22:01:54 -080017kStilts = linear_system.LinearSystemParams(
18 name='Stilts',
Austin Schuh9642a1d2019-01-21 16:54:14 -080019 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
suneel2bc345d2019-02-09 20:00:56 -080024 mass=1.175 * 2, # 1 stilt foot = 1.175 kg
Austin Schuh9642a1d2019-01-21 16:54:14 -080025 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]])
Theo Bafrali6915f112019-02-08 22:01:54 -080037 linear_system.PlotKick(kStilts, R)
38 linear_system.PlotMotion(kStilts, R, max_velocity=5.0)
Austin Schuh9642a1d2019-01-21 16:54:14 -080039
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:
Theo Bafrali6915f112019-02-08 22:01:54 -080046 namespaces = ['y2019', 'control_loops', 'superstructure', 'stilts']
47 linear_system.WriteLinearSystem(kStilts, argv[1:3], argv[3:5],
Austin Schuh9642a1d2019-01-21 16:54:14 -080048 namespaces)
49
50
51if __name__ == '__main__':
52 argv = FLAGS(sys.argv)
53 glog.init()
54 sys.exit(main(argv))