blob: 0864301a0f0d92fdeaa16a76b1afd928527f1cdb [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
20gflags.DEFINE_bool('hybrid', False, 'If true, make it hybrid.')
21
22kAltitude = angular_system.AngularSystemParams(
23 name='Altitude',
24 motor=control_loop.KrakenFOC(),
25 G=(16.0 / 60.0) * (16.0 / 162.0),
26 # 4340 in^ lb
Austin Schuh4ad11a62024-03-02 13:10:27 -080027 J=1.2,
James Kuszmaulc27f2c92024-04-05 17:33:55 -070028 q_pos=0.40,
Austin Schuh087613b2024-02-19 12:39:08 -080029 q_vel=8.0,
Niko Sohmers11017112024-02-18 16:03:58 -080030 kalman_q_pos=0.12,
31 kalman_q_vel=2.0,
James Kuszmaulc27f2c92024-04-05 17:33:55 -070032 kalman_q_voltage=3.0,
Niko Sohmers11017112024-02-18 16:03:58 -080033 kalman_r_position=0.05,
Austin Schuh65b4f9d2024-03-17 16:03:10 -070034 radius=10.5 * 0.0254,
35 dt=0.005)
Niko Sohmers11017112024-02-18 16:03:58 -080036
37
38def main(argv):
39 if FLAGS.plot:
40 R = numpy.matrix([[numpy.pi / 2.0], [0.0]])
41 angular_system.PlotKick(kAltitude, R)
42 angular_system.PlotMotion(kAltitude, R)
43 return
44
45 # Write the generated constants out to a file.
46 if len(argv) != 7:
47 glog.fatal(
48 'Expected .h file name and .cc file name for the intake and integral intake.'
49 )
50 else:
51 namespaces = ['y2024', 'control_loops', 'superstructure', 'altitude']
52 angular_system.WriteAngularSystem(kAltitude, argv[1:4], argv[4:7],
53 namespaces)
54
55
56if __name__ == '__main__':
57 argv = FLAGS(sys.argv)
58 glog.init()
59 sys.exit(main(argv))