blob: 127def7299a4b8a5f141ed18533a55c708f10769 [file] [log] [blame]
Austin Schuh47a0ee12019-01-21 16:01:32 -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
Austin Schuhba23ba92019-02-15 23:03:10 -08007import copy
Austin Schuh47a0ee12019-01-21 16:01:32 -08008import numpy
9import sys
10from matplotlib import pylab
11import gflags
12import glog
13
14FLAGS = gflags.FLAGS
15
16try:
17 gflags.DEFINE_bool('plot', False, 'If true, plot the loop response.')
18except gflags.DuplicateFlagError:
19 pass
20
suneel2bc345d2019-02-09 20:00:56 -080021# Wrist alone
22# 0.1348
23# Wrist with ball
24# 0.3007
25# Wrist with hatch
26# 0.446
27
Austin Schuh47a0ee12019-01-21 16:01:32 -080028kWrist = angular_system.AngularSystemParams(
29 name='Wrist',
30 motor=control_loop.BAG(),
31 G=(6.0 / 60.0) * (20.0 / 100.0) * (24.0 / 84.0),
Tyler Chatow993fe282019-04-06 22:24:36 -070032 J=0.30,
Austin Schuh47a0ee12019-01-21 16:01:32 -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
Tyler Chatow993fe282019-04-06 22:24:36 -070040kWristBall = copy.copy(kWrist)
41kWristBall.J = 0.4007
42kWristBall.q_pos = 0.55
43kWristBall.q_vel = 5.0
44
45kWristPanel = copy.copy(kWrist)
46kWristPanel.J = 0.446
47
Austin Schuhba23ba92019-02-15 23:03:10 -080048kWristModel = copy.copy(kWrist)
49kWristModel.J = 0.1348
50
Austin Schuh47a0ee12019-01-21 16:01:32 -080051
52def main(argv):
53 if FLAGS.plot:
54 R = numpy.matrix([[numpy.pi / 2.0], [0.0]])
Tyler Chatow993fe282019-04-06 22:24:36 -070055 angular_system.PlotKick(kWristBall, R, plant_params=kWristBall)
56 angular_system.PlotMotion(kWristBall, R, plant_params=kWristBall)
Austin Schuh47a0ee12019-01-21 16:01:32 -080057
58 # Write the generated constants out to a file.
59 if len(argv) != 5:
60 glog.fatal(
61 'Expected .h file name and .cc file name for the wrist and integral wrist.'
62 )
63 else:
64 namespaces = ['y2019', 'control_loops', 'superstructure', 'wrist']
Tyler Chatow993fe282019-04-06 22:24:36 -070065 angular_system.WriteAngularSystem([kWrist, kWristBall, kWristPanel],
66 argv[1:3], argv[3:5], namespaces)
Austin Schuh47a0ee12019-01-21 16:01:32 -080067
68
69if __name__ == '__main__':
70 argv = FLAGS(sys.argv)
71 glog.init()
72 sys.exit(main(argv))