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/y2024/control_loops/drivetrain/drivetrain_replay.cc b/y2024/control_loops/drivetrain/drivetrain_replay.cc
index d43b2af..73c2f87 100644
--- a/y2024/control_loops/drivetrain/drivetrain_replay.cc
+++ b/y2024/control_loops/drivetrain/drivetrain_replay.cc
@@ -1,4 +1,4 @@
-#include "gflags/gflags.h"
+#include "absl/flags/flag.h"
#include "aos/configuration.h"
#include "aos/events/logging/log_reader.h"
@@ -17,31 +17,32 @@
#include "y2024/constants/simulated_constants_sender.h"
#include "y2024/control_loops/drivetrain/drivetrain_base.h"
-DEFINE_string(config, "y2024/aos_config.json",
- "Name of the config file to replay using.");
-DEFINE_bool(override_config, false,
- "If set, override the logged config with --config.");
-DEFINE_int32(team, 971, "Team number to use for logfile replay.");
-DEFINE_string(output_folder, "/tmp/replayed",
- "Name of the folder to write replayed logs to.");
-DEFINE_string(constants_path, "y2024/constants/constants.json",
- "Path to the constant file");
+ABSL_FLAG(std::string, config, "y2024/aos_config.json",
+ "Name of the config file to replay using.");
+ABSL_FLAG(bool, override_config, false,
+ "If set, override the logged config with --config.");
+ABSL_FLAG(int32_t, team, 971, "Team number to use for logfile replay.");
+ABSL_FLAG(std::string, output_folder, "/tmp/replayed",
+ "Name of the folder to write replayed logs to.");
+ABSL_FLAG(std::string, constants_path, "y2024/constants/constants.json",
+ "Path to the constant file");
int main(int argc, char **argv) {
aos::InitGoogle(&argc, &argv);
- aos::network::OverrideTeamNumber(FLAGS_team);
+ aos::network::OverrideTeamNumber(absl::GetFlag(FLAGS_team));
const aos::FlatbufferDetachedBuffer<aos::Configuration> config =
- aos::configuration::ReadConfig(FLAGS_config);
+ aos::configuration::ReadConfig(absl::GetFlag(FLAGS_config));
// sort logfiles
const std::vector<aos::logger::LogFile> logfiles =
aos::logger::SortParts(aos::logger::FindLogs(argc, argv));
// open logfiles
- aos::logger::LogReader reader(
- logfiles, FLAGS_override_config ? &config.message() : nullptr);
+ aos::logger::LogReader reader(logfiles, absl::GetFlag(FLAGS_override_config)
+ ? &config.message()
+ : nullptr);
reader.RemapLoggedChannel("/imu/constants", "y2024.Constants");
reader.RemapLoggedChannel("/roborio/constants", "y2024.Constants");
@@ -58,8 +59,9 @@
reader.RegisterWithoutStarting(factory.get());
- y2024::SendSimulationConstants(reader.event_loop_factory(), FLAGS_team,
- FLAGS_constants_path, {"roborio"});
+ y2024::SendSimulationConstants(
+ reader.event_loop_factory(), absl::GetFlag(FLAGS_team),
+ absl::GetFlag(FLAGS_constants_path), {"roborio"});
const aos::Node *node = nullptr;
if (aos::configuration::MultiNode(reader.configuration())) {
@@ -86,7 +88,7 @@
std::make_unique<frc971::control_loops::drivetrain::DrivetrainLoop>(
drivetrain_config, drivetrain_event_loop.get(), localizer.get());
loggers.push_back(std::make_unique<aos::util::LoggerState>(
- factory.get(), node, FLAGS_output_folder));
+ factory.get(), node, absl::GetFlag(FLAGS_output_folder)));
// The Trajectory information is NOT_LOGGED, so we need to rerun it against
// the SplineGoals that we have in the log.
node_factory
diff --git a/y2024/control_loops/drivetrain/trajectory_generator_main.cc b/y2024/control_loops/drivetrain/trajectory_generator_main.cc
index f53f79a..b01bea0 100644
--- a/y2024/control_loops/drivetrain/trajectory_generator_main.cc
+++ b/y2024/control_loops/drivetrain/trajectory_generator_main.cc
@@ -1,6 +1,8 @@
#include <sys/resource.h>
#include <sys/time.h>
+#include "absl/flags/flag.h"
+
#include "aos/events/shm_event_loop.h"
#include "aos/init.h"
#include "frc971/constants/constants_sender_lib.h"
@@ -10,8 +12,8 @@
using ::frc971::control_loops::drivetrain::TrajectoryGenerator;
-DEFINE_bool(skip_renicing, false,
- "If true, skip renicing the trajectory generator.");
+ABSL_FLAG(bool, skip_renicing, false,
+ "If true, skip renicing the trajectory generator.");
int main(int argc, char *argv[]) {
::aos::InitGoogle(&argc, &argv);
@@ -27,7 +29,7 @@
::y2024::control_loops::drivetrain::GetDrivetrainConfig(&event_loop));
event_loop.OnRun([]() {
- if (FLAGS_skip_renicing) {
+ if (absl::GetFlag(FLAGS_skip_renicing)) {
LOG(WARNING) << "Ignoring request to renice to -20 due to "
"--skip_renicing.";
} else {
diff --git a/y2024/control_loops/superstructure/BUILD b/y2024/control_loops/superstructure/BUILD
index 6c1075a..f175d19 100644
--- a/y2024/control_loops/superstructure/BUILD
+++ b/y2024/control_loops/superstructure/BUILD
@@ -136,8 +136,9 @@
"//frc971/control_loops:control_loops_fbs",
"//frc971/control_loops:profiled_subsystem_fbs",
"//frc971/control_loops:static_zeroing_single_dof_profiled_subsystem",
- "@com_github_google_glog//:glog",
"@com_google_absl//absl/functional:bind_front",
+ "@com_google_absl//absl/log",
+ "@com_google_absl//absl/log:check",
],
)
diff --git a/y2024/control_loops/superstructure/collision_avoidance.cc b/y2024/control_loops/superstructure/collision_avoidance.cc
index bd82fe0..a4f3a35 100644
--- a/y2024/control_loops/superstructure/collision_avoidance.cc
+++ b/y2024/control_loops/superstructure/collision_avoidance.cc
@@ -3,7 +3,8 @@
#include <cmath>
#include "absl/functional/bind_front.h"
-#include "glog/logging.h"
+#include "absl/log/check.h"
+#include "absl/log/log.h"
namespace y2024::control_loops::superstructure {
diff --git a/y2024/control_loops/superstructure/superstructure.cc b/y2024/control_loops/superstructure/superstructure.cc
index 7f7da4f..a33fc87 100644
--- a/y2024/control_loops/superstructure/superstructure.cc
+++ b/y2024/control_loops/superstructure/superstructure.cc
@@ -9,8 +9,8 @@
#include "frc971/shooter_interpolation/interpolation.h"
#include "frc971/zeroing/wrap.h"
-DEFINE_bool(ignore_distance, false,
- "If true, ignore distance when shooting and obey joystick_reader");
+ABSL_FLAG(bool, ignore_distance, false,
+ "If true, ignore distance when shooting and obey joystick_reader");
// The threshold used when decided if the extend is close enough to a goal to
// continue.
diff --git a/y2024/control_loops/superstructure/superstructure_lib_test.cc b/y2024/control_loops/superstructure/superstructure_lib_test.cc
index 719a29b..cf518e7 100644
--- a/y2024/control_loops/superstructure/superstructure_lib_test.cc
+++ b/y2024/control_loops/superstructure/superstructure_lib_test.cc
@@ -1,6 +1,7 @@
#include <chrono>
#include <memory>
+#include "absl/flags/flag.h"
#include "gtest/gtest.h"
#include "aos/events/logging/log_writer.h"
@@ -20,8 +21,8 @@
#include "y2024/control_loops/superstructure/superstructure.h"
#include "y2024/control_loops/superstructure/turret/turret_plant.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 y2024::control_loops::superstructure::testing {
@@ -336,11 +337,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/y2024/control_loops/superstructure/superstructure_main.cc b/y2024/control_loops/superstructure/superstructure_main.cc
index a5ab8ed..90c5eb4 100644
--- a/y2024/control_loops/superstructure/superstructure_main.cc
+++ b/y2024/control_loops/superstructure/superstructure_main.cc
@@ -2,8 +2,8 @@
#include "aos/init.h"
#include "y2024/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 y2024::control_loops::superstructure::Superstructure;
diff --git a/y2024/control_loops/superstructure/superstructure_replay.cc b/y2024/control_loops/superstructure/superstructure_replay.cc
index ab88a46..37ab08f 100644
--- a/y2024/control_loops/superstructure/superstructure_replay.cc
+++ b/y2024/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,14 +15,14 @@
#include "y2024/constants.h"
#include "y2024/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.");
+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.");
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(
@@ -40,11 +40,11 @@
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));
roborio->OnStartup([roborio]() {
roborio->AlwaysStart<y2024::control_loops::superstructure::Superstructure>(