blob: 9e7543b7d17b41217a6046d3ae76aa741e7163e3 [file] [log] [blame]
Niko Sohmersb21dbdc2024-01-20 20:06:59 -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
20kIntakePivot = angular_system.AngularSystemParams(
21 name='IntakePivot',
22 motor=control_loop.KrakenFOC(),
23 # TODO(Niko): Change gear ratios when we have all of them
24 G=0.02,
25 J=0.34,
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=13 * 0.0254)
33
34
35def main(argv):
36 if FLAGS.plot:
37 R = numpy.matrix([[numpy.pi / 2.0], [0.0]])
38 angular_system.PlotKick(kIntakePivot, R)
39 angular_system.PlotMotion(kIntakePivot, R)
40 return
41 if len(argv) != 7:
42 glog.fatal(
43 'Expected .h file name and .cc file name for the intake pivot and integral intake pivot.'
44 )
45 else:
46 namespaces = [
47 'y2024', 'control_loops', 'superstructure', 'intake_pivot'
48 ]
49 angular_system.WriteAngularSystem(kIntakePivot, 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))