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/y2022/localizer/imu_main.cc b/y2022/localizer/imu_main.cc
index 03dfc58..75af90f 100644
--- a/y2022/localizer/imu_main.cc
+++ b/y2022/localizer/imu_main.cc
@@ -1,16 +1,19 @@
+#include "absl/flags/flag.h"
+
#include "aos/events/shm_event_loop.h"
#include "aos/init.h"
#include "aos/realtime.h"
#include "frc971/imu_reader/imu.h"
#include "y2022/constants.h"
-DEFINE_string(config, "aos_config.json", "Path to the config file to use.");
+ABSL_FLAG(std::string, config, "aos_config.json",
+ "Path to the config file to use.");
int main(int argc, char *argv[]) {
aos::InitGoogle(&argc, &argv);
aos::FlatbufferDetachedBuffer<aos::Configuration> config =
- aos::configuration::ReadConfig(FLAGS_config);
+ aos::configuration::ReadConfig(absl::GetFlag(FLAGS_config));
PCHECK(system("sudo chmod 644 /dev/adis16505") == 0)
<< ": Failed to set read permissions on IMU device.";
diff --git a/y2022/localizer/localizer.cc b/y2022/localizer/localizer.cc
index c4ccf85..0e8a7e5 100644
--- a/y2022/localizer/localizer.cc
+++ b/y2022/localizer/localizer.cc
@@ -1,12 +1,14 @@
#include "y2022/localizer/localizer.h"
+#include "absl/flags/flag.h"
+
#include "aos/json_to_flatbuffer.h"
#include "frc971/control_loops/c2d.h"
#include "frc971/wpilib/imu_batch_generated.h"
#include "y2022/constants.h"
-DEFINE_bool(ignore_accelerometer, false,
- "If set, ignores the accelerometer readings.");
+ABSL_FLAG(bool, ignore_accelerometer, false,
+ "If set, ignores the accelerometer readings.");
namespace frc971::controls {
@@ -377,7 +379,7 @@
constexpr size_t kShareStates = kNModelStates;
static_assert(kUseModelThreshold < kUseAccelThreshold);
if (using_model_) {
- if (!FLAGS_ignore_accelerometer &&
+ if (!absl::GetFlag(FLAGS_ignore_accelerometer) &&
filtered_residual_ > kUseAccelThreshold) {
hysteresis_count_++;
} else {
diff --git a/y2022/localizer/localizer_main.cc b/y2022/localizer/localizer_main.cc
index 29c2f1e..19f4f8a 100644
--- a/y2022/localizer/localizer_main.cc
+++ b/y2022/localizer/localizer_main.cc
@@ -1,15 +1,18 @@
+#include "absl/flags/flag.h"
+
#include "aos/events/shm_event_loop.h"
#include "aos/init.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.");
+ABSL_FLAG(std::string, config, "aos_config.json",
+ "Path to the config file to use.");
int main(int argc, char *argv[]) {
aos::InitGoogle(&argc, &argv);
aos::FlatbufferDetachedBuffer<aos::Configuration> config =
- aos::configuration::ReadConfig(FLAGS_config);
+ aos::configuration::ReadConfig(absl::GetFlag(FLAGS_config));
aos::ShmEventLoop event_loop(&config.message());
frc971::controls::EventLoopLocalizer localizer(
diff --git a/y2022/localizer/localizer_replay.cc b/y2022/localizer/localizer_replay.cc
index a3baf3b..753d011 100644
--- a/y2022/localizer/localizer_replay.cc
+++ b/y2022/localizer/localizer_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"
@@ -12,11 +12,11 @@
#include "y2022/localizer/localizer.h"
#include "y2022/localizer/localizer_schema.h"
-DEFINE_string(config, "y2022/aos_config.json",
- "Name of the config file to replay using.");
-DEFINE_int32(team, 7971, "Team number to use for logfile replay.");
-DEFINE_string(output_folder, "/tmp/replayed",
- "Name of the folder to write replayed logs to.");
+ABSL_FLAG(std::string, config, "y2022/aos_config.json",
+ "Name of the config file to replay using.");
+ABSL_FLAG(int32_t, team, 7971, "Team number to use for logfile replay.");
+ABSL_FLAG(std::string, output_folder, "/tmp/replayed",
+ "Name of the folder to write replayed logs to.");
// TODO(james): Currently, this replay produces logfiles that can't be read due
// to time estimation issues. Pending the active refactorings of the
@@ -24,10 +24,10 @@
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 =
@@ -52,7 +52,7 @@
const std::vector<std::string> nodes_to_log = {"imu"};
std::vector<std::unique_ptr<aos::util::LoggerState>> loggers =
aos::util::MakeLoggersForNodes(reader.event_loop_factory(), nodes_to_log,
- FLAGS_output_folder);
+ absl::GetFlag(FLAGS_output_folder));
const aos::Node *node = nullptr;
if (aos::configuration::MultiNode(reader.configuration())) {
diff --git a/y2022/localizer/localizer_test.cc b/y2022/localizer/localizer_test.cc
index 0db26b6..bcee192 100644
--- a/y2022/localizer/localizer_test.cc
+++ b/y2022/localizer/localizer_test.cc
@@ -1,5 +1,6 @@
#include "y2022/localizer/localizer.h"
+#include "absl/flags/flag.h"
#include "gtest/gtest.h"
#include "aos/events/logging/log_writer.h"
@@ -10,8 +11,8 @@
#include "y2022/control_loops/superstructure/superstructure_status_generated.h"
#include "y2022/vision/target_estimate_generated.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 frc971::controls::testing {
typedef ModelBasedLocalizer::ModelState ModelState;
@@ -496,11 +497,11 @@
CHECK(status_fetcher_.Fetch());
CHECK(status_fetcher_->zeroed());
- if (!FLAGS_output_folder.empty()) {
+ if (!absl::GetFlag(FLAGS_output_folder).empty()) {
logger_event_loop_ =
event_loop_factory_.MakeEventLoop("logger", imu_node_);
logger_ = std::make_unique<aos::logger::Logger>(logger_event_loop_.get());
- logger_->StartLoggingOnRun(FLAGS_output_folder);
+ logger_->StartLoggingOnRun(absl::GetFlag(FLAGS_output_folder));
}
}