blob: fead853f843b0f46abd2c608fd0423c78e1a7ef9 [file] [log] [blame]
Austin Schuh219ace52022-02-07 21:54:16 -08001#!/usr/bin/python3
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 numpy
8import sys
9from matplotlib import pylab
10import gflags
11import glog
12
13FLAGS = gflags.FLAGS
14
15try:
16 gflags.DEFINE_bool('plot', False, 'If true, plot the loop response.')
17except gflags.DuplicateFlagError:
18 pass
19
milind-uc63d0942022-04-15 12:07:42 -070020kTurret = angular_system.AngularSystemParams(name='Turret',
21 motor=control_loop.Falcon(),
22 G=(14.0 / 66.0) * (24.0 / 58.0) *
23 (18.0 / 110.0),
24 J=2.0,
25 q_pos=0.40,
26 q_vel=20.0,
27 kalman_q_pos=0.12,
28 kalman_q_vel=2.0,
29 kalman_q_voltage=4.0,
30 kalman_r_position=0.05,
31 radius=24 * 0.0254)
Austin Schuh219ace52022-02-07 21:54:16 -080032
33
34def main(argv):
35 if FLAGS.plot:
36 R = numpy.matrix([[numpy.pi], [0.0]])
37 angular_system.PlotKick(kTurret, R)
38 angular_system.PlotMotion(kTurret, R)
39
40 # 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 turret and integral turret.'
44 )
45 else:
46 namespaces = ['y2022', 'control_loops', 'superstructure', 'turret']
47 angular_system.WriteAngularSystem(kTurret, argv[1:3], argv[3:5],
48 namespaces)
49
50
51if __name__ == '__main__':
52 argv = FLAGS(sys.argv)
53 glog.init()
54 sys.exit(main(argv))