Merge "Make aimer code crash less"
diff --git a/frc971/control_loops/can_talonfx.fbs b/frc971/control_loops/can_talonfx.fbs
index 81efbb1..eea6379 100644
--- a/frc971/control_loops/can_talonfx.fbs
+++ b/frc971/control_loops/can_talonfx.fbs
@@ -22,5 +22,10 @@
   position:float (id: 5);
 
   // Nominal range is -1 to 1, but can be -2 to +2
-  duty_cycle: float (id: 6);
+  duty_cycle:float (id: 6);
+
+  // The timestamp of the measurement on the canivore clock in nanoseconds
+  // This will have less jitter than the
+  // timestamp of the message being sent out.
+  timestamp:int64 (id: 7);
 }
diff --git a/frc971/control_loops/drivetrain/drivetrain_can_position.fbs b/frc971/control_loops/drivetrain/drivetrain_can_position.fbs
index 539b18e..d598c29 100644
--- a/frc971/control_loops/drivetrain/drivetrain_can_position.fbs
+++ b/frc971/control_loops/drivetrain/drivetrain_can_position.fbs
@@ -9,7 +9,7 @@
   // The timestamp of the measurement on the canivore clock in nanoseconds
   // This will have less jitter than the
   // timestamp of the message being sent out.
-  timestamp:int64 (id: 1);
+  timestamp:int64 (id: 1, deprecated);
 
   // The ctre::phoenix::StatusCode of the measurement
   // Should be OK = 0
diff --git a/frc971/orin/argus_camera.cc b/frc971/orin/argus_camera.cc
index a4dca06..62ae36e 100644
--- a/frc971/orin/argus_camera.cc
+++ b/frc971/orin/argus_camera.cc
@@ -522,6 +522,7 @@
   aos::ShmEventLoop event_loop(&config.message());
 
   event_loop.SetRuntimeRealtimePriority(55);
+  event_loop.SetRuntimeAffinity(aos::MakeCpusetFromCpus({2, 3, 4}));
 
   aos::Sender<frc971::vision::CameraImage> sender =
       event_loop.MakeSender<frc971::vision::CameraImage>(FLAGS_channel);
diff --git a/frc971/orin/orin_irq_config.json b/frc971/orin/orin_irq_config.json
index 66699c8..8ead6ba 100644
--- a/frc971/orin/orin_irq_config.json
+++ b/frc971/orin/orin_irq_config.json
@@ -40,7 +40,7 @@
     },
     {
       "name": "cana",
-      "affinity": [4]
+      "affinity": [5]
     },
     {
       "name": "uart-pl011",
@@ -276,12 +276,12 @@
     {
       "name": "irq/*-cana",
       "scheduler": "SCHEDULER_FIFO",
-      "priority": 51,
-      "affinity": [4]
+      "priority": 60,
+      "affinity": [5]
     },
     {
       "name": "irq/*-peak_pcie",
-      "scheduler": "SCHEDULER_FIFO",
+      "scheduler": "SCHEDULER_OTHER",
       "priority": 51,
       "affinity": [5]
     },
diff --git a/frc971/wpilib/talonfx.cc b/frc971/wpilib/talonfx.cc
index ba88548..152339e 100644
--- a/frc971/wpilib/talonfx.cc
+++ b/frc971/wpilib/talonfx.cc
@@ -124,4 +124,5 @@
   can_talonfx->set_torque_current(torque_current());
   can_talonfx->set_duty_cycle(duty_cycle());
   can_talonfx->set_position(position() * gear_ratio);
+  can_talonfx->set_timestamp(GetTimestamp());
 }
diff --git a/y2023/wpilib_interface.cc b/y2023/wpilib_interface.cc
index d03bda3..492d44b 100644
--- a/y2023/wpilib_interface.cc
+++ b/y2023/wpilib_interface.cc
@@ -360,7 +360,6 @@
                 .MakeBuilder<frc971::control_loops::drivetrain::CANPosition>();
 
     can_position_builder.add_talonfxs(falcons_list);
-    can_position_builder.add_timestamp(right_front_->GetTimestamp());
     can_position_builder.add_status(static_cast<int>(status));
 
     builder.CheckOk(builder.Send(can_position_builder.Finish()));
diff --git a/y2023_bot3/wpilib_interface.cc b/y2023_bot3/wpilib_interface.cc
index 443fabd..1dd8efd 100644
--- a/y2023_bot3/wpilib_interface.cc
+++ b/y2023_bot3/wpilib_interface.cc
@@ -294,7 +294,6 @@
                 .MakeBuilder<frc971::control_loops::drivetrain::CANPosition>();
 
     can_position_builder.add_talonfxs(falcons_list);
-    can_position_builder.add_timestamp(right_front_->GetTimestamp());
     can_position_builder.add_status(static_cast<int>(status));
 
     builder.CheckOk(builder.Send(can_position_builder.Finish()));
diff --git a/y2024/constants/971.json b/y2024/constants/971.json
index 62015a3..3a7cfad 100644
--- a/y2024/constants/971.json
+++ b/y2024/constants/971.json
@@ -23,18 +23,18 @@
   "robot": {
     {% set _ = intake_pivot_zero.update(
       {
-          "measured_absolute_position" : 3.26046279713726
+          "measured_absolute_position" : 3.49222521810232
       }
     ) %}
     "intake_constants":  {{ intake_pivot_zero | tojson(indent=2)}},
     "climber_constants": {
       {% set _ = climber_zero.update(
           {
-              "measured_absolute_position" : 0.0143601265619493
+              "measured_absolute_position" :  0.00861798094474761
           }
       ) %}
       "zeroing_constants": {{ climber_zero | tojson(indent=2)}},
-      "potentiometer_offset": {{ -0.935529777248618 + 1.83632555414775 + 0.0431080619919798 - 0.493015437796464 + 0.001602382648064  +0.00194716776942403 }}
+      "potentiometer_offset": {{ -0.935529777248618 + 1.83632555414775 + 0.0431080619919798 - 0.493015437796464 + 0.001602382648064  +0.00194716776942403 - 0.030467594535944}}
     },
     "catapult_constants": {
       {% set _ = catapult_zero.update(
@@ -57,11 +57,11 @@
     "turret_constants": {
       {% set _ = turret_zero.update(
           {
-              "measured_absolute_position" : 0.210464386547614
+              "measured_absolute_position" : 0.961143535321169
           }
       ) %}
       "zeroing_constants": {{ turret_zero | tojson(indent=2)}},
-      "potentiometer_offset": {{ -6.47164779835404 - 0.0711209027239817 }}
+      "potentiometer_offset": {{ -6.47164779835404 - 0.0711209027239817 + 1.0576004531907 }}
     },
     "extend_constants": {
       {% set _ = extend_zero.update(
diff --git a/y2024/control_loops/superstructure/superstructure_can_position.fbs b/y2024/control_loops/superstructure/superstructure_can_position.fbs
index e809adf..ab69337 100644
--- a/y2024/control_loops/superstructure/superstructure_can_position.fbs
+++ b/y2024/control_loops/superstructure/superstructure_can_position.fbs
@@ -6,7 +6,7 @@
     // The timestamp of the measurement on the canivore clock in nanoseconds
     // This will have less jitter than the
     // timestamp of the message being sent out.
-    timestamp:int64 (id: 0);
+    timestamp:int64 (id: 0, deprecated);
 
     // The ctre::phoenix::StatusCode of the measurement
     // Should be OK = 0
diff --git a/y2024/wpilib_interface.cc b/y2024/wpilib_interface.cc
index 8060a69..37486d7 100644
--- a/y2024/wpilib_interface.cc
+++ b/y2024/wpilib_interface.cc
@@ -589,8 +589,6 @@
                 control_loops::drivetrain::kHighOutputRatio);
           }
 
-          drivetrain_can_builder->set_timestamp(
-              drivetrain_talonfxs.front()->GetTimestamp());
           drivetrain_can_builder->set_status(static_cast<int>(status));
 
           drivetrain_can_builder.CheckOk(drivetrain_can_builder.Send());
@@ -617,8 +615,6 @@
           extend->SerializePosition(superstructure_can_builder->add_extend(),
                                     superstructure::extend::kOutputRatio);
 
-          superstructure_can_builder->set_timestamp(
-              intake_pivot->GetTimestamp());
           superstructure_can_builder->set_status(static_cast<int>(status));
           superstructure_can_builder.CheckOk(superstructure_can_builder.Send());
         });
@@ -653,8 +649,6 @@
           retention_roller->SerializePosition(
               superstructure_can_builder->add_retention_roller(), 1.0);
 
-          superstructure_can_builder->set_timestamp(
-              intake_roller->GetTimestamp());
           superstructure_can_builder->set_status(static_cast<int>(status));
           superstructure_can_builder.CheckOk(superstructure_can_builder.Send());
         },
diff --git a/y2024_defense/wpilib_interface.cc b/y2024_defense/wpilib_interface.cc
index 6dec3c9..175f238 100644
--- a/y2024_defense/wpilib_interface.cc
+++ b/y2024_defense/wpilib_interface.cc
@@ -332,7 +332,6 @@
                 control_loops::drivetrain::kHighOutputRatio);
           }
 
-          builder->set_timestamp(falcons.front()->GetTimestamp());
           builder->set_status(static_cast<int>(status));
 
           builder.CheckOk(builder.Send());