blob: 07c3d90800d0c61b099fa093ca68160b9f02af5b [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,
Austin Schuh087613b2024-02-19 12:39:08 -080026 q_pos=0.60,
27 q_vel=10.0,
Niko Sohmers11017112024-02-18 16:03:58 -080028 kalman_q_pos=0.12,
29 kalman_q_vel=2.0,
Austin Schuh087613b2024-02-19 12:39:08 -080030 kalman_q_voltage=2.0,
Niko Sohmers11017112024-02-18 16:03:58 -080031 kalman_r_position=0.05,
Austin Schuh65b4f9d2024-03-17 16:03:10 -070032 radius=24 * 0.0254,
33 dt=0.005)
Niko Sohmers11017112024-02-18 16:03:58 -080034
35
36def main(argv):
37 if FLAGS.plot:
38 R = numpy.matrix([[numpy.pi], [0.0]])
39 angular_system.PlotKick(kTurret, R)
40 angular_system.PlotMotion(kTurret, R)
41
42 # Write the generated constants out to a file.
43 if len(argv) != 7:
44 glog.fatal(
45 'Expected .h file name and .cc file name for the turret and integral turret.'
46 )
47 else:
48 namespaces = ['y2024', 'control_loops', 'superstructure', 'turret']
49 angular_system.WriteAngularSystem(kTurret, argv[1:4], argv[4:7],
50 namespaces)
51
52
53if __name__ == '__main__':
54 argv = FLAGS(sys.argv)
55 glog.init()
56 sys.exit(main(argv))