blob: 7e957581e2bb038f75409f7805922711ba4baaef [file] [log] [blame]
Sabina Davis6b9d84a2020-02-02 14:51:35 -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
Sabina Davis6b9d84a2020-02-02 14:51:35 -080020kIntake = angular_system.AngularSystemParams(
21 name='Intake',
22 motor=control_loop.BAG(),
Austin Schuhc1c957a2020-02-20 17:47:58 -080023 G=(12.0 / 24.0) * (1.0 / 7.0) * (1.0 / 7.0) * (16.0 / 32.0),
24 J=3.0 * 0.139 * 0.139,
Sabina Davis6b9d84a2020-02-02 14:51:35 -080025 q_pos=0.20,
26 q_vel=5.0,
27 kalman_q_pos=0.12,
28 kalman_q_vel=2.0,
29 kalman_q_voltage=4.0,
30 kalman_r_position=0.05)
31
32
33def main(argv):
34 if FLAGS.plot:
35 R = numpy.matrix([[numpy.pi / 2.0], [0.0]])
36 angular_system.PlotKick(kIntake, R)
37 angular_system.PlotMotion(kIntake, R)
38
39 # Write the generated constants out to a file.
40 if len(argv) != 5:
41 glog.fatal(
42 'Expected .h file name and .cc file name for the intake and integral intake.'
43 )
44 else:
45 namespaces = ['y2020', 'control_loops', 'superstructure', 'intake']
46 angular_system.WriteAngularSystem(kIntake, argv[1:3], argv[3:5],
47 namespaces)
48
49
50if __name__ == '__main__':
51 argv = FLAGS(sys.argv)
52 glog.init()
53 sys.exit(main(argv))