First pass at tuning 2024 subsystems

The Krakens make everything a bit more exciting.  Apply a first pass at
tuning everything.

Change-Id: I4a6541c3f052a3b38fc229f2625039ab72cf00fd
Signed-off-by: Austin Schuh <austin.linux@gmail.com>
diff --git a/y2024/control_loops/python/altitude.py b/y2024/control_loops/python/altitude.py
index 157c4a5..d302b79 100644
--- a/y2024/control_loops/python/altitude.py
+++ b/y2024/control_loops/python/altitude.py
@@ -25,11 +25,11 @@
     G=(16.0 / 60.0) * (16.0 / 162.0),
     # 4340 in^ lb
     J=1.27,
-    q_pos=0.40,
-    q_vel=3.0,
+    q_pos=0.60,
+    q_vel=8.0,
     kalman_q_pos=0.12,
     kalman_q_vel=2.0,
-    kalman_q_voltage=4.0,
+    kalman_q_voltage=2.0,
     kalman_r_position=0.05,
     radius=10.5 * 0.0254)
 
diff --git a/y2024/control_loops/python/catapult.py b/y2024/control_loops/python/catapult.py
index c1b1472..f7b76e6 100644
--- a/y2024/control_loops/python/catapult.py
+++ b/y2024/control_loops/python/catapult.py
@@ -19,40 +19,52 @@
 
 gflags.DEFINE_bool('hybrid', False, 'If true, make it hybrid.')
 
+
+def AddResistance(motor, resistance):
+    motor.resistance += resistance
+    return motor
+
+
 kCatapultWithGamePiece = angular_system.AngularSystemParams(
     name='Catapult',
-    motor=control_loop.KrakenFOC(),
+    # Add the battery series resistance to make it better match.
+    motor=AddResistance(control_loop.NMotor(control_loop.KrakenFOC(), 2),
+                        0.03),
     G=(14.0 / 60.0) * (12.0 / 24.0),
     # 208.7328 in^2 lb
     J=0.065,
-    q_pos=0.40,
-    q_vel=3.0,
+    q_pos=0.80,
+    q_vel=15.0,
     kalman_q_pos=0.12,
     kalman_q_vel=2.0,
-    kalman_q_voltage=4.0,
+    kalman_q_voltage=0.7,
     kalman_r_position=0.05,
-    radius=12 * 0.0254)
+    radius=12 * 0.0254,
+    delayed_u=1)
 
 kCatapultWithoutGamePiece = angular_system.AngularSystemParams(
     name='Catapult',
-    motor=control_loop.KrakenFOC(),
+    # Add the battery series resistance to make it better match.
+    motor=AddResistance(control_loop.NMotor(control_loop.KrakenFOC(), 2),
+                        0.03),
     G=(14.0 / 60.0) * (12.0 / 24.0),
     # 135.2928 in^2 lb
     J=0.04,
-    q_pos=0.40,
-    q_vel=3.0,
+    q_pos=0.80,
+    q_vel=15.0,
     kalman_q_pos=0.12,
     kalman_q_vel=2.0,
-    kalman_q_voltage=4.0,
+    kalman_q_voltage=0.7,
     kalman_r_position=0.05,
-    radius=12 * 0.0254)
+    radius=12 * 0.0254,
+    delayed_u=1)
 
 
 def main(argv):
     if FLAGS.plot:
         R = numpy.matrix([[numpy.pi / 2.0], [0.0]])
-        angular_system.PlotKick(kCatapult, R)
-        angular_system.PlotMotion(kCatapult, R)
+        angular_system.PlotKick(kCatapultWithGamePiece, R)
+        angular_system.PlotMotion(kCatapultWithGamePiece, R)
         return
 
     # Write the generated constants out to a file.
diff --git a/y2024/control_loops/python/climber.py b/y2024/control_loops/python/climber.py
index 9dd347b..997cf28 100644
--- a/y2024/control_loops/python/climber.py
+++ b/y2024/control_loops/python/climber.py
@@ -19,9 +19,9 @@
     motor=control_loop.KrakenFOC(),
     G=(8. / 60.) * (16. / 60.),
     radius=16 * 0.25 / numpy.pi / 2.0 * 0.0254,
-    mass=1.0,
-    q_pos=0.10,
-    q_vel=1.35,
+    mass=2.0,
+    q_pos=0.03,
+    q_vel=2.,
     kalman_q_pos=0.12,
     kalman_q_vel=2.00,
     kalman_q_voltage=35.0,
@@ -31,12 +31,13 @@
 
 def main(argv):
     if FLAGS.plot:
-        R = numpy.matrix([[0.2], [0.0]])
-        linear_system.PlotKick(kClimber, R, plant_params=kClimber)
+        R = numpy.matrix([[0.4], [0.0]])
         linear_system.PlotMotion(kClimber,
                                  R,
                                  max_velocity=5.0,
                                  plant_params=kClimber)
+        linear_system.PlotKick(kClimber, R, plant_params=kClimber)
+        return
 
     # Write the generated constants out to a file.
     if len(argv) != 7:
@@ -45,7 +46,8 @@
         )
     else:
         namespaces = ['y2024', 'control_loops', 'superstructure', 'climber']
-    linear_system.WriteLinearSystem(kClimber, argv[1:4], argv[4:7], namespaces)
+        linear_system.WriteLinearSystem(kClimber, argv[1:4], argv[4:7],
+                                        namespaces)
 
 
 if __name__ == '__main__':
diff --git a/y2024/control_loops/python/extend.py b/y2024/control_loops/python/extend.py
index e84b45e..f95c995 100644
--- a/y2024/control_loops/python/extend.py
+++ b/y2024/control_loops/python/extend.py
@@ -25,20 +25,23 @@
     G=(14. / 60.) * (32. / 48.),
     radius=36 * 0.005 / numpy.pi / 2.0,
     mass=5.0,
-    q_pos=0.40,
-    q_vel=3.0,
+    q_pos=0.20,
+    q_vel=80.0,
     kalman_q_pos=0.12,
     kalman_q_vel=2.0,
-    kalman_q_voltage=4.0,
+    kalman_q_voltage=8.0,
     kalman_r_position=0.05,
 )
 
 
 def main(argv):
     if FLAGS.plot:
-        R = numpy.matrix([[numpy.pi / 2.0], [0.0]])
+        R = numpy.matrix([[0.4], [0.0]])
         linear_system.PlotKick(kExtend, R)
-        linear_system.PlotMotion(kExtend, R)
+        linear_system.PlotMotion(kExtend,
+                                 R,
+                                 max_velocity=2.0,
+                                 max_acceleration=15.0)
         return
 
     # Write the generated constants out to a file.
diff --git a/y2024/control_loops/python/intake_pivot.py b/y2024/control_loops/python/intake_pivot.py
index 81a616f..a699a2f 100644
--- a/y2024/control_loops/python/intake_pivot.py
+++ b/y2024/control_loops/python/intake_pivot.py
@@ -23,10 +23,10 @@
     G=(16. / 60.) * (18. / 62.) * (18. / 62.) * (15. / 24.),
     J=0.25,
     q_pos=0.40,
-    q_vel=20.0,
+    q_vel=60.0,
     kalman_q_pos=0.12,
     kalman_q_vel=2.0,
-    kalman_q_voltage=4.0,
+    kalman_q_voltage=2.0,
     kalman_r_position=0.05,
     radius=6.85 * 0.0254)
 
diff --git a/y2024/control_loops/python/turret.py b/y2024/control_loops/python/turret.py
index 259e104..41cc48a 100644
--- a/y2024/control_loops/python/turret.py
+++ b/y2024/control_loops/python/turret.py
@@ -23,11 +23,11 @@
     G=(14.0 / 60.0) * (28.0 / 48.0) * (22.0 / 100.0),
     # 1305 in^2 lb
     J=0.4,
-    q_pos=0.40,
-    q_vel=20.0,
+    q_pos=0.60,
+    q_vel=10.0,
     kalman_q_pos=0.12,
     kalman_q_vel=2.0,
-    kalman_q_voltage=4.0,
+    kalman_q_voltage=2.0,
     kalman_r_position=0.05,
     radius=24 * 0.0254)