blob: 6d0509ddb128ba7b752d2a3fc6abaa105921124e [file] [log] [blame]
Comran Morshed2ae094e2016-01-23 20:43:20 +00001#!/usr/bin/python
2
John Park33858a32018-09-28 23:05:48 -07003from aos.util.trapezoid_profile import TrapezoidProfile
Comran Morshed2ae094e2016-01-23 20:43:20 +00004from frc971.control_loops.python import control_loop
Austin Schuh2e554032019-01-21 15:07:27 -08005from frc971.control_loops.python import angular_system
Comran Morshed2ae094e2016-01-23 20:43:20 +00006from frc971.control_loops.python import controls
Comran Morshed2ae094e2016-01-23 20:43:20 +00007import numpy
8import sys
Comran Morshed2ae094e2016-01-23 20:43:20 +00009from matplotlib import pylab
10import gflags
11import glog
12
13FLAGS = gflags.FLAGS
14
15try:
Austin Schuh2e554032019-01-21 15:07:27 -080016 gflags.DEFINE_bool('plot', False, 'If true, plot the loop response.')
Comran Morshed2ae094e2016-01-23 20:43:20 +000017except gflags.DuplicateFlagError:
Austin Schuh2e554032019-01-21 15:07:27 -080018 pass
Comran Morshed2ae094e2016-01-23 20:43:20 +000019
Austin Schuh2e554032019-01-21 15:07:27 -080020kIntake = angular_system.AngularSystemParams(
21 name='Intake',
22 motor=control_loop.Vex775Pro(),
23 # (1 / 35.0) * (20.0 / 40.0) -> 16 tooth sprocket on #25 chain
24 G=(12.0 / 56.0) * (14.0 / 54.0) * (18.0 / 64.0) * (16.0 / 48.0),
25 J=0.34 - 0.03757568,
26 q_pos=0.20,
27 q_vel=5.0,
Austin Schuh63d095d2019-02-23 11:57:12 -080028 dt=0.005,
Austin Schuh2e554032019-01-21 15:07:27 -080029 kalman_q_pos=0.12,
30 kalman_q_vel=2.0,
31 kalman_q_voltage=4.0,
32 kalman_r_position=0.05)
Comran Morshed2ae094e2016-01-23 20:43:20 +000033
34
35def main(argv):
Austin Schuh2e554032019-01-21 15:07:27 -080036 if FLAGS.plot:
37 R = numpy.matrix([[numpy.pi / 2.0], [0.0]])
38 angular_system.PlotMotion(kIntake, R)
Comran Morshed2ae094e2016-01-23 20:43:20 +000039
Austin Schuh2e554032019-01-21 15:07:27 -080040 # 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 intake and integral intake.'
44 )
45 else:
46 namespaces = ['y2016', 'control_loops', 'superstructure']
47 angular_system.WriteAngularSystem(kIntake, argv[1:3], argv[3:5],
48 namespaces)
Comran Morshed2ae094e2016-01-23 20:43:20 +000049
Comran Morshed2ae094e2016-01-23 20:43:20 +000050
51if __name__ == '__main__':
Austin Schuh2e554032019-01-21 15:07:27 -080052 argv = FLAGS(sys.argv)
53 glog.init()
54 sys.exit(main(argv))