blob: 26d3a16ad7224b20cd7dcc3e04fb848068d778be [file] [log] [blame]
milind-uf8bd1772023-02-20 16:27:25 -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
20kWrist = angular_system.AngularSystemParams(
21 name='Wrist',
22 motor=control_loop.BAG(),
23 G=(6.0 / 48.0) * (20.0 / 100.0) * (24.0 / 36.0) * (36.0 / 60.0),
24 # Use parallel axis theorem to get the moment of inertia around
25 # the joint (I = I_cm + mh^2 = 0.001877 + 0.8332 * 0.0407162^2)
26 J=0.003258,
27 q_pos=0.40,
28 q_vel=20.0,
29 kalman_q_pos=0.12,
30 kalman_q_vel=2.0,
31 kalman_q_voltage=4.0,
32 kalman_r_position=0.05,
33 radius=5.71 * 0.0254)
34
35
36def main(argv):
37 if FLAGS.plot:
38 R = numpy.matrix([[numpy.pi / 2.0], [0.0]])
39 angular_system.PlotKick(kIntake, R)
40 angular_system.PlotMotion(kIntake, R)
41
42 # Write the generated constants out to a file.
43 if len(argv) != 5:
44 glog.fatal(
45 'Expected .h file name and .cc file name for the wrist and integral wrist.'
46 )
47 else:
48 namespaces = ['y2023', 'control_loops', 'superstructure', 'wrist']
49 angular_system.WriteAngularSystem(kWrist, argv[1:3], argv[3:5],
50 namespaces)
51
52
53if __name__ == '__main__':
54 argv = FLAGS(sys.argv)
55 glog.init()
56 sys.exit(main(argv))