blob: c240d01faa571e3cb83f9a9b5bdca45bd534e248 [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(),
Maxwell Hendersonce232a92024-02-18 12:17:37 -080023 G=(16. / 60.) * (18. / 62.) * (18. / 62.) * (15. / 24.),
Maxwell Henderson6b1be312024-02-28 20:15:06 -080024 J=0.4,
25 q_pos=1.0,
26 q_vel=800.0,
Niko Sohmersb21dbdc2024-01-20 20:06:59 -080027 kalman_q_pos=0.12,
28 kalman_q_vel=2.0,
James Kuszmaula4226f52024-03-01 21:29:12 -080029 kalman_q_voltage=1.0,
Niko Sohmersb21dbdc2024-01-20 20:06:59 -080030 kalman_r_position=0.05,
James Kuszmaula4226f52024-03-01 21:29:12 -080031 radius=6.85 * 0.0254,
Austin Schuh65b4f9d2024-03-17 16:03:10 -070032 enable_voltage_error=False,
33 dt=0.005)
Niko Sohmersb21dbdc2024-01-20 20:06:59 -080034
35
36def main(argv):
37 if FLAGS.plot:
38 R = numpy.matrix([[numpy.pi / 2.0], [0.0]])
39 angular_system.PlotKick(kIntakePivot, R)
40 angular_system.PlotMotion(kIntakePivot, R)
41 return
42 if len(argv) != 7:
43 glog.fatal(
44 'Expected .h file name and .cc file name for the intake pivot and integral intake pivot.'
45 )
46 else:
47 namespaces = [
48 'y2024', 'control_loops', 'superstructure', 'intake_pivot'
49 ]
50 angular_system.WriteAngularSystem(kIntakePivot, argv[1:4], argv[4:7],
51 namespaces)
52
53
54if __name__ == '__main__':
55 argv = FLAGS(sys.argv)
56 glog.init()
Maxwell Hendersonce232a92024-02-18 12:17:37 -080057 sys.exit(main(argv))