blob: fd1707b63d2d9715680aaf8191b1723c2e97b7f5 [file] [log] [blame]
Siddhant Kanwar0e37f592022-02-21 19:26:50 -08001#!/usr/bin/python3
2
3from frc971.control_loops.python import control_loop
4from frc971.control_loops.python import linear_system
5import numpy
6import sys
7import gflags
8import glog
9
10FLAGS = gflags.FLAGS
11
12try:
13 gflags.DEFINE_bool('plot', False, 'If true, plot the loop response.')
14except gflags.DuplicateFlagError:
15 pass
16
17kClimber = linear_system.LinearSystemParams(
18 name='Climber',
19 motor=control_loop.Falcon(),
20 G=(1.0 / 10.0) * (1.0 / 3.0) * (1.0 / 3.0),
21 radius=22 * 0.25 / numpy.pi / 2.0 * 0.0254,
22 mass=2.0,
23 q_pos=0.10,
24 q_vel=1.35,
25 kalman_q_pos=0.12,
26 kalman_q_vel=2.00,
27 kalman_q_voltage=35.0,
28 kalman_r_position=0.05)
29
30def main(argv):
31 if FLAGS.plot:
32 R = numpy.matrix([[0.2], [0.0]])
33 linear_system.PlotKick(kClimber, R, plant_params=kClimber)
34 linear_system.PlotMotion(
35 kClimber, R, max_velocity=5.0, plant_params=kClimber)
36
37 # Write the generated constants out to a file.
38 if len(argv) != 5:
39 glog.fatal(
40 'Expected .h file name and .cc file name for the climber and integral climber.'
41 )
42 else:
43 namespaces = ['y2022', 'control_loops', 'superstructure', 'climber']
44 linear_system.WriteLinearSystem(kClimber,
45 argv[1:3], argv[3:5], namespaces)
46
47
48if __name__ == '__main__':
49 argv = FLAGS(sys.argv)
50 glog.init()
51 sys.exit(main(argv))