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