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 {