blob: 12d9cd0eb80d1b91e577d1e8eacf0e2b3ea07dcb [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(),
milind-u6e7d8d42022-04-06 18:30:43 -070020 G=(1.0 / 4.0) * (1.0 / 3.0) * (1.0 / 3.0),
Siddhant Kanwar0e37f592022-02-21 19:26:50 -080021 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
Ravago Jones5127ccc2022-07-31 16:32:45 -070030
Siddhant Kanwar0e37f592022-02-21 19:26:50 -080031def main(argv):
32 if FLAGS.plot:
33 R = numpy.matrix([[0.2], [0.0]])
34 linear_system.PlotKick(kClimber, R, plant_params=kClimber)
Ravago Jones5127ccc2022-07-31 16:32:45 -070035 linear_system.PlotMotion(kClimber,
36 R,
37 max_velocity=5.0,
38 plant_params=kClimber)
Siddhant Kanwar0e37f592022-02-21 19:26:50 -080039
40 # Write the generated constants out to a file.
41 if len(argv) != 5:
42 glog.fatal(
43 'Expected .h file name and .cc file name for the climber and integral climber.'
44 )
45 else:
46 namespaces = ['y2022', 'control_loops', 'superstructure', 'climber']
Ravago Jones5127ccc2022-07-31 16:32:45 -070047 linear_system.WriteLinearSystem(kClimber, argv[1:3], argv[3:5],
48 namespaces)
Siddhant Kanwar0e37f592022-02-21 19:26:50 -080049
50
51if __name__ == '__main__':
52 argv = FLAGS(sys.argv)
53 glog.init()
54 sys.exit(main(argv))