blob: ceb417020039322a0f4bc9c346977f93c0f3be4f [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,
28 kalman_q_pos=0.12,
29 kalman_q_vel=2.0,
30 kalman_q_voltage=4.0,
31 kalman_r_position=0.05)
Comran Morshed2ae094e2016-01-23 20:43:20 +000032
33
34def main(argv):
Austin Schuh2e554032019-01-21 15:07:27 -080035 if FLAGS.plot:
36 R = numpy.matrix([[numpy.pi / 2.0], [0.0]])
37 angular_system.PlotMotion(kIntake, R)
Comran Morshed2ae094e2016-01-23 20:43:20 +000038
Austin Schuh2e554032019-01-21 15:07:27 -080039 # 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 intake and integral intake.'
43 )
44 else:
45 namespaces = ['y2016', 'control_loops', 'superstructure']
46 angular_system.WriteAngularSystem(kIntake, argv[1:3], argv[3:5],
47 namespaces)
Comran Morshed2ae094e2016-01-23 20:43:20 +000048
Comran Morshed2ae094e2016-01-23 20:43:20 +000049
50if __name__ == '__main__':
Austin Schuh2e554032019-01-21 15:07:27 -080051 argv = FLAGS(sys.argv)
52 glog.init()
53 sys.exit(main(argv))