blob: ce0fac071134f2cf05fa15d991cf43a095a11ec3 [file] [log] [blame]
milind-u53ad98a2023-02-20 16:26:09 -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
22kRoll = angular_system.AngularSystemParams(
23 name='Roll',
24 motor=control_loop.BAG(),
25 G=18.0 / 48.0 * 1.0 / 36.0,
26 # 598.006 in^2 lb
27 J=0.175,
28 q_pos=0.40,
29 q_vel=20.0,
30 kalman_q_pos=0.12,
31 kalman_q_vel=2.0,
32 kalman_q_voltage=4.0,
33 kalman_r_position=0.05,
34 radius=13 * 0.0254)
35
36
37def main(argv):
38 if FLAGS.plot:
39 R = numpy.matrix([[numpy.pi / 2.0], [0.0]])
40 angular_system.PlotKick(kRoll, R)
41 angular_system.PlotMotion(kRoll, R)
Austin Schuha32a1892023-02-21 14:04:07 -080042 return
milind-u53ad98a2023-02-20 16:26:09 -080043
44 # Write the generated constants out to a file.
45 if len(argv) != 5:
46 glog.fatal(
47 'Expected .h file name and .cc file name for the intake and integral intake.'
48 )
49 else:
50 namespaces = ['y2023', 'control_loops', 'superstructure', 'roll']
51 if FLAGS.hybrid:
52 kRoll.name = 'HybridRoll'
53 angular_system.WriteAngularSystem(
54 kRoll,
55 argv[1:3],
56 argv[3:5],
57 namespaces,
58 plant_type='StateFeedbackHybridPlant',
59 observer_type='HybridKalman')
60 else:
61 angular_system.WriteAngularSystem(kRoll, argv[1:3], argv[3:5],
62 namespaces)
63
64
65if __name__ == '__main__':
66 argv = FLAGS(sys.argv)
67 glog.init()
68 sys.exit(main(argv))