blob: 66b7b26e420132b19bc73b6df180ed1fba3b6caf [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),
suneel2bc345d2019-02-09 20:00:56 -080032 J=0.27,
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
Austin Schuhba23ba92019-02-15 23:03:10 -080040kWristModel = copy.copy(kWrist)
41kWristModel.J = 0.1348
42
Austin Schuh47a0ee12019-01-21 16:01:32 -080043
44def main(argv):
45 if FLAGS.plot:
46 R = numpy.matrix([[numpy.pi / 2.0], [0.0]])
Austin Schuhba23ba92019-02-15 23:03:10 -080047 angular_system.PlotKick(kWrist, R, plant_params=kWristModel)
48 angular_system.PlotMotion(kWrist, R, plant_params=kWristModel)
Austin Schuh47a0ee12019-01-21 16:01:32 -080049
50 # Write the generated constants out to a file.
51 if len(argv) != 5:
52 glog.fatal(
53 'Expected .h file name and .cc file name for the wrist and integral wrist.'
54 )
55 else:
56 namespaces = ['y2019', 'control_loops', 'superstructure', 'wrist']
57 angular_system.WriteAngularSystem(kWrist, argv[1:3], argv[3:5],
58 namespaces)
59
60
61if __name__ == '__main__':
62 argv = FLAGS(sys.argv)
63 glog.init()
64 sys.exit(main(argv))