Run clang-format on the entire repo

This patch clang-formats the entire repo. Third-party code is
excluded.

I needed to fix up the .clang-format file so that all the header
includes are ordered properly. I could have sworn that it used to work
without the extra modification, but I guess not.

Signed-off-by: Philipp Schrader <philipp.schrader@gmail.com>
Change-Id: I64bb9f2c795401393f9dfe2fefc4f04cb36b52f6
diff --git a/y2022/localizer/kernel/adis16505.c b/y2022/localizer/kernel/adis16505.c
index 963ca4a..f0eb6ae 100644
--- a/y2022/localizer/kernel/adis16505.c
+++ b/y2022/localizer/kernel/adis16505.c
@@ -8,14 +8,12 @@
 #include <linux/kernel.h> /* Needed for pr_info() */
 #include <linux/kfifo.h>
 #include <linux/module.h> /* Needed by all modules */
-#include <linux/poll.h>
-
-#include <linux/of_gpio.h>
-#include <linux/spi/spi.h>
-#include <linux/of_address.h>
 #include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/of_gpio.h>
 #include <linux/of_platform.h>
-
+#include <linux/poll.h>
+#include <linux/spi/spi.h>
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("frc971");
@@ -115,10 +113,10 @@
         return -EAGAIN;
       }
 
-      err = wait_event_interruptible(ts->wq,
-                                     (spin_lock(&ts->fifo_read_lock),
-                                      empty = !kfifo_is_empty(&ts->fifo),
-                                      spin_unlock(&ts->fifo_read_lock), empty));
+      err = wait_event_interruptible(
+          ts->wq,
+          (spin_lock(&ts->fifo_read_lock), empty = !kfifo_is_empty(&ts->fifo),
+           spin_unlock(&ts->fifo_read_lock), empty));
       if (err != 0) {
         return err;
       }
@@ -330,4 +328,4 @@
     .remove = adis16505_remove,
 };
 
-module_spi_driver(adis16505_driver); 
+module_spi_driver(adis16505_driver);
diff --git a/y2022/localizer/localizer.cc b/y2022/localizer/localizer.cc
index ec81573..b774e18 100644
--- a/y2022/localizer/localizer.cc
+++ b/y2022/localizer/localizer.cc
@@ -909,43 +909,43 @@
             absl::StrCat("/", kPisToUse[camera_index], "/camera"));
   }
   aos::TimerHandler *estimate_timer = event_loop_->AddTimer([this]() {
-      const bool maybe_in_auto = utils_.MaybeInAutonomous();
-      model_based_.set_use_aggressive_image_corrections(!maybe_in_auto);
-      for (size_t camera_index = 0; camera_index < kPisToUse.size();
-           ++camera_index) {
-        if (model_based_.NumQueuedImageDebugs() ==
-                ModelBasedLocalizer::kDebugBufferSize ||
-            (last_visualization_send_ + kMinVisualizationPeriod <
-             event_loop_->monotonic_now())) {
-          auto builder = visualization_sender_.MakeBuilder();
-          visualization_sender_.CheckOk(
-              builder.Send(model_based_.PopulateVisualization(builder.fbb())));
+    const bool maybe_in_auto = utils_.MaybeInAutonomous();
+    model_based_.set_use_aggressive_image_corrections(!maybe_in_auto);
+    for (size_t camera_index = 0; camera_index < kPisToUse.size();
+         ++camera_index) {
+      if (model_based_.NumQueuedImageDebugs() ==
+              ModelBasedLocalizer::kDebugBufferSize ||
+          (last_visualization_send_ + kMinVisualizationPeriod <
+           event_loop_->monotonic_now())) {
+        auto builder = visualization_sender_.MakeBuilder();
+        visualization_sender_.CheckOk(
+            builder.Send(model_based_.PopulateVisualization(builder.fbb())));
+      }
+      if (target_estimate_fetchers_[camera_index].Fetch()) {
+        const std::optional<aos::monotonic_clock::duration> monotonic_offset =
+            utils_.ClockOffset(kPisToUse[camera_index]);
+        if (!monotonic_offset.has_value()) {
+          model_based_.TallyRejection(
+              RejectionReason::MESSAGE_BRIDGE_DISCONNECTED);
+          continue;
         }
-        if (target_estimate_fetchers_[camera_index].Fetch()) {
-          const std::optional<aos::monotonic_clock::duration> monotonic_offset =
-              utils_.ClockOffset(kPisToUse[camera_index]);
-          if (!monotonic_offset.has_value()) {
-            model_based_.TallyRejection(
-                RejectionReason::MESSAGE_BRIDGE_DISCONNECTED);
-            continue;
-          }
-          // TODO(james): Get timestamp from message contents.
-          aos::monotonic_clock::time_point capture_time(
-              target_estimate_fetchers_[camera_index]
-                  .context()
-                  .monotonic_remote_time -
-              monotonic_offset.value());
-          if (capture_time > target_estimate_fetchers_[camera_index]
-                                 .context()
-                                 .monotonic_event_time) {
-            model_based_.TallyRejection(RejectionReason::IMAGE_FROM_FUTURE);
-            continue;
-          }
-          capture_time -= imu_watcher_.pico_offset_error();
-          model_based_.HandleImageMatch(
-              capture_time, target_estimate_fetchers_[camera_index].get(),
-              camera_index);
+        // TODO(james): Get timestamp from message contents.
+        aos::monotonic_clock::time_point capture_time(
+            target_estimate_fetchers_[camera_index]
+                .context()
+                .monotonic_remote_time -
+            monotonic_offset.value());
+        if (capture_time > target_estimate_fetchers_[camera_index]
+                               .context()
+                               .monotonic_event_time) {
+          model_based_.TallyRejection(RejectionReason::IMAGE_FROM_FUTURE);
+          continue;
         }
+        capture_time -= imu_watcher_.pico_offset_error();
+        model_based_.HandleImageMatch(
+            capture_time, target_estimate_fetchers_[camera_index].get(),
+            camera_index);
+      }
     }
   });
   event_loop_->OnRun([this, estimate_timer]() {
@@ -959,7 +959,6 @@
     aos::monotonic_clock::time_point sample_time_pi,
     std::optional<Eigen::Vector2d> encoders, Eigen::Vector3d gyro,
     Eigen::Vector3d accel) {
-
   model_based_.HandleImu(
       sample_time_pico, gyro, accel, encoders,
       utils_.VoltageOrZero(event_loop_->context().monotonic_event_time));
diff --git a/y2022/localizer/localizer.h b/y2022/localizer/localizer.h
index 59ad75c..fb56436 100644
--- a/y2022/localizer/localizer.h
+++ b/y2022/localizer/localizer.h
@@ -3,6 +3,7 @@
 
 #include "Eigen/Dense"
 #include "Eigen/Geometry"
+
 #include "aos/containers/ring_buffer.h"
 #include "aos/containers/sized_array.h"
 #include "aos/events/event_loop.h"
diff --git a/y2022/localizer/localizer_main.cc b/y2022/localizer/localizer_main.cc
index fab1d51..29c2f1e 100644
--- a/y2022/localizer/localizer_main.cc
+++ b/y2022/localizer/localizer_main.cc
@@ -1,7 +1,7 @@
 #include "aos/events/shm_event_loop.h"
 #include "aos/init.h"
-#include "y2022/localizer/localizer.h"
 #include "y2022/control_loops/drivetrain/drivetrain_base.h"
+#include "y2022/localizer/localizer.h"
 
 DEFINE_string(config, "aos_config.json", "Path to the config file to use.");
 
diff --git a/y2022/localizer/localizer_replay.cc b/y2022/localizer/localizer_replay.cc
index 6dcbb1e..e706421 100644
--- a/y2022/localizer/localizer_replay.cc
+++ b/y2022/localizer/localizer_replay.cc
@@ -1,15 +1,16 @@
+#include "gflags/gflags.h"
+
 #include "aos/configuration.h"
 #include "aos/events/logging/log_reader.h"
 #include "aos/events/logging/log_writer.h"
-#include "aos/util/simulation_logger.h"
 #include "aos/events/simulated_event_loop.h"
 #include "aos/init.h"
 #include "aos/json_to_flatbuffer.h"
 #include "aos/network/team_number.h"
+#include "aos/util/simulation_logger.h"
+#include "y2022/control_loops/drivetrain/drivetrain_base.h"
 #include "y2022/localizer/localizer.h"
 #include "y2022/localizer/localizer_schema.h"
-#include "gflags/gflags.h"
-#include "y2022/control_loops/drivetrain/drivetrain_base.h"
 
 DEFINE_string(config, "y2022/aos_config.json",
               "Name of the config file to replay using.");
@@ -39,10 +40,8 @@
   // open logfiles
   aos::logger::LogReader reader(logfiles, &config.message());
 
-  reader.RemapLoggedChannel("/localizer",
-                            "frc971.controls.LocalizerStatus");
-  reader.RemapLoggedChannel("/localizer",
-                            "frc971.controls.LocalizerOutput");
+  reader.RemapLoggedChannel("/localizer", "frc971.controls.LocalizerStatus");
+  reader.RemapLoggedChannel("/localizer", "frc971.controls.LocalizerOutput");
   reader.RemapLoggedChannel("/localizer",
                             "frc971.controls.LocalizerVisualization");
 
diff --git a/y2022/localizer/localizer_test.cc b/y2022/localizer/localizer_test.cc
index ef14972..6083143 100644
--- a/y2022/localizer/localizer_test.cc
+++ b/y2022/localizer/localizer_test.cc
@@ -1,10 +1,11 @@
 #include "y2022/localizer/localizer.h"
 
+#include "gtest/gtest.h"
+
 #include "aos/events/logging/log_writer.h"
 #include "aos/events/simulated_event_loop.h"
 #include "frc971/control_loops/drivetrain/drivetrain_test_lib.h"
 #include "frc971/control_loops/pose.h"
-#include "gtest/gtest.h"
 #include "y2022/control_loops/drivetrain/drivetrain_base.h"
 #include "y2022/control_loops/superstructure/superstructure_status_generated.h"
 #include "y2022/vision/target_estimate_generated.h"