blob: 2c4644d5198aab8fd18a5b0b232442adf529dc50 [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,
Austin Schuh63d095d2019-02-23 11:57:12 -080030 kalman_r_position=0.05)
Austin Schuh9642a1d2019-01-21 16:54:14 -080031
32
33def main(argv):
34 if FLAGS.plot:
35 R = numpy.matrix([[1.5], [0.0]])
Theo Bafrali6915f112019-02-08 22:01:54 -080036 linear_system.PlotKick(kStilts, R)
37 linear_system.PlotMotion(kStilts, R, max_velocity=5.0)
Austin Schuh9642a1d2019-01-21 16:54:14 -080038
39 # Write the generated constants out to a file.
40 if len(argv) != 5:
41 glog.fatal(
42 'Expected .h file name and .cc file name for the elevator and integral elevator.'
43 )
44 else:
Theo Bafrali6915f112019-02-08 22:01:54 -080045 namespaces = ['y2019', 'control_loops', 'superstructure', 'stilts']
46 linear_system.WriteLinearSystem(kStilts, argv[1:3], argv[3:5],
Austin Schuh9642a1d2019-01-21 16:54:14 -080047 namespaces)
48
49
50if __name__ == '__main__':
51 argv = FLAGS(sys.argv)
52 glog.init()
53 sys.exit(main(argv))