blob: 3ad404ca5586c6e6babd07bb01e56e603fdb3099 [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(),
Austin Schuhe5248cd2023-03-05 12:46:16 -080023 G=(6.0 / 48.0) * (20.0 / 100.0) * (18.0 / 24.0) * (24.0 / 44.0),
milind-uf8bd1772023-02-20 16:27:25 -080024 # 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,
Austin Schuh6dc925b2023-02-24 16:23:32 -080027 q_pos=0.80,
28 q_vel=80.0,
milind-uf8bd1772023-02-20 16:27:25 -080029 kalman_q_pos=0.12,
30 kalman_q_vel=2.0,
Austin Schuh6dc925b2023-02-24 16:23:32 -080031 kalman_q_voltage=0.5,
milind-uf8bd1772023-02-20 16:27:25 -080032 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]])
Austin Schuha32a1892023-02-21 14:04:07 -080039 angular_system.PlotKick(kWrist, R)
40 angular_system.PlotMotion(kWrist, R)
41 return
milind-uf8bd1772023-02-20 16:27:25 -080042
43 # Write the generated constants out to a file.
James Kuszmaul630ab1d2024-01-09 16:38:57 -080044 if len(argv) != 7:
milind-uf8bd1772023-02-20 16:27:25 -080045 glog.fatal(
46 'Expected .h file name and .cc file name for the wrist and integral wrist.'
47 )
48 else:
49 namespaces = ['y2023', 'control_loops', 'superstructure', 'wrist']
James Kuszmaul630ab1d2024-01-09 16:38:57 -080050 angular_system.WriteAngularSystem(kWrist, argv[1:4], argv[4:7],
milind-uf8bd1772023-02-20 16:27:25 -080051 namespaces)
52
53
54if __name__ == '__main__':
55 argv = FLAGS(sys.argv)
56 glog.init()
57 sys.exit(main(argv))