blob: 997cf28f7df3f86a04e4fa514eebbab3d8be710a [file] [log] [blame]
Filip Kujawa37aa0bc2024-01-31 20:59:49 -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
Filip Kujawa37aa0bc2024-01-31 20:59:49 -080017kClimber = linear_system.LinearSystemParams(
18 name='Climber',
Maxwell Hendersonce232a92024-02-18 12:17:37 -080019 motor=control_loop.KrakenFOC(),
20 G=(8. / 60.) * (16. / 60.),
21 radius=16 * 0.25 / numpy.pi / 2.0 * 0.0254,
Austin Schuh087613b2024-02-19 12:39:08 -080022 mass=2.0,
23 q_pos=0.03,
24 q_vel=2.,
Filip Kujawa37aa0bc2024-01-31 20:59:49 -080025 kalman_q_pos=0.12,
26 kalman_q_vel=2.00,
27 kalman_q_voltage=35.0,
Maxwell Hendersonce232a92024-02-18 12:17:37 -080028 kalman_r_position=0.05,
29)
Filip Kujawa37aa0bc2024-01-31 20:59:49 -080030
31
32def main(argv):
33 if FLAGS.plot:
Austin Schuh087613b2024-02-19 12:39:08 -080034 R = numpy.matrix([[0.4], [0.0]])
Filip Kujawa37aa0bc2024-01-31 20:59:49 -080035 linear_system.PlotMotion(kClimber,
36 R,
37 max_velocity=5.0,
38 plant_params=kClimber)
Austin Schuh087613b2024-02-19 12:39:08 -080039 linear_system.PlotKick(kClimber, R, plant_params=kClimber)
40 return
Filip Kujawa37aa0bc2024-01-31 20:59:49 -080041
42 # Write the generated constants out to a file.
43 if len(argv) != 7:
44 glog.fatal(
45 'Expected .h file name and .cc file name for the climber and integral climber.'
46 )
47 else:
48 namespaces = ['y2024', 'control_loops', 'superstructure', 'climber']
Austin Schuh087613b2024-02-19 12:39:08 -080049 linear_system.WriteLinearSystem(kClimber, argv[1:4], argv[4:7],
50 namespaces)
Filip Kujawa37aa0bc2024-01-31 20:59:49 -080051
52
53if __name__ == '__main__':
54 argv = FLAGS(sys.argv)
55 glog.init()
56 sys.exit(main(argv))