blob: 015fdfaa0b78c868e0f0ed4eec1c8b6257be9fa1 [file] [log] [blame]
Austin Schuh48d60c12017-02-04 21:58:58 -08001#!/usr/bin/python
2
Austin Schuh48d60c12017-02-04 21:58:58 -08003from frc971.control_loops.python import control_loop
Austin Schuhb5d302f2019-01-20 20:51:19 -08004from frc971.control_loops.python import linear_system
Austin Schuh48d60c12017-02-04 21:58:58 -08005import numpy
6import sys
Austin Schuh48d60c12017-02-04 21:58:58 -08007import gflags
8import glog
9
10FLAGS = gflags.FLAGS
11
12try:
Austin Schuhb5d302f2019-01-20 20:51:19 -080013 gflags.DEFINE_bool('plot', False, 'If true, plot the loop response.')
Austin Schuh48d60c12017-02-04 21:58:58 -080014except gflags.DuplicateFlagError:
Austin Schuhb5d302f2019-01-20 20:51:19 -080015 pass
Austin Schuh48d60c12017-02-04 21:58:58 -080016
Austin Schuhb5d302f2019-01-20 20:51:19 -080017kIntake = linear_system.LinearSystemParams(
18 name='Intake',
19 motor=control_loop.Vex775Pro(),
Austin Schuh48d60c12017-02-04 21:58:58 -080020 # (1 / 35.0) * (20.0 / 40.0) -> 16 tooth sprocket on #25 chain
Austin Schuhb5d302f2019-01-20 20:51:19 -080021 G=(1.0 / 35.0) * (20.0 / 40.0),
22 radius=16.0 * 0.25 / (2.0 * numpy.pi) * 0.0254,
23 mass=5.4,
24 q_pos=0.015,
25 q_vel=0.3,
26 kalman_q_pos=0.12,
27 kalman_q_vel=2.00,
28 kalman_q_voltage=40.0,
29 kalman_r_position=0.05)
Austin Schuh48d60c12017-02-04 21:58:58 -080030
31
32def main(argv):
Austin Schuhb5d302f2019-01-20 20:51:19 -080033 if FLAGS.plot:
34 R = numpy.matrix([[0.1], [0.0]])
35 linear_system.PlotMotion(kIntake, R)
Austin Schuh48d60c12017-02-04 21:58:58 -080036
Austin Schuhb5d302f2019-01-20 20:51:19 -080037 # Write the generated constants out to a file.
38 if len(argv) != 5:
39 glog.fatal(
40 'Expected .h file name and .cc file name for the intake and integral intake.'
41 )
42 else:
43 namespaces = ['y2017', 'control_loops', 'superstructure', 'intake']
44 linear_system.WriteLinearSystem(kIntake, argv[1:3], argv[3:5],
45 namespaces)
Austin Schuh48d60c12017-02-04 21:58:58 -080046
Austin Schuh48d60c12017-02-04 21:58:58 -080047
48if __name__ == '__main__':
Austin Schuhb5d302f2019-01-20 20:51:19 -080049 argv = FLAGS(sys.argv)
50 glog.init()
51 sys.exit(main(argv))