blob: 5a27afbcf887f3a17c5b94726bcded1f8c86aa6b [file] [log] [blame]
Kai Tinkess8a7b8a62020-02-01 14:38:33 -08001#!/usr/bin/python
2
3from aos.util.trapezoid_profile import TrapezoidProfile
4from frc971.control_loops.python import control_loop
5from frc971.control_loops.python import angular_system
6from frc971.control_loops.python import controls
7import copy
8import numpy
9import sys
10from matplotlib import pylab
11import gflags
12import glog
13
14FLAGS = gflags.FLAGS
15
16try:
17 gflags.DEFINE_bool('plot', False, 'If true, plot the loop response.')
18except gflags.DuplicateFlagError:
19 pass
20
21kTurret = angular_system.AngularSystemParams(
22 name='Turret',
23 motor=control_loop.Vex775Pro(),
Austin Schuhc1c957a2020-02-20 17:47:58 -080024 G=(6.0 / 60.0) * (26.0 / 150.0),
Austin Schuh2fb23642020-02-29 15:10:51 -080025 J=0.20,
26 q_pos=0.30,
27 q_vel=4.5,
Kai Tinkess8a7b8a62020-02-01 14:38:33 -080028 kalman_q_pos=0.12,
Austin Schuh2fb23642020-02-29 15:10:51 -080029 kalman_q_vel=10.0,
30 kalman_q_voltage=12.0,
Kai Tinkess8a7b8a62020-02-01 14:38:33 -080031 kalman_r_position=0.05)
32
33def main(argv):
Austin Schuh989a3132020-02-20 18:20:06 -080034 if FLAGS.plot:
35 R = numpy.matrix([[numpy.pi], [0.0]])
36 angular_system.PlotKick(kTurret, R)
37 angular_system.PlotMotion(kTurret, R)
38
Kai Tinkess8a7b8a62020-02-01 14:38:33 -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 turret.'
43 )
44 else:
45 namespaces = ['y2020', 'control_loops', 'superstructure', 'turret']
46 angular_system.WriteAngularSystem([kTurret],
47 argv[1:3], argv[3:5], namespaces)
48
49
50if __name__ == '__main__':
51 argv = FLAGS(sys.argv)
52 glog.init()
53 sys.exit(main(argv))