blob: a75ed5bd7242534b632c308a1441030e1076ccfb [file] [log] [blame]
James Kuszmaulbfdd2562024-07-06 14:18:53 -07001#!/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_current
6from frc971.control_loops.python import controls
7import numpy
8import sys
9from matplotlib import pylab
10import gflags
11import glog
12import matplotlib
13
14FLAGS = gflags.FLAGS
15
16try:
17 gflags.DEFINE_bool('plot', False, 'If true, plot the loop response.')
18except gflags.DuplicateFlagError:
19 pass
20
21kRotation = angular_system_current.AngularSystemCurrentParams(
22 name='Rotation',
23 motor=control_loop.KrakenFOC(),
24 G=9.0 / 24.0 * 14.0 / 72.0,
25 J=3.1 / 1000.0,
26 q_pos=0.05,
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=25 * 0.0254,
33 wrap_point=2.0 * numpy.pi)
34
35
36def main(argv):
37 if FLAGS.plot:
38 R = numpy.matrix([[numpy.pi / 2.0], [0.0]])
39 angular_system_current.PlotKick(kRotation, R)
40 angular_system_current.PlotMotion(kRotation, R)
41 return
42
43 # Write the generated constants out to a file.
44 if len(argv) != 7:
45 glog.fatal(
46 'Expected .h file name and .cc file name for the wrist and integral wrist.'
47 )
48 else:
49 namespaces = ['y2024_swerve', 'control_loops', 'drivetrain']
50 angular_system_current.WriteAngularSystemCurrent(
51 kRotation, argv[1:4], argv[4:7], namespaces)
52
53
54if __name__ == '__main__':
55 argv = FLAGS(sys.argv)
56 glog.init()
57 sys.exit(main(argv))