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/y2019/control_loops/drivetrain/drivetrain_replay.cc b/y2019/control_loops/drivetrain/drivetrain_replay.cc
index 26c87e8..d9d928c 100644
--- a/y2019/control_loops/drivetrain/drivetrain_replay.cc
+++ b/y2019/control_loops/drivetrain/drivetrain_replay.cc
@@ -1,14 +1,15 @@
#include <iostream>
+#include "gflags/gflags.h"
+
#include "aos/configuration.h"
-#include "aos/events/logging/log_writer.h"
#include "aos/events/logging/log_reader.h"
+#include "aos/events/logging/log_writer.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 "frc971/control_loops/drivetrain/drivetrain.h"
-#include "gflags/gflags.h"
#include "y2019/control_loops/drivetrain/drivetrain_base.h"
#include "y2019/control_loops/drivetrain/event_loop_localizer.h"
diff --git a/y2019/control_loops/drivetrain/event_loop_localizer.h b/y2019/control_loops/drivetrain/event_loop_localizer.h
index a78f3a2..0847479 100644
--- a/y2019/control_loops/drivetrain/event_loop_localizer.h
+++ b/y2019/control_loops/drivetrain/event_loop_localizer.h
@@ -66,9 +66,7 @@
Localizer::State Xhat() const override { return localizer_.X_hat(); }
- TargetSelector *target_selector() override {
- return &target_selector_;
- }
+ TargetSelector *target_selector() override { return &target_selector_; }
private:
void HandleFrame(const CameraFrame *frame);
diff --git a/y2019/control_loops/drivetrain/localized_drivetrain_test.cc b/y2019/control_loops/drivetrain/localized_drivetrain_test.cc
index 4d6f84a..016e3b7 100644
--- a/y2019/control_loops/drivetrain/localized_drivetrain_test.cc
+++ b/y2019/control_loops/drivetrain/localized_drivetrain_test.cc
@@ -1,11 +1,12 @@
#include <queue>
+#include "gtest/gtest.h"
+
#include "aos/network/team_number.h"
#include "frc971/control_loops/control_loop_test.h"
#include "frc971/control_loops/drivetrain/drivetrain.h"
#include "frc971/control_loops/drivetrain/drivetrain_test_lib.h"
#include "frc971/control_loops/team_number_test_environment.h"
-#include "gtest/gtest.h"
#include "y2019/control_loops/drivetrain/camera_generated.h"
#include "y2019/control_loops/drivetrain/drivetrain_base.h"
#include "y2019/control_loops/drivetrain/event_loop_localizer.h"
diff --git a/y2019/control_loops/drivetrain/localizer.h b/y2019/control_loops/drivetrain/localizer.h
index 818e1b9..2e7c3a5 100644
--- a/y2019/control_loops/drivetrain/localizer.h
+++ b/y2019/control_loops/drivetrain/localizer.h
@@ -95,15 +95,13 @@
dhdx;
make_h_queue_.CorrectKnownHBuilder(
z, nullptr,
- ExpectedObservationBuilder(this, camera, targets, &h_functions,
- &dhdx),
+ ExpectedObservationBuilder(this, camera, targets, &h_functions, &dhdx),
R, t);
// Fetch cache:
for (size_t ii = 1; ii < targets.size(); ++ii) {
TargetViewToMatrices(targets[ii], &z, &R);
h_queue_.CorrectKnownH(
- z, nullptr,
- ExpectedObservationFunctor(h_functions[ii], dhdx[ii]), R,
+ z, nullptr, ExpectedObservationFunctor(h_functions[ii], dhdx[ii]), R,
t);
}
}
@@ -189,8 +187,8 @@
const State &state, const StateSquare &P) {
HFunction h;
Eigen::Matrix<Scalar, kNOutputs, kNStates> dhdx;
- localizer_->MakeH(camera_, target_views_, h_functions_, dhdx_,
- state, P, &h, &dhdx);
+ localizer_->MakeH(camera_, target_views_, h_functions_, dhdx_, state, P,
+ &h, &dhdx);
functor_.emplace(h, dhdx);
return &functor_.value();
}
@@ -410,8 +408,7 @@
if (view_idx >= camera_views.size()) {
AOS_LOG(ERROR, "Somehow, the view scorer failed.\n");
h_functions->emplace_back();
- dhdx->push_back(
- Eigen::Matrix<Scalar, kNOutputs, kNStates>::Zero());
+ dhdx->push_back(Eigen::Matrix<Scalar, kNOutputs, kNStates>::Zero());
continue;
}
const Eigen::Matrix<Scalar, kNOutputs, kNStates> best_H =
diff --git a/y2019/control_loops/drivetrain/localizer_test.cc b/y2019/control_loops/drivetrain/localizer_test.cc
index 1c9485a..28f0235 100644
--- a/y2019/control_loops/drivetrain/localizer_test.cc
+++ b/y2019/control_loops/drivetrain/localizer_test.cc
@@ -3,15 +3,17 @@
#include <queue>
#include <random>
+#include "gflags/gflags.h"
+
#include "aos/testing/random_seed.h"
#include "aos/testing/test_shm.h"
#include "frc971/control_loops/drivetrain/splinedrivetrain.h"
#include "frc971/control_loops/drivetrain/trajectory.h"
-#include "gflags/gflags.h"
#if defined(SUPPORT_PLOT)
#include "third_party/matplotlib-cpp/matplotlibcpp.h"
#endif
#include "gtest/gtest.h"
+
#include "y2019/constants.h"
#include "y2019/control_loops/drivetrain/drivetrain_base.h"
@@ -490,9 +492,9 @@
const double left_enc = state(StateIdx::kLeftEncoder, 0);
const double right_enc = state(StateIdx::kRightEncoder, 0);
- const double gyro = (state(StateIdx::kRightVelocity) -
- state(StateIdx::kLeftVelocity)) /
- dt_config_.robot_radius / 2.0;
+ const double gyro =
+ (state(StateIdx::kRightVelocity) - state(StateIdx::kLeftVelocity)) /
+ dt_config_.robot_radius / 2.0;
const TestLocalizer::State xdot = DiffEq(state, U);
const Eigen::Vector3d accel(
localizer_.CalcLongitudinalVelocity(xdot) -
diff --git a/y2019/control_loops/drivetrain/replay_localizer.cc b/y2019/control_loops/drivetrain/replay_localizer.cc
index 3687e3d..b7d269b 100644
--- a/y2019/control_loops/drivetrain/replay_localizer.cc
+++ b/y2019/control_loops/drivetrain/replay_localizer.cc
@@ -1,5 +1,7 @@
#include <fcntl.h>
+#include "gflags/gflags.h"
+
#include "aos/init.h"
#include "aos/logging/implementations.h"
#include "aos/logging/replay.h"
@@ -8,7 +10,6 @@
#include "frc971/control_loops/drivetrain/drivetrain.q.h"
#include "frc971/control_loops/drivetrain/localizer.q.h"
#include "frc971/wpilib/imu.q.h"
-#include "gflags/gflags.h"
#include "y2019/constants.h"
#include "y2019/control_loops/drivetrain/drivetrain_base.h"
#include "y2019/control_loops/drivetrain/event_loop_localizer.h"
@@ -29,9 +30,10 @@
namespace drivetrain {
using ::y2019::constants::Field;
-typedef TypedLocalizer<
- constants::Values::kNumCameras, Field::kNumTargets, Field::kNumObstacles,
- EventLoopLocalizer::kMaxTargetsPerFrame, double> TestLocalizer;
+typedef TypedLocalizer<constants::Values::kNumCameras, Field::kNumTargets,
+ Field::kNumObstacles,
+ EventLoopLocalizer::kMaxTargetsPerFrame, double>
+ TestLocalizer;
typedef typename TestLocalizer::Camera TestCamera;
typedef typename TestCamera::Pose Pose;
typedef typename TestCamera::LineSegment Obstacle;
@@ -42,7 +44,7 @@
const ::std::map<::std::string, ::std::string> &kwargs) {
::std::vector<double> x;
::std::vector<double> y;
- for (const Pose & p : poses) {
+ for (const Pose &p : poses) {
x.push_back(p.abs_pos().x());
y.push_back(p.abs_pos().y());
}
@@ -336,8 +338,8 @@
// Whether the robot has been enabled yet.
bool has_been_enabled_ = false;
// Cache of last gyro value to forward to the localizer.
- double latest_gyro_ = 0.0; // rad/sec
- double battery_voltage_ = 12.0; // volts
+ double latest_gyro_ = 0.0; // rad/sec
+ double battery_voltage_ = 12.0; // volts
::Eigen::Matrix<double, 2, 1> last_U_{0, 0};
::Eigen::Matrix<double, 2, 1> last_last_U_{0, 0};
diff --git a/y2019/control_loops/drivetrain/target_selector_test.cc b/y2019/control_loops/drivetrain/target_selector_test.cc
index b60085c..d4ef6da 100644
--- a/y2019/control_loops/drivetrain/target_selector_test.cc
+++ b/y2019/control_loops/drivetrain/target_selector_test.cc
@@ -1,7 +1,8 @@
#include "y2019/control_loops/drivetrain/target_selector.h"
-#include "aos/events/simulated_event_loop.h"
#include "gtest/gtest.h"
+
+#include "aos/events/simulated_event_loop.h"
#include "y2019/control_loops/superstructure/superstructure_goal_generated.h"
namespace y2019 {
@@ -81,8 +82,7 @@
builder.MakeBuilder<superstructure::Goal>();
goal_builder.add_suction(suction_offset);
- ASSERT_EQ(builder.Send(goal_builder.Finish()),
- aos::RawSender::Error::kOk);
+ ASSERT_EQ(builder.Send(goal_builder.Finish()), aos::RawSender::Error::kOk);
}
{
auto builder = target_selector_hint_sender_.MakeBuilder();