blob: 8c99940dc8a77e1208e3d0618a7d0e8780829e77 [file] [log] [blame]
Sabina Davis24d94e02020-01-31 21:32:41 -08001#!/usr/bin/python
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
20'''
21Hood is an angular subsystem due to the mounting of the encoder on the hood joint.
22We are currently electing to ignore potential non-linearity.
23'''
24
25#TODO: update constants
26kHood = angular_system.AngularSystemParams(
27 name='Hood',
28 motor=control_loop.BAG(),
29 # meters / rad (used the displacement of the lead screw and the angle)
30 G=(0.1601 / 0.6457),
31 J=0.3,
32 q_pos=0.20,
33 q_vel=5.0,
34 kalman_q_pos=0.12,
35 kalman_q_vel=2.0,
36 kalman_q_voltage=4.0,
37 kalman_r_position=0.05)
38
39
40def main(argv):
41 if FLAGS.plot:
42 R = numpy.matrix([[numpy.pi / 2.0], [0.0]])
43 angular_system.PlotKick(kHood, R)
44 angular_system.PlotMotion(kHood, R)
45
46 # Write the generated constants out to a file.
47 if len(argv) != 5:
48 glog.fatal(
49 'Expected .h file name and .cc file name for the hood and integral hood.'
50 )
51 else:
52 namespaces = ['y2020', 'control_loops', 'superstructure', 'hood']
53 angular_system.WriteAngularSystem(kHood, argv[1:3], argv[3:5],
54 namespaces)
55
56
57if __name__ == '__main__':
58 argv = FLAGS(sys.argv)
59 glog.init()
60 sys.exit(main(argv))