blob: 54c6d7f409bdd6edb8a0549f011d1fb77f2f42a0 [file] [log] [blame]
Austin Schuhf25ee962023-02-22 22:02:27 -08001#!/usr/bin/python3
2
3from aos.util.trapezoid_profile import TrapezoidProfile
4from frc971.control_loops.python import control_loop
Ravago Jones2e8ac662023-07-01 22:57:02 -07005from frc971.control_loops.python import angular_system_current
Austin Schuhf25ee962023-02-22 22:02:27 -08006from 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
Ravago Jones2e8ac662023-07-01 22:57:02 -070020kTurret = angular_system_current.AngularSystemCurrentParams(
21 name='Turret',
22 motor=control_loop.Falcon(),
23 G=0.01,
24 J=3.1,
25 q_pos=0.05,
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=25 * 0.0254)
Austin Schuhf25ee962023-02-22 22:02:27 -080032
33
34def main(argv):
35 if FLAGS.plot:
36 R = numpy.matrix([[numpy.pi / 2.0], [0.0]])
Ravago Jones2e8ac662023-07-01 22:57:02 -070037 angular_system_current.PlotKick(kTurret, R)
38 angular_system_current.PlotMotion(kTurret, R)
Austin Schuhf25ee962023-02-22 22:02:27 -080039 return
40
41 # Write the generated constants out to a file.
42 if len(argv) != 5:
43 glog.fatal(
44 'Expected .h file name and .cc file name for the wrist and integral wrist.'
45 )
46 else:
47 namespaces = ['y2023', 'control_loops', 'superstructure', 'turret']
Ravago Jones2e8ac662023-07-01 22:57:02 -070048 angular_system_current.WriteAngularSystemCurrent(
49 kTurret, argv[1:3], argv[3:5], namespaces)
Austin Schuhf25ee962023-02-22 22:02:27 -080050
51
52if __name__ == '__main__':
53 argv = FLAGS(sys.argv)
54 glog.init()
55 sys.exit(main(argv))