Tune autos

This is mostly pre-Monterey auto tuning. Ther are some tweaks to the
3-piece from Monterey and some relatively minor tweaks from Monterey for
the 5-piece (the separate red/blue side tuning we did for the five piece
in Monterey are not brought in here; we stick with the blue-side
version which is essentially what we went into the event with).

Change-Id: I58d68a7d1db967f40d2254668a7ce68edbcebf6b
Signed-off-by: James Kuszmaul <jabukuszmaul+collab@gmail.com>
diff --git a/y2024/autonomous/auto_splines.h b/y2024/autonomous/auto_splines.h
index 8eb38e8..f477cee 100644
--- a/y2024/autonomous/auto_splines.h
+++ b/y2024/autonomous/auto_splines.h
@@ -35,16 +35,16 @@
             "splines/five_note.4.json")),
         two_piece_steal_spline_1_(
             aos::JsonFileToFlatbuffer<frc971::MultiSpline>(
-                "splines/five_note.0.json")),
+                "splines/2_piece_steal.0.json")),
         two_piece_steal_spline_2_(
             aos::JsonFileToFlatbuffer<frc971::MultiSpline>(
-                "splines/five_note.1.json")),
+                "splines/2_piece_steal.1.json")),
         two_piece_steal_spline_3_(
             aos::JsonFileToFlatbuffer<frc971::MultiSpline>(
-                "splines/five_note.2.json")),
+                "splines/2_piece_steal.2.json")),
         two_piece_steal_spline_4_(
             aos::JsonFileToFlatbuffer<frc971::MultiSpline>(
-                "splines/five_note.3.json")) {}
+                "splines/2_piece_steal.3.json")) {}
   static flatbuffers::Offset<frc971::MultiSpline> BasicSSpline(
       aos::Sender<frc971::control_loops::drivetrain::SplineGoal>::Builder
           *builder,
diff --git a/y2024/autonomous/autonomous_actor.cc b/y2024/autonomous/autonomous_actor.cc
index 0504cf3..6dd6f8a 100644
--- a/y2024/autonomous/autonomous_actor.cc
+++ b/y2024/autonomous/autonomous_actor.cc
@@ -78,8 +78,8 @@
           mobility_and_shoot_splines_.value()[0].starting_position();
       CHECK(starting_position_);
       break;
-    case AutonomousMode::FOUR_PIECE:
-      AOS_LOG(INFO, "FOUR_PIECE replanning!");
+    case AutonomousMode::FIVE_PIECE:
+      AOS_LOG(INFO, "FIVE_PIECE replanning!");
       four_piece_splines_ = {
           PlanSpline(
               std::bind(&AutonomousSplines::FourPieceSpline1, &auto_splines_,
@@ -123,7 +123,12 @@
           PlanSpline(
               std::bind(&AutonomousSplines::TwoPieceStealSpline4,
                         &auto_splines_, std::placeholders::_1, alliance_),
-              SplineDirection::kForward)};
+              SplineDirection::kBackward)};
+
+      starting_position_ =
+          two_piece_steal_splines_.value()[0].starting_position();
+      CHECK(starting_position_);
+      break;
   }
 
   is_planned_ = true;
@@ -150,7 +155,7 @@
     case AutonomousMode::MOBILITY_AND_SHOOT:
       MobilityAndShoot();
       break;
-    case AutonomousMode::FOUR_PIECE:
+    case AutonomousMode::FIVE_PIECE:
       FourPieceAuto();
       break;
     case AutonomousMode::TWO_PIECE_STEAL:
@@ -287,7 +292,7 @@
       INFO, "Finished second spline %lfs\n",
       aos::time::DurationInSeconds(aos::monotonic_clock::now() - start_time));
 
-  std::this_thread::sleep_for(chrono::milliseconds(250));
+  std::this_thread::sleep_for(chrono::milliseconds(200));
 
   Shoot();
 
@@ -335,7 +340,7 @@
       INFO, "Done with spline %lfs\n",
       aos::time::DurationInSeconds(aos::monotonic_clock::now() - start_time));
 
-  std::this_thread::sleep_for(chrono::milliseconds(500));
+  std::this_thread::sleep_for(chrono::milliseconds(250));
 
   AOS_LOG(
       INFO, "Shooting last note! %lfs\n",
@@ -363,7 +368,6 @@
   Aim();
   if (!WaitForPreloaded()) return;
 
-  std::this_thread::sleep_for(chrono::milliseconds(500));
   Shoot();
 
   AOS_LOG(
@@ -376,7 +380,6 @@
       INFO, "Shot first note %lfs\n",
       aos::time::DurationInSeconds(aos::monotonic_clock::now() - start_time));
 
-  Intake();
   StopFiring();
 
   AOS_LOG(
@@ -387,6 +390,9 @@
 
   splines[0].Start();
 
+  if (!splines[0].WaitForSplineDistanceRemaining(2.0)) return;
+  Intake();
+
   if (!splines[0].WaitForSplineDistanceRemaining(0.01)) return;
 
   if (!splines[1].WaitForPlan()) return;
@@ -403,9 +409,10 @@
       INFO, "Finished second spline %lfs\n",
       aos::time::DurationInSeconds(aos::monotonic_clock::now() - start_time));
 
-  std::this_thread::sleep_for(chrono::milliseconds(250));
+  std::this_thread::sleep_for(chrono::milliseconds(200));
 
   Shoot();
+  StopIntake();
 
   if (!WaitForNoteFired(initial_shot_count + 1, std::chrono::seconds(2)))
     return;
@@ -423,6 +430,10 @@
       aos::time::DurationInSeconds(aos::monotonic_clock::now() - start_time));
   splines[2].Start();
 
+  if (!splines[2].WaitForSplineDistanceRemaining(2.0)) return;
+
+  Intake();
+
   if (!splines[2].WaitForSplineDistanceRemaining(0.01)) return;
 
   if (!splines[3].WaitForPlan()) return;
@@ -436,6 +447,8 @@
 
   Shoot();
 
+  std::this_thread::sleep_for(chrono::milliseconds(400));
+
   if (!WaitForNoteFired(initial_shot_count + 2, std::chrono::seconds(2)))
     return;
 
@@ -468,6 +481,12 @@
   goal_builder.CheckOk(goal_builder.Send());
 }
 
+void AutonomousActor::StopIntake() {
+  set_intake_goal(control_loops::superstructure::IntakeGoal::NONE);
+  set_note_goal(control_loops::superstructure::NoteGoal::CATAPULT);
+  SendSuperstructureGoal();
+}
+
 void AutonomousActor::Intake() {
   set_intake_goal(control_loops::superstructure::IntakeGoal::INTAKE);
   set_note_goal(control_loops::superstructure::NoteGoal::CATAPULT);
diff --git a/y2024/autonomous/autonomous_actor.h b/y2024/autonomous/autonomous_actor.h
index 0de85bf..8abc8e3 100644
--- a/y2024/autonomous/autonomous_actor.h
+++ b/y2024/autonomous/autonomous_actor.h
@@ -43,6 +43,7 @@
   void TwoPieceStealAuto();
   void SendSuperstructureGoal();
 
+  void StopIntake();
   void Intake();
   void Aim();
   void Shoot();
diff --git a/y2024/autonomous/splines/2_piece_steal.0.json b/y2024/autonomous/splines/2_piece_steal.0.json
index e7f2843..22991bc 100644
--- a/y2024/autonomous/splines/2_piece_steal.0.json
+++ b/y2024/autonomous/splines/2_piece_steal.0.json
@@ -1,20 +1,20 @@
 {
     "spline_count": 1,
     "spline_x": [
-        -6.860785213920586,
-        -5.203804609147312,
-        -3.7777316994250265,
-        -2.667592923096702,
-        -1.3560879613526007,
-        -0.5092457179511491
+        -7.464294557723783,
+        -6.667696122353746,
+        -5.241623212631461,
+        -2.649344562378961,
+        -1.3378396006348594,
+        -0.49099735723340787
     ],
     "spline_y": [
-        -1.1157080654374518,
-        -1.1036636998527491,
-        -1.7082745320796768,
-        -2.823974049798384,
-        -2.893366029809447,
-        -3.209959853823472
+        0.25504399412981815,
+        -1.1178495529758359,
+        -1.7224603852027636,
+        -2.734000679910806,
+        -2.803392659921869,
+        -3.119986483935894
     ],
     "constraints": [
         {
@@ -27,7 +27,7 @@
         },
         {
             "constraint_type": "VOLTAGE",
-            "value": 10
+            "value": 10.0
         }
     ]
 }
\ No newline at end of file
diff --git a/y2024/autonomous/splines/2_piece_steal.1.json b/y2024/autonomous/splines/2_piece_steal.1.json
index 98c1323..5f70712 100644
--- a/y2024/autonomous/splines/2_piece_steal.1.json
+++ b/y2024/autonomous/splines/2_piece_steal.1.json
@@ -1,20 +1,20 @@
 {
     "spline_count": 1,
     "spline_x": [
-        -0.5092457179511491,
-        -1.8931992589519813,
-        -3.6060816001326397,
-        -3.8917290706695438,
-        -4.713201267483203,
-        -5.640902947694428
+        -0.49099735723340787,
+        -1.87495089823424,
+        -3.5878332394148984,
+        -4.434897728401375,
+        -5.256369925215035,
+        -6.18407160542626
     ],
     "spline_y": [
-        -3.209959853823472,
-        -2.6925657969997197,
-        -2.333279192015276,
-        -2.186602322153238,
-        -1.549542211476115,
-        -0.8645502069901454
+        -3.119986483935894,
+        -2.6025924271121417,
+        -2.243305822127698,
+        -1.4510436149779986,
+        -0.8139835043008755,
+        -0.12899149981490599
     ],
     "constraints": [
         {
diff --git a/y2024/autonomous/splines/2_piece_steal.2.json b/y2024/autonomous/splines/2_piece_steal.2.json
index ef955db..82b7713 100644
--- a/y2024/autonomous/splines/2_piece_steal.2.json
+++ b/y2024/autonomous/splines/2_piece_steal.2.json
@@ -1,20 +1,20 @@
 {
     "spline_count": 1,
     "spline_x": [
-        -5.640902947694428,
-        -4.662999278601822,
-        -3.239591234160512,
-        -3.047507215729768,
-        -1.061657126562114,
-        -0.47709853308607464
+        -6.18407160542626,
+        -5.206167936333653,
+        -4.43307070573797,
+        -3.17612250686913,
+        -1.294215637444423,
+        -0.3843367810862599
     ],
     "spline_y": [
-        -0.8645502069901454,
-        -1.5866101199714517,
-        -3.0049314806309253,
-        -3.286832304945575,
-        -2.0927386168786777,
-        -1.9056608123457113
+        -0.12899149981490599,
+        -0.8510514127962123,
+        -1.608007330741425,
+        -2.291809026288921,
+        -2.1179353172559603,
+        -1.6123055526776628
     ],
     "constraints": [
         {
@@ -23,7 +23,7 @@
         },
         {
             "constraint_type": "LATERAL_ACCELERATION",
-            "value": 2
+            "value": 1
         },
         {
             "constraint_type": "VOLTAGE",
diff --git a/y2024/autonomous/splines/2_piece_steal.3.json b/y2024/autonomous/splines/2_piece_steal.3.json
index 356d7e9..ef0a343 100644
--- a/y2024/autonomous/splines/2_piece_steal.3.json
+++ b/y2024/autonomous/splines/2_piece_steal.3.json
@@ -1,20 +1,20 @@
 {
     "spline_count": 1,
     "spline_x": [
-        -0.47709853308607464,
-        -1.1147335735554593,
-        -3.3428566977932013,
-        -2.7197061644307787,
-        -4.462847247516866,
-        -5.662538809543391
+        -0.3843367810862599,
+        -0.9952657406801264,
+        -3.223388864917868,
+        -3.2427732340458624,
+        -4.985914317131949,
+        -6.185605879158475
     ],
     "spline_y": [
-        -1.9056608123457113,
-        -2.1097248100280774,
-        -2.6177296382002626,
-        -2.8074138647816946,
-        -1.752456754116137,
-        -0.8676468782753499
+        -1.6123055526776628,
+        -1.9518055463910178,
+        -2.4598103745632027,
+        -2.084533148494687,
+        -1.0295760378291297,
+        -0.14476616198834247
     ],
     "constraints": [
         {
diff --git a/y2024/autonomous/splines/five_note.0.json b/y2024/autonomous/splines/five_note.0.json
index e21be61..1ece0b1 100644
--- a/y2024/autonomous/splines/five_note.0.json
+++ b/y2024/autonomous/splines/five_note.0.json
@@ -3,23 +3,23 @@
     "spline_x": [
         -6.837790264225116,
         -6.431035594540573,
-        -6.2550649114538475,
-        -6.681741927563226,
-        -6.377706237094424,
-        -5.921735095811581
+        -6.3853568768522155,
+        -6.536109470762101,
+        -6.2861263825343965,
+        -5.969281120927116
     ],
     "spline_y": [
         1.3535788089450442,
         1.352246384830838,
-        1.2577755750226314,
-        0.6390756151537094,
-        0.505286635887767,
-        0.26109745109761073
+        0.9118242114761634,
+        0.7117762479291074,
+        0.5676538847048089,
+        0.31121312731966144
     ],
     "constraints": [
         {
             "constraint_type": "LONGITUDINAL_ACCELERATION",
-            "value": 3
+            "value": 3.0
         },
         {
             "constraint_type": "LATERAL_ACCELERATION",
diff --git a/y2024/autonomous/splines/five_note.1.json b/y2024/autonomous/splines/five_note.1.json
index 02c7944..a24b24e 100644
--- a/y2024/autonomous/splines/five_note.1.json
+++ b/y2024/autonomous/splines/five_note.1.json
@@ -1,29 +1,29 @@
 {
     "spline_count": 1,
     "spline_x": [
-        -5.921735095811581,
-        -5.997356157615366,
-        -6.1394966638452235,
-        -6.356632365068064,
+        -5.969281120927116,
+        -6.035960507029774,
+        -6.397330764914305,
+        -6.321370480442026,
         -6.390015362394428,
         -6.442406423309679
     ],
     "spline_y": [
-        0.26109745109761073,
-        0.30159528914692224,
-        0.3303773156538068,
-        0.24034081023232307,
+        0.31121312731966144,
+        0.36518051880723346,
+        0.42223452861284927,
+        0.15435057554213572,
         0.14172167645452102,
         0.03474267887241966
     ],
     "constraints": [
         {
             "constraint_type": "LONGITUDINAL_ACCELERATION",
-            "value": 3
+            "value": 4.0
         },
         {
             "constraint_type": "LATERAL_ACCELERATION",
-            "value": 3
+            "value": 4.5
         },
         {
             "constraint_type": "VOLTAGE",
diff --git a/y2024/autonomous/splines/five_note.2.json b/y2024/autonomous/splines/five_note.2.json
index 442ce48..3a8f9bf 100644
--- a/y2024/autonomous/splines/five_note.2.json
+++ b/y2024/autonomous/splines/five_note.2.json
@@ -4,17 +4,17 @@
         -6.442406423309679,
         -6.09480165393726,
         -5.554752477197956,
-        -5.500010615292536,
-        -5.505673744840998,
-        -5.450725524128315
+        -5.499633139479728,
+        -5.50529626902819,
+        -5.450348048315508
     ],
     "spline_y": [
         0.03474267887241966,
         0.7445280722694474,
         1.1059794544455144,
-        1.0226571920273129,
-        1.4628922679287215,
-        2.245294280677646
+        1.1560777656770767,
+        1.5963128415784853,
+        2.3787148543274097
     ],
     "constraints": [
         {
@@ -31,8 +31,8 @@
         },
         {
             "constraint_type": "VELOCITY",
-            "value": 0.6,
-            "start_distance": 1.5,
+            "value": 0.45,
+            "start_distance": 1.6,
             "end_distance": 10.0
         }
     ]
diff --git a/y2024/autonomous/splines/five_note.3.json b/y2024/autonomous/splines/five_note.3.json
index f4239d6..89dd72f 100644
--- a/y2024/autonomous/splines/five_note.3.json
+++ b/y2024/autonomous/splines/five_note.3.json
@@ -1,17 +1,17 @@
 {
     "spline_count": 1,
     "spline_x": [
-        -5.450725524128315,
-        -5.4125513915961285,
-        -3.9062446310670764,
+        -5.450348048315508,
+        -5.412173915783321,
+        -3.905867155254269,
         -2.390277169363972,
         -1.4242176922097336,
         -0.44894876385221405
     ],
     "spline_y": [
-        2.245294280677646,
-        2.7888517924722676,
-        3.9025565085593934,
+        2.3787148543274097,
+        2.9222723661220313,
+        4.035977082209158,
         2.9014194169393095,
         2.4045843838581282,
         2.0389901653192535
@@ -27,7 +27,7 @@
         },
         {
             "constraint_type": "VOLTAGE",
-            "value": 8.0
+            "value": 10.0
         },
         {
             "constraint_type": "VELOCITY",
diff --git a/y2024/autonomous/splines/five_note.4.json b/y2024/autonomous/splines/five_note.4.json
index 1c210a5..76ad4c3 100644
--- a/y2024/autonomous/splines/five_note.4.json
+++ b/y2024/autonomous/splines/five_note.4.json
@@ -4,22 +4,22 @@
         -0.44894876385221405,
         -1.42422446903808,
         -2.3902839461923184,
-        -3.6552329072641223,
-        -4.682377123355169,
-        -5.357290416833793
+        -4.170024929006823,
+        -5.19716914509787,
+        -5.872082438576494
     ],
     "spline_y": [
         2.0389901653192535,
         2.4045869242541067,
         2.901421957335288,
-        2.3043000750345737,
-        1.9165787798578524,
-        1.7991159872216307
+        2.268920393640828,
+        1.8811990984641065,
+        1.7637363058278848
     ],
     "constraints": [
         {
             "constraint_type": "LONGITUDINAL_ACCELERATION",
-            "value": 4.5
+            "value": 2.8
         },
         {
             "constraint_type": "LATERAL_ACCELERATION",
@@ -27,12 +27,12 @@
         },
         {
             "constraint_type": "VOLTAGE",
-            "value": 10.000000000000007
+            "value": 9.5
         },
         {
             "constraint_type": "VELOCITY",
-            "value": 6.4,
-            "start_distance": 0.0,
+            "value": 1.0,
+            "start_distance": 5.35,
             "end_distance": 100.0
         }
     ]
diff --git a/y2024/constants/common.json b/y2024/constants/common.json
index 9ac7cb8..d6d948b 100644
--- a/y2024/constants/common.json
+++ b/y2024/constants/common.json
@@ -255,7 +255,7 @@
   },
   "turret_avoid_extend_collision_position": 0.0,
   "altitude_avoid_extend_collision_position": 0.3,
-  "autonomous_mode": "FOUR_PIECE",
+  "autonomous_mode": "FIVE_PIECE",
   "ignore_targets": {
     "red": [1, 2, 5, 6, 9, 10, 11, 12, 13, 14, 15, 16],
     "blue": [1, 2, 5, 6, 9, 10, 11, 12, 13, 14, 15, 16]
diff --git a/y2024/constants/constants.fbs b/y2024/constants/constants.fbs
index f652b22..a558c9b 100644
--- a/y2024/constants/constants.fbs
+++ b/y2024/constants/constants.fbs
@@ -122,7 +122,7 @@
   // Simple drive-and-shoot to pick up at most one game piece.
   MOBILITY_AND_SHOOT = 2,
   // Auto to pick up four game pieces.
-  FOUR_PIECE = 3,
+  FIVE_PIECE = 3,
   // Auto which picks up two game pieces from the center
   TWO_PIECE_STEAL = 4,
 }