blob: 259e104d5e82c423bd70baf075a00922035beec9 [file] [log] [blame]
Niko Sohmers11017112024-02-18 16:03:58 -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
20kTurret = angular_system.AngularSystemParams(
21 name='Turret',
22 motor=control_loop.KrakenFOC(),
23 G=(14.0 / 60.0) * (28.0 / 48.0) * (22.0 / 100.0),
24 # 1305 in^2 lb
25 J=0.4,
26 q_pos=0.40,
27 q_vel=20.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,
32 radius=24 * 0.0254)
33
34
35def main(argv):
36 if FLAGS.plot:
37 R = numpy.matrix([[numpy.pi], [0.0]])
38 angular_system.PlotKick(kTurret, R)
39 angular_system.PlotMotion(kTurret, R)
40
41 # Write the generated constants out to a file.
42 if len(argv) != 7:
43 glog.fatal(
44 'Expected .h file name and .cc file name for the turret and integral turret.'
45 )
46 else:
47 namespaces = ['y2024', 'control_loops', 'superstructure', 'turret']
48 angular_system.WriteAngularSystem(kTurret, argv[1:4], argv[4:7],
49 namespaces)
50
51
52if __name__ == '__main__':
53 argv = FLAGS(sys.argv)
54 glog.init()
55 sys.exit(main(argv))