Move over to ABSL logging and flags.

Removes gperftools too since that wants gflags.

Here come the fireworks.

Change-Id: I79cb7bcf60f1047fbfa28bfffc21a0fd692e4b1c
Signed-off-by: Austin Schuh <austin.linux@gmail.com>
diff --git a/y2023/control_loops/superstructure/arm/BUILD b/y2023/control_loops/superstructure/arm/BUILD
index a54f72c..c8ecaff 100644
--- a/y2023/control_loops/superstructure/arm/BUILD
+++ b/y2023/control_loops/superstructure/arm/BUILD
@@ -171,7 +171,7 @@
         "//frc971/control_loops:fixed_quadrature",
         "//frc971/control_loops/double_jointed_arm:ekf",
         "//y2023/control_loops/superstructure/roll:roll_plants",
-        "@com_github_gflags_gflags//:gflags",
+        "@com_google_absl//absl/flags:flag",
         "@org_tuxfamily_eigen//:eigen",
     ],
 )
diff --git a/y2023/control_loops/superstructure/arm/arm_design.cc b/y2023/control_loops/superstructure/arm/arm_design.cc
index 8c5664e..07439d6 100644
--- a/y2023/control_loops/superstructure/arm/arm_design.cc
+++ b/y2023/control_loops/superstructure/arm/arm_design.cc
@@ -1,3 +1,5 @@
+#include "absl/flags/flag.h"
+
 #include "aos/analysis/in_process_plotter.h"
 #include "aos/init.h"
 #include "frc971/control_loops/dlqr.h"
@@ -5,17 +7,17 @@
 #include "frc971/control_loops/jacobian.h"
 #include "y2023/control_loops/superstructure/arm/arm_constants.h"
 
-DEFINE_double(lqr_proximal_pos, 0.15, "Position LQR gain");
-DEFINE_double(lqr_proximal_vel, 4.0, "Velocity LQR gain");
-DEFINE_double(lqr_distal_pos, 0.20, "Position LQR gain");
-DEFINE_double(lqr_distal_vel, 4.0, "Velocity LQR gain");
-DEFINE_double(fx, 0.0, "X force");
-DEFINE_double(fy, 0.0, "y force");
+ABSL_FLAG(double, lqr_proximal_pos, 0.15, "Position LQR gain");
+ABSL_FLAG(double, lqr_proximal_vel, 4.0, "Velocity LQR gain");
+ABSL_FLAG(double, lqr_distal_pos, 0.20, "Position LQR gain");
+ABSL_FLAG(double, lqr_distal_vel, 4.0, "Velocity LQR gain");
+ABSL_FLAG(double, fx, 0.0, "X force");
+ABSL_FLAG(double, fy, 0.0, "y force");
 
-DEFINE_double(start0, 0.0, "starting position on proximal");
-DEFINE_double(start1, 0.0, "starting position on distal");
-DEFINE_double(goal0, 0.0, "goal position on proximal");
-DEFINE_double(goal1, 0.0, "goal position on distal");
+ABSL_FLAG(double, start0, 0.0, "starting position on proximal");
+ABSL_FLAG(double, start1, 0.0, "starting position on distal");
+ABSL_FLAG(double, goal0, 0.0, "goal position on proximal");
+ABSL_FLAG(double, goal1, 0.0, "goal position on distal");
 
 namespace y2023::control_loops::superstructure::arm {
 
@@ -26,14 +28,14 @@
 
   ::Eigen::Matrix<double, 4, 1> X = ::Eigen::Matrix<double, 4, 1>::Zero();
   ::Eigen::Matrix<double, 4, 1> goal = ::Eigen::Matrix<double, 4, 1>::Zero();
-  goal(0, 0) = FLAGS_goal0;
+  goal(0, 0) = absl::GetFlag(FLAGS_goal0);
   goal(1, 0) = 0;
-  goal(2, 0) = FLAGS_goal1;
+  goal(2, 0) = absl::GetFlag(FLAGS_goal1);
   goal(3, 0) = 0;
 
-  X(0, 0) = FLAGS_start0;
+  X(0, 0) = absl::GetFlag(FLAGS_start0);
   X(1, 0) = 0;
-  X(2, 0) = FLAGS_start1;
+  X(2, 0) = absl::GetFlag(FLAGS_start1);
   X(3, 0) = 0;
   ::Eigen::Matrix<double, 2, 1> U = ::Eigen::Matrix<double, 2, 1>::Zero();
 
@@ -52,10 +54,10 @@
   std::vector<double> torque0;
   std::vector<double> torque1;
 
-  const double kProximalPosLQR = FLAGS_lqr_proximal_pos;
-  const double kProximalVelLQR = FLAGS_lqr_proximal_vel;
-  const double kDistalPosLQR = FLAGS_lqr_distal_pos;
-  const double kDistalVelLQR = FLAGS_lqr_distal_vel;
+  const double kProximalPosLQR = absl::GetFlag(FLAGS_lqr_proximal_pos);
+  const double kProximalVelLQR = absl::GetFlag(FLAGS_lqr_proximal_vel);
+  const double kDistalPosLQR = absl::GetFlag(FLAGS_lqr_distal_pos);
+  const double kDistalVelLQR = absl::GetFlag(FLAGS_lqr_distal_vel);
   const ::Eigen::DiagonalMatrix<double, 4> Q =
       (::Eigen::DiagonalMatrix<double, 4>().diagonal()
            << 1.0 / ::std::pow(kProximalPosLQR, 2),
@@ -74,8 +76,9 @@
   {
     const ::Eigen::Matrix<double, 2, 1> torque =
         dynamics
-            .TorqueFromForce(X,
-                             ::Eigen::Matrix<double, 2, 1>(FLAGS_fx, FLAGS_fy))
+            .TorqueFromForce(
+                X, ::Eigen::Matrix<double, 2, 1>(absl::GetFlag(FLAGS_fx),
+                                                 absl::GetFlag(FLAGS_fy)))
             .transpose();
     LOG(INFO) << "Torque (N m): " << torque.transpose();
     const ::Eigen::Matrix<double, 2, 1> current =
diff --git a/y2023/control_loops/superstructure/arm/arm_trajectory_gen.cc b/y2023/control_loops/superstructure/arm/arm_trajectory_gen.cc
index 699cfcf..7116f92 100644
--- a/y2023/control_loops/superstructure/arm/arm_trajectory_gen.cc
+++ b/y2023/control_loops/superstructure/arm/arm_trajectory_gen.cc
@@ -1,8 +1,9 @@
 #include <iostream>
 #include <memory>
 
-#include "gflags/gflags.h"
-#include "glog/logging.h"
+#include "absl/flags/flag.h"
+#include "absl/log/check.h"
+#include "absl/log/log.h"
 
 #include "aos/events/shm_event_loop.h"
 #include "aos/flatbuffers.h"
@@ -24,7 +25,7 @@
 using y2023::control_loops::superstructure::arm::Path;
 using y2023::control_loops::superstructure::arm::Trajectory;
 
-DEFINE_string(output, "", "Defines the location of the output file");
+ABSL_FLAG(std::string, output, "", "Defines the location of the output file");
 
 int main(int argc, char **argv) {
   aos::InitGoogle(&argc, &argv);
@@ -193,5 +194,5 @@
       fbb.Release());
 
   // This writes to a binary file so we can cache the optimization results
-  aos::WriteFlatbufferToFile(FLAGS_output, detatched_buffer);
+  aos::WriteFlatbufferToFile(absl::GetFlag(FLAGS_output), detatched_buffer);
 }
diff --git a/y2023/control_loops/superstructure/arm/trajectory.cc b/y2023/control_loops/superstructure/arm/trajectory.cc
index be339e4..f7ae5f9 100644
--- a/y2023/control_loops/superstructure/arm/trajectory.cc
+++ b/y2023/control_loops/superstructure/arm/trajectory.cc
@@ -1,7 +1,7 @@
 #include "y2023/control_loops/superstructure/arm/trajectory.h"
 
 #include "Eigen/Dense"
-#include "gflags/gflags.h"
+#include "absl/flags/flag.h"
 
 #include "aos/logging/logging.h"
 #include "frc971/control_loops/dlqr.h"
@@ -10,10 +10,10 @@
 #include "frc971/control_loops/runge_kutta.h"
 #include "y2023/control_loops/superstructure/arm/arm_trajectories_generated.h"
 
-DEFINE_double(lqr_proximal_pos, 0.5, "Position LQR gain");
-DEFINE_double(lqr_proximal_vel, 5, "Velocity LQR gain");
-DEFINE_double(lqr_distal_pos, 0.5, "Position LQR gain");
-DEFINE_double(lqr_distal_vel, 5, "Velocity LQR gain");
+ABSL_FLAG(double, lqr_proximal_pos, 0.5, "Position LQR gain");
+ABSL_FLAG(double, lqr_proximal_vel, 5, "Velocity LQR gain");
+ABSL_FLAG(double, lqr_distal_pos, 0.5, "Position LQR gain");
+ABSL_FLAG(double, lqr_distal_vel, 5, "Velocity LQR gain");
 
 namespace y2023::control_loops::superstructure::arm {
 
@@ -714,10 +714,10 @@
 ::Eigen::Matrix<double, 2, 6> TrajectoryFollower::ArmK_at_state(
     const Eigen::Ref<const ::Eigen::Matrix<double, 6, 1>> arm_X,
     const Eigen::Ref<const ::Eigen::Matrix<double, 2, 1>> arm_U) {
-  const double kProximalPos = FLAGS_lqr_proximal_pos;
-  const double kProximalVel = FLAGS_lqr_proximal_vel;
-  const double kDistalPos = FLAGS_lqr_distal_pos;
-  const double kDistalVel = FLAGS_lqr_distal_vel;
+  const double kProximalPos = absl::GetFlag(FLAGS_lqr_proximal_pos);
+  const double kProximalVel = absl::GetFlag(FLAGS_lqr_proximal_vel);
+  const double kDistalPos = absl::GetFlag(FLAGS_lqr_distal_pos);
+  const double kDistalVel = absl::GetFlag(FLAGS_lqr_distal_vel);
   const ::Eigen::DiagonalMatrix<double, 4> Q =
       (::Eigen::DiagonalMatrix<double, 4>().diagonal()
            << 1.0 / ::std::pow(kProximalPos, 2),
diff --git a/y2023/control_loops/superstructure/arm/trajectory_plot.cc b/y2023/control_loops/superstructure/arm/trajectory_plot.cc
index 8488d72..d2b6b59 100644
--- a/y2023/control_loops/superstructure/arm/trajectory_plot.cc
+++ b/y2023/control_loops/superstructure/arm/trajectory_plot.cc
@@ -1,4 +1,4 @@
-#include "gflags/gflags.h"
+#include "absl/flags/flag.h"
 
 #include "aos/analysis/in_process_plotter.h"
 #include "aos/init.h"
@@ -12,16 +12,16 @@
 #include "y2023/control_loops/superstructure/roll/integral_hybrid_roll_plant.h"
 #include "y2023/control_loops/superstructure/roll/integral_roll_plant.h"
 
-DEFINE_bool(forwards, true, "If true, run the forwards simulation.");
-DEFINE_bool(plot, true, "If true, plot");
-DEFINE_bool(plot_thetas, true, "If true, plot the angles");
+ABSL_FLAG(bool, forwards, true, "If true, run the forwards simulation.");
+ABSL_FLAG(bool, plot, true, "If true, plot");
+ABSL_FLAG(bool, plot_thetas, true, "If true, plot the angles");
 
-DEFINE_double(alpha0_max, 15.0, "Max acceleration on joint 0.");
-DEFINE_double(alpha1_max, 10.0, "Max acceleration on joint 1.");
-DEFINE_double(alpha2_max, 90.0, "Max acceleration on joint 2.");
-DEFINE_double(vmax_plan, 9.5, "Max voltage to plan.");
-DEFINE_double(vmax_battery, 12.0, "Max battery voltage.");
-DEFINE_double(time, 2.0, "Simulation time.");
+ABSL_FLAG(double, alpha0_max, 15.0, "Max acceleration on joint 0.");
+ABSL_FLAG(double, alpha1_max, 10.0, "Max acceleration on joint 1.");
+ABSL_FLAG(double, alpha2_max, 90.0, "Max acceleration on joint 2.");
+ABSL_FLAG(double, vmax_plan, 9.5, "Max voltage to plan.");
+ABSL_FLAG(double, vmax_battery, 12.0, "Max battery voltage.");
+ABSL_FLAG(double, time, 2.0, "Simulation time.");
 
 namespace y2023::control_loops::superstructure::arm {
 using frc971::control_loops::MatrixGaussianQuadrature5;
@@ -55,16 +55,17 @@
 
   constexpr double sim_dt = 0.00505;
 
-  LOG(INFO) << "Planning with kAlpha0Max=" << FLAGS_alpha0_max
-            << ", kAlpha1Max=" << FLAGS_alpha1_max
-            << ", kAlpha2Max=" << FLAGS_alpha2_max;
+  LOG(INFO) << "Planning with kAlpha0Max=" << absl::GetFlag(FLAGS_alpha0_max)
+            << ", kAlpha1Max=" << absl::GetFlag(FLAGS_alpha1_max)
+            << ", kAlpha2Max=" << absl::GetFlag(FLAGS_alpha2_max);
 
   const ::Eigen::DiagonalMatrix<double, 3> alpha_unitizer(
       (::Eigen::DiagonalMatrix<double, 3>().diagonal()
-           << (1.0 / FLAGS_alpha0_max),
-       (1.0 / FLAGS_alpha1_max), (1.0 / FLAGS_alpha2_max))
+           << (1.0 / absl::GetFlag(FLAGS_alpha0_max)),
+       (1.0 / absl::GetFlag(FLAGS_alpha1_max)),
+       (1.0 / absl::GetFlag(FLAGS_alpha2_max)))
           .finished());
-  trajectory.OptimizeTrajectory(alpha_unitizer, FLAGS_vmax_plan);
+  trajectory.OptimizeTrajectory(alpha_unitizer, absl::GetFlag(FLAGS_vmax_plan));
 
   const ::std::vector<double> distance_array = trajectory.DistanceArray();
 
@@ -301,7 +302,7 @@
   ::std::cout << "Really stabilized P: " << arm_ekf.P_converged()
               << ::std::endl;
 
-  while (t < FLAGS_time) {
+  while (t < absl::GetFlag(FLAGS_time)) {
     t_array.push_back(t);
     arm_ekf.Correct(
         (::Eigen::Matrix<double, 2, 1>() << arm_X(0), arm_X(2)).finished(),
@@ -314,7 +315,8 @@
     follower.Update(
         (Eigen::Matrix<double, 9, 1>() << arm_ekf.X_hat(), roll.X_hat())
             .finished(),
-        disabled, sim_dt, FLAGS_vmax_plan, FLAGS_vmax_battery);
+        disabled, sim_dt, absl::GetFlag(FLAGS_vmax_plan),
+        absl::GetFlag(FLAGS_vmax_battery));
 
     const ::Eigen::Matrix<double, 3, 1> theta_t =
         trajectory.ThetaT(follower.goal()(0));
@@ -395,7 +397,7 @@
     t += sim_dt;
   }
 
-  if (FLAGS_plot) {
+  if (absl::GetFlag(FLAGS_plot)) {
     aos::analysis::Plotter plotter;
 
     plotter.AddFigure();
@@ -488,7 +490,7 @@
     plotter.AddLine(t_array, torque2_hat_t_array, "torque2_hat");
     plotter.Publish();
 
-    if (FLAGS_plot_thetas) {
+    if (absl::GetFlag(FLAGS_plot_thetas)) {
       plotter.AddFigure();
       plotter.Title("Angles");
       plotter.AddLine(t_array, theta0_goal_t_array, "theta0_t_goal");
diff --git a/y2023/control_loops/superstructure/superstructure.cc b/y2023/control_loops/superstructure/superstructure.cc
index bfb7a9d..60881f2 100644
--- a/y2023/control_loops/superstructure/superstructure.cc
+++ b/y2023/control_loops/superstructure/superstructure.cc
@@ -7,8 +7,8 @@
 #include "frc971/zeroing/wrap.h"
 #include "y2023/control_loops/superstructure/arm/arm_trajectories_generated.h"
 
-DEFINE_bool(ignore_distance, false,
-            "If true, ignore distance when shooting and obay joystick_reader");
+ABSL_FLAG(bool, ignore_distance, false,
+          "If true, ignore distance when shooting and obay joystick_reader");
 
 namespace y2023::control_loops::superstructure {
 
diff --git a/y2023/control_loops/superstructure/superstructure_lib_test.cc b/y2023/control_loops/superstructure/superstructure_lib_test.cc
index 5973eee..cc6e3ae 100644
--- a/y2023/control_loops/superstructure/superstructure_lib_test.cc
+++ b/y2023/control_loops/superstructure/superstructure_lib_test.cc
@@ -15,8 +15,8 @@
 #include "y2023/control_loops/superstructure/roll/integral_roll_plant.h"
 #include "y2023/control_loops/superstructure/superstructure.h"
 
-DEFINE_string(output_folder, "",
-              "If set, logs all channels to the provided logfile.");
+ABSL_FLAG(std::string, output_folder, "",
+          "If set, logs all channels to the provided logfile.");
 
 namespace y2023::control_loops::superstructure::testing {
 namespace {
@@ -320,11 +320,11 @@
 
     SetEnabled(true);
 
-    if (!FLAGS_output_folder.empty()) {
-      unlink(FLAGS_output_folder.c_str());
+    if (!absl::GetFlag(FLAGS_output_folder).empty()) {
+      unlink(absl::GetFlag(FLAGS_output_folder).c_str());
       logger_event_loop_ = MakeEventLoop("logger", roborio_);
       logger_ = std::make_unique<aos::logger::Logger>(logger_event_loop_.get());
-      logger_->StartLoggingOnRun(FLAGS_output_folder);
+      logger_->StartLoggingOnRun(absl::GetFlag(FLAGS_output_folder));
     }
   }
 
diff --git a/y2023/control_loops/superstructure/superstructure_main.cc b/y2023/control_loops/superstructure/superstructure_main.cc
index 4a044b6..bc20e44 100644
--- a/y2023/control_loops/superstructure/superstructure_main.cc
+++ b/y2023/control_loops/superstructure/superstructure_main.cc
@@ -1,9 +1,11 @@
+#include "absl/flags/flag.h"
+
 #include "aos/events/shm_event_loop.h"
 #include "aos/init.h"
 #include "y2023/control_loops/superstructure/superstructure.h"
 
-DEFINE_string(arm_trajectories, "arm_trajectories_generated.bfbs",
-              "The path to the generated arm trajectories bfbs file.");
+ABSL_FLAG(std::string, arm_trajectories, "arm_trajectories_generated.bfbs",
+          "The path to the generated arm trajectories bfbs file.");
 
 using y2023::control_loops::superstructure::Superstructure;
 using y2023::control_loops::superstructure::arm::ArmTrajectories;
@@ -20,7 +22,7 @@
 
   auto trajectories =
       y2023::control_loops::superstructure::Superstructure::GetArmTrajectories(
-          FLAGS_arm_trajectories);
+          absl::GetFlag(FLAGS_arm_trajectories));
 
   std::shared_ptr<const y2023::constants::Values> values =
       std::make_shared<const y2023::constants::Values>(
diff --git a/y2023/control_loops/superstructure/superstructure_replay.cc b/y2023/control_loops/superstructure/superstructure_replay.cc
index 6f23ec2..1f13aeb 100644
--- a/y2023/control_loops/superstructure/superstructure_replay.cc
+++ b/y2023/control_loops/superstructure/superstructure_replay.cc
@@ -3,7 +3,7 @@
 // replayed, so that it can then be run through the plotting tool or analyzed
 // in some other way. The original superstructure status data will be on the
 // /original/superstructure channel.
-#include "gflags/gflags.h"
+#include "absl/flags/flag.h"
 
 #include "aos/events/logging/log_reader.h"
 #include "aos/events/logging/log_writer.h"
@@ -15,16 +15,16 @@
 #include "y2023/constants.h"
 #include "y2023/control_loops/superstructure/superstructure.h"
 
-DEFINE_int32(team, 971, "Team number to use for logfile replay.");
-DEFINE_string(output_folder, "/tmp/superstructure_replay/",
-              "Logs all channels to the provided logfile.");
-DEFINE_string(arm_trajectories, "arm/arm_trajectories_generated.bfbs",
-              "The path to the generated arm trajectories bfbs file.");
+ABSL_FLAG(int32_t, team, 971, "Team number to use for logfile replay.");
+ABSL_FLAG(std::string, output_folder, "/tmp/superstructure_replay/",
+          "Logs all channels to the provided logfile.");
+ABSL_FLAG(std::string, arm_trajectories, "arm/arm_trajectories_generated.bfbs",
+          "The path to the generated arm trajectories bfbs file.");
 
 int main(int argc, char **argv) {
   aos::InitGoogle(&argc, &argv);
 
-  aos::network::OverrideTeamNumber(FLAGS_team);
+  aos::network::OverrideTeamNumber(absl::GetFlag(FLAGS_team));
 
   // open logfiles
   aos::logger::LogReader reader(
@@ -42,15 +42,15 @@
   aos::NodeEventLoopFactory *roborio =
       factory.GetNodeEventLoopFactory("roborio");
 
-  unlink(FLAGS_output_folder.c_str());
+  unlink(absl::GetFlag(FLAGS_output_folder).c_str());
   std::unique_ptr<aos::EventLoop> logger_event_loop =
       roborio->MakeEventLoop("logger");
   auto logger = std::make_unique<aos::logger::Logger>(logger_event_loop.get());
-  logger->StartLoggingOnRun(FLAGS_output_folder);
+  logger->StartLoggingOnRun(absl::GetFlag(FLAGS_output_folder));
 
   auto trajectories =
       y2023::control_loops::superstructure::Superstructure::GetArmTrajectories(
-          FLAGS_arm_trajectories);
+          absl::GetFlag(FLAGS_arm_trajectories));
 
   roborio->OnStartup([roborio, &trajectories]() {
     roborio->AlwaysStart<y2023::control_loops::superstructure::Superstructure>(