Niko Sohmers | f2890c5 | 2022-08-20 13:35:12 -0700 | [diff] [blame^] | 1 | #!/usr/bin/python3
|
| 2 |
|
| 3 | from aos.util.trapezoid_profile import TrapezoidProfile
|
| 4 | from frc971.control_loops.python import control_loop
|
| 5 | from frc971.control_loops.python import angular_system
|
| 6 | from frc971.control_loops.python import controls
|
| 7 | import numpy
|
| 8 | import sys
|
| 9 | from matplotlib import pylab
|
| 10 | import gflags
|
| 11 | import glog
|
| 12 |
|
| 13 | FLAGS = gflags.FLAGS
|
| 14 |
|
| 15 | try:
|
| 16 | gflags.DEFINE_bool('plot', False, 'If true, plot the loop response.')
|
| 17 | except gflags.DuplicateFlagError:
|
| 18 | pass
|
| 19 |
|
| 20 | kIntake = angular_system.AngularSystemParams(
|
| 21 | name='Intake',
|
| 22 | motor=control_loop.Falcon(),
|
| 23 | # TODO(Thiago): Change gear ratios when we have all of them
|
| 24 | G=0.02,
|
| 25 | J=0.34,
|
| 26 | q_pos=0.40,
|
| 27 | q_vel=20.0,
|
| 28 | kalman_q_pos=0.12,
|
| 29 | kalman_q_vel=2.0,
|
| 30 | kalman_q_voltage=4.0,
|
| 31 | kalman_r_position=0.05,
|
| 32 | radius=13 * 0.0254)
|
| 33 |
|
| 34 |
|
| 35 | def main(argv):
|
| 36 | if FLAGS.plot:
|
| 37 | R = numpy.matrix([[numpy.pi / 2.0], [0.0]])
|
| 38 | angular_system.PlotKick(kIntake, R)
|
| 39 | angular_system.PlotMotion(kIntake, R)
|
| 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 intake and integral intake.'
|
| 45 | )
|
| 46 | else:
|
| 47 | namespaces = [
|
| 48 | 'y2022_bot3', 'control_loops', 'superstructure', 'intake'
|
| 49 | ]
|
| 50 | angular_system.WriteAngularSystem(kIntake, 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))
|