blob: 9f4f488ec9ff89c6f51e556c4caee4e77c38293b [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),
suneel2bc345d2019-02-09 20:00:56 -080024 # Suneel: Sampled moment of inertia at 6 different positions
25 # J = the average of the six.
26 # 1. 0.686
27 # 2. 0.637
28 # 3. 0.514
29 # 4. 0.332
30 # 5. 0.183
31 # 6. 0.149
32 J=0.3,
Austin Schuhf2a9c1a2019-01-21 16:42:28 -080033 q_pos=0.20,
34 q_vel=5.0,
35 kalman_q_pos=0.12,
36 kalman_q_vel=2.0,
37 kalman_q_voltage=4.0,
38 kalman_r_position=0.05)
39
40
41def main(argv):
42 if FLAGS.plot:
43 R = numpy.matrix([[numpy.pi / 2.0], [0.0]])
Austin Schuhf2a9c1a2019-01-21 16:42:28 -080044 angular_system.PlotKick(kIntake, R)
Austin Schuhba23ba92019-02-15 23:03:10 -080045 angular_system.PlotMotion(kIntake, R)
Austin Schuhf2a9c1a2019-01-21 16:42:28 -080046
47 # Write the generated constants out to a file.
48 if len(argv) != 5:
49 glog.fatal(
50 'Expected .h file name and .cc file name for the intake and integral intake.'
51 )
52 else:
53 namespaces = ['y2019', 'control_loops', 'superstructure', 'intake']
54 angular_system.WriteAngularSystem(kIntake, argv[1:3], argv[3:5],
55 namespaces)
56
57
58if __name__ == '__main__':
59 argv = FLAGS(sys.argv)
60 glog.init()
61 sys.exit(main(argv))