blob: d1c5710f12f69bc7d2255151750655bb70419526 [file] [log] [blame]
Austin Schuhf2a9c1a2019-01-21 16:42:28 -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
20kIntake = angular_system.AngularSystemParams(
21 name='Intake',
22 motor=control_loop.BAG(),
Alex Perry5fb5ff22019-02-09 21:53:17 -080023 G=(1.0 / 7.0) * (1.0 / 4.0) * (1.0 / 4.0)* (18.0 / 38.0),
Austin Schuhf2a9c1a2019-01-21 16:42:28 -080024 # TODO(austin): Pull moments of inertia from CAD when it's done.
25 J=0.8,
26 q_pos=0.20,
27 q_vel=5.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
33
34def main(argv):
35 if FLAGS.plot:
36 R = numpy.matrix([[numpy.pi / 2.0], [0.0]])
37 angular_system.PlotMotion(kIntake, R)
38 angular_system.PlotKick(kIntake, R)
39
40 # Write the generated constants out to a file.
41 if len(argv) != 5:
42 glog.fatal(
43 'Expected .h file name and .cc file name for the intake and integral intake.'
44 )
45 else:
46 namespaces = ['y2019', 'control_loops', 'superstructure', 'intake']
47 angular_system.WriteAngularSystem(kIntake, argv[1:3], argv[3:5],
48 namespaces)
49
50
51if __name__ == '__main__':
52 argv = FLAGS(sys.argv)
53 glog.init()
54 sys.exit(main(argv))