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/frc971/control_loops/drivetrain/BUILD b/frc971/control_loops/drivetrain/BUILD
index 800af99..9aca44f 100644
--- a/frc971/control_loops/drivetrain/BUILD
+++ b/frc971/control_loops/drivetrain/BUILD
@@ -330,7 +330,7 @@
"//aos/testing:googletest",
"//aos/testing:test_shm",
"//third_party/matplotlib-cpp",
- "@com_github_gflags_gflags//:gflags",
+ "@com_google_absl//absl/flags:flag",
],
)
@@ -624,7 +624,7 @@
":spline",
"//aos/analysis:in_process_plotter",
"//aos/testing:googletest",
- "@com_github_gflags_gflags//:gflags",
+ "@com_google_absl//absl/flags:flag",
],
)
@@ -640,7 +640,8 @@
"//aos/logging",
"//frc971/control_loops:control_loops_fbs",
"//frc971/control_loops:fixed_quadrature",
- "@com_github_google_glog//:glog",
+ "@com_google_absl//absl/log",
+ "@com_google_absl//absl/log:check",
"@com_google_absl//absl/types:span",
"@org_tuxfamily_eigen//:eigen",
],
@@ -665,7 +666,7 @@
"//aos:flatbuffers",
"//aos/testing:googletest",
"//aos/testing:test_shm",
- "@com_github_gflags_gflags//:gflags",
+ "@com_google_absl//absl/flags:flag",
] + cpu_select({
"amd64": [
"//third_party/matplotlib-cpp",
@@ -721,7 +722,7 @@
"//aos/network:team_number",
"//third_party/matplotlib-cpp",
"//y2019/control_loops/drivetrain:drivetrain_base",
- "@com_github_gflags_gflags//:gflags",
+ "@com_google_absl//absl/flags:flag",
"@org_tuxfamily_eigen//:eigen",
],
)
@@ -774,7 +775,8 @@
"//frc971/control_loops:control_loops_fbs",
"//frc971/control_loops:quaternion_utils",
"//frc971/control_loops:runge_kutta",
- "@com_github_google_glog//:glog",
+ "@com_google_absl//absl/log",
+ "@com_google_absl//absl/log:check",
"@org_tuxfamily_eigen//:eigen",
],
)
diff --git a/frc971/control_loops/drivetrain/distance_spline.cc b/frc971/control_loops/drivetrain/distance_spline.cc
index 80ef4c4..015aca4 100644
--- a/frc971/control_loops/drivetrain/distance_spline.cc
+++ b/frc971/control_loops/drivetrain/distance_spline.cc
@@ -1,6 +1,7 @@
#include "frc971/control_loops/drivetrain/distance_spline.h"
-#include "glog/logging.h"
+#include "absl/log/check.h"
+#include "absl/log/log.h"
#include "aos/logging/logging.h"
#include "frc971/control_loops/drivetrain/spline.h"
diff --git a/frc971/control_loops/drivetrain/distance_spline_test.cc b/frc971/control_loops/drivetrain/distance_spline_test.cc
index 806d39e..b2e6ac6 100644
--- a/frc971/control_loops/drivetrain/distance_spline_test.cc
+++ b/frc971/control_loops/drivetrain/distance_spline_test.cc
@@ -2,7 +2,7 @@
#include <vector>
-#include "gflags/gflags.h"
+#include "absl/flags/flag.h"
#include "gtest/gtest.h"
#include "aos/flatbuffers.h"
@@ -11,7 +11,7 @@
#include "third_party/matplotlib-cpp/matplotlibcpp.h"
#endif
-DEFINE_bool(plot, false, "If true, plot");
+ABSL_FLAG(bool, plot, false, "If true, plot");
namespace frc971::control_loops::drivetrain::testing {
@@ -78,7 +78,7 @@
#if defined(SUPPORT_PLOT)
// Conditionally plot the functions and their integrals to aid debugging.
- if (FLAGS_plot) {
+ if (absl::GetFlag(FLAGS_plot)) {
matplotlibcpp::figure();
matplotlibcpp::plot(distances_plot, x_plot, {{"label", "x"}});
matplotlibcpp::plot(distances_plot, ix_plot, {{"label", "ix"}});
@@ -138,7 +138,7 @@
#if defined(SUPPORT_PLOT)
// Conditionally plot the functions and their integrals to aid debugging.
- if (FLAGS_plot) {
+ if (absl::GetFlag(FLAGS_plot)) {
matplotlibcpp::figure();
matplotlibcpp::plot(distances_plot, theta_plot, {{"label", "theta"}});
matplotlibcpp::plot(distances_plot, itheta_plot, {{"label", "itheta"}});
diff --git a/frc971/control_loops/drivetrain/drivetrain_lib_test.cc b/frc971/control_loops/drivetrain/drivetrain_lib_test.cc
index c1aa2a5..9cd669d 100644
--- a/frc971/control_loops/drivetrain/drivetrain_lib_test.cc
+++ b/frc971/control_loops/drivetrain/drivetrain_lib_test.cc
@@ -3,7 +3,7 @@
#include <chrono>
#include <memory>
-#include "gflags/gflags.h"
+#include "absl/flags/flag.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
@@ -24,8 +24,8 @@
#include "frc971/control_loops/polytope.h"
#include "frc971/queues/gyro_generated.h"
-DEFINE_string(output_file, "",
- "If set, logs all channels to the provided logfile.");
+ABSL_FLAG(std::string, output_file, "",
+ "If set, logs all channels to the provided logfile.");
namespace frc971::control_loops::drivetrain::testing {
@@ -65,11 +65,11 @@
set_send_delay(chrono::nanoseconds(0));
set_battery_voltage(12.0);
- if (!FLAGS_output_file.empty()) {
- unlink(FLAGS_output_file.c_str());
+ if (!absl::GetFlag(FLAGS_output_file).empty()) {
+ unlink(absl::GetFlag(FLAGS_output_file).c_str());
logger_event_loop_ = MakeEventLoop("logger");
logger_ = std::make_unique<aos::logger::Logger>(logger_event_loop_.get());
- logger_->StartLoggingOnRun(FLAGS_output_file);
+ logger_->StartLoggingOnRun(absl::GetFlag(FLAGS_output_file));
}
// Run for enough time to allow the gyro/imu zeroing code to run.
diff --git a/frc971/control_loops/drivetrain/drivetrain_test_lib.cc b/frc971/control_loops/drivetrain/drivetrain_test_lib.cc
index 394be07..fc32148 100644
--- a/frc971/control_loops/drivetrain/drivetrain_test_lib.cc
+++ b/frc971/control_loops/drivetrain/drivetrain_test_lib.cc
@@ -2,8 +2,9 @@
#include <chrono>
-#include "gflags/gflags.h"
-#include "glog/logging.h"
+#include "absl/flags/flag.h"
+#include "absl/log/check.h"
+#include "absl/log/log.h"
#include "gtest/gtest.h"
#include "frc971/control_loops/drivetrain/trajectory.h"
@@ -18,7 +19,7 @@
#include "y2016/control_loops/drivetrain/kalman_drivetrain_motor_plant.h"
#include "y2016/control_loops/drivetrain/polydrivetrain_dog_motor_plant.h"
-DEFINE_bool(plot, false, "If true, plot");
+ABSL_FLAG(bool, plot, false, "If true, plot");
namespace frc971::control_loops::drivetrain::testing {
@@ -137,7 +138,7 @@
// Skip this the first time.
if (!first_) {
Simulate();
- if (FLAGS_plot) {
+ if (absl::GetFlag(FLAGS_plot)) {
EXPECT_TRUE(drivetrain_status_fetcher_.Fetch());
::Eigen::Matrix<double, 2, 1> actual_position = GetPosition();
@@ -368,7 +369,7 @@
void DrivetrainSimulation::MaybePlot() {
#if defined(SUPPORT_PLOT)
- if (FLAGS_plot) {
+ if (absl::GetFlag(FLAGS_plot)) {
std::cout << "Plotting." << ::std::endl;
matplotlibcpp::figure();
matplotlibcpp::plot(actual_x_, actual_y_, {{"label", "actual position"}});
diff --git a/frc971/control_loops/drivetrain/improved_down_estimator.h b/frc971/control_loops/drivetrain/improved_down_estimator.h
index c778ad5..a73d575 100644
--- a/frc971/control_loops/drivetrain/improved_down_estimator.h
+++ b/frc971/control_loops/drivetrain/improved_down_estimator.h
@@ -3,7 +3,8 @@
#include "Eigen/Dense"
#include "Eigen/Geometry"
-#include "glog/logging.h"
+#include "absl/log/check.h"
+#include "absl/log/log.h"
#include "aos/events/event_loop.h"
#include "aos/time/time.h"
diff --git a/frc971/control_loops/drivetrain/improved_down_estimator_test.cc b/frc971/control_loops/drivetrain/improved_down_estimator_test.cc
index c128429..c6cda26 100644
--- a/frc971/control_loops/drivetrain/improved_down_estimator_test.cc
+++ b/frc971/control_loops/drivetrain/improved_down_estimator_test.cc
@@ -2,7 +2,8 @@
#include <random>
-#include "glog/logging.h"
+#include "absl/log/check.h"
+#include "absl/log/log.h"
#include "gtest/gtest.h"
#include <Eigen/Geometry>
diff --git a/frc971/control_loops/drivetrain/line_follow_drivetrain_test.cc b/frc971/control_loops/drivetrain/line_follow_drivetrain_test.cc
index ed018b9..4d88ab1 100644
--- a/frc971/control_loops/drivetrain/line_follow_drivetrain_test.cc
+++ b/frc971/control_loops/drivetrain/line_follow_drivetrain_test.cc
@@ -2,7 +2,7 @@
#include <chrono>
-#include "gflags/gflags.h"
+#include "absl/flags/flag.h"
#include "gtest/gtest.h"
#include "third_party/matplotlib-cpp/matplotlibcpp.h"
@@ -10,7 +10,7 @@
#include "frc971/control_loops/drivetrain/drivetrain_test_lib.h"
#include "frc971/control_loops/drivetrain/trajectory.h"
-DECLARE_bool(plot);
+ABSL_DECLARE_FLAG(bool, plot);
namespace chrono = ::std::chrono;
@@ -117,7 +117,7 @@
}
void TearDown() override {
- if (FLAGS_plot) {
+ if (absl::GetFlag(FLAGS_plot)) {
matplotlibcpp::figure();
matplotlibcpp::plot(time_, simulation_ul_, {{"label", "ul"}});
matplotlibcpp::plot(time_, simulation_ur_, {{"label", "ur"}});
diff --git a/frc971/control_loops/drivetrain/localization/puppet_localizer_test.cc b/frc971/control_loops/drivetrain/localization/puppet_localizer_test.cc
index a4338a8..d08f8eb 100644
--- a/frc971/control_loops/drivetrain/localization/puppet_localizer_test.cc
+++ b/frc971/control_loops/drivetrain/localization/puppet_localizer_test.cc
@@ -2,7 +2,7 @@
#include <queue>
-#include "gtest/gtest.h"
+#include "absl/flags/flag.h"
#include "aos/events/logging/log_writer.h"
#include "aos/network/message_bridge_server_generated.h"
@@ -15,8 +15,8 @@
#include "frc971/control_loops/team_number_test_environment.h"
#include "y2022/control_loops/drivetrain/drivetrain_base.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::control_loops::drivetrain::testing {
@@ -77,10 +77,10 @@
set_team_id(frc971::control_loops::testing::kTeamNumber);
set_battery_voltage(12.0);
- if (!FLAGS_output_folder.empty()) {
+ if (!absl::GetFlag(FLAGS_output_folder).empty()) {
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));
}
test_event_loop_->OnRun([this]() { SetStartingPosition({3.0, 2.0, 0.0}); });
diff --git a/frc971/control_loops/drivetrain/spline_test.cc b/frc971/control_loops/drivetrain/spline_test.cc
index b47f4ac..7209658 100644
--- a/frc971/control_loops/drivetrain/spline_test.cc
+++ b/frc971/control_loops/drivetrain/spline_test.cc
@@ -2,12 +2,12 @@
#include <vector>
-#include "gflags/gflags.h"
+#include "absl/flags/flag.h"
#include "gtest/gtest.h"
#include "aos/analysis/in_process_plotter.h"
-DEFINE_bool(plot, false, "If true, plot");
+ABSL_FLAG(bool, plot, false, "If true, plot");
namespace frc971::control_loops::drivetrain::testing {
@@ -21,13 +21,13 @@
class SplineTest : public ::testing::Test {
public:
static void SetUpTestSuite() {
- if (FLAGS_plot) {
+ if (absl::GetFlag(FLAGS_plot)) {
plotter_ = std::make_unique<aos::analysis::Plotter>();
}
}
static void TearDownTestSuite() {
- if (FLAGS_plot) {
+ if (absl::GetFlag(FLAGS_plot)) {
plotter_->Spin();
}
}
@@ -39,7 +39,7 @@
.finished()),
spline4_(control_points_),
spline6_(Spline4To6(control_points_)) {
- if (FLAGS_plot) {
+ if (absl::GetFlag(FLAGS_plot)) {
CHECK(plotter_);
plotter_->Title(TestName());
}
@@ -47,7 +47,7 @@
~SplineTest() {}
void TearDown() override {
- if (FLAGS_plot) {
+ if (absl::GetFlag(FLAGS_plot)) {
plotter_->Publish();
}
}
@@ -115,7 +115,7 @@
}
// Conditionally plot the functions and their integrals to aid debugging.
- if (FLAGS_plot) {
+ if (absl::GetFlag(FLAGS_plot)) {
plotter_->AddFigure("Spline Attributes Over Alpha");
plotter_->AddLine(alphas_plot, x_plot, "X");
plotter_->AddLine(alphas_plot, ix_plot, "Integrated X");
@@ -175,7 +175,7 @@
}
// Conditionally plot the functions and their integrals to aid debugging.
- if (FLAGS_plot) {
+ if (absl::GetFlag(FLAGS_plot)) {
plotter_->AddFigure("Heading Plot");
plotter_->AddLine(alphas_plot, theta_plot, "theta");
plotter_->AddLine(alphas_plot, itheta_plot, "Integrated theta");
@@ -226,7 +226,7 @@
}
// Conditionally plot the functions and their integrals to aid debugging.
- if (FLAGS_plot) {
+ if (absl::GetFlag(FLAGS_plot)) {
plotter_->AddFigure("Spline X/Y");
plotter_->AddLine(alphas_plot, x_plot, "X");
plotter_->AddLine(alphas_plot, y_plot, "Y");
diff --git a/frc971/control_loops/drivetrain/trajectory_plot.cc b/frc971/control_loops/drivetrain/trajectory_plot.cc
index 9eb95b5..8236e61 100644
--- a/frc971/control_loops/drivetrain/trajectory_plot.cc
+++ b/frc971/control_loops/drivetrain/trajectory_plot.cc
@@ -1,8 +1,9 @@
#include <chrono>
-#include "gflags/gflags.h"
+#include "absl/flags/flag.h"
#include "third_party/matplotlib-cpp/matplotlibcpp.h"
+#include "aos/init.h"
#include "aos/logging/implementations.h"
#include "aos/network/team_number.h"
#include "aos/time/time.h"
@@ -28,15 +29,15 @@
//
// https://photos.google.com/share/AF1QipPl34MOTPem2QmmTC3B21dL7GV2_HjxnseRrqxgR60TUasyIPliIuWmnH3yxuSNZw?key=cVhZLUYycXBIZlNTRy10cjZlWm0tcmlqQl9MTE13
-DEFINE_bool(plot, true, "If true, plot");
+ABSL_FLAG(bool, plot, true, "If true, plot");
-DEFINE_double(dx, 0.0, "Amount to disturb x at the start");
-DEFINE_double(dy, 0.0, "Amount to disturb y at the start");
-DEFINE_double(dt, 0.0, "Amount to disturb theta at the start");
-DEFINE_double(dvl, 0.0, "Amount to disturb vl at the start");
-DEFINE_double(dvr, 0.0, "Amount to disturb vr at the start");
+ABSL_FLAG(double, dx, 0.0, "Amount to disturb x at the start");
+ABSL_FLAG(double, dy, 0.0, "Amount to disturb y at the start");
+ABSL_FLAG(double, dt, 0.0, "Amount to disturb theta at the start");
+ABSL_FLAG(double, dvl, 0.0, "Amount to disturb vl at the start");
+ABSL_FLAG(double, dvr, 0.0, "Amount to disturb vr at the start");
-DEFINE_double(forward, 1.0, "Amount to drive forwards");
+ABSL_FLAG(double, forward, 1.0, "Amount to drive forwards");
namespace chrono = ::std::chrono;
@@ -45,12 +46,13 @@
void Main() {
const DrivetrainConfig<double> config =
::y2019::control_loops::drivetrain::GetDrivetrainConfig();
- Trajectory trajectory(
- DistanceSpline(Spline(Spline4To6(
- (::Eigen::Matrix<double, 2, 4>() << 0.0, 1.2 * FLAGS_forward,
- -0.2 * FLAGS_forward, FLAGS_forward, 0.0, 0.0, 1.0, 1.0)
- .finished()))),
- &config, nullptr);
+ Trajectory trajectory(DistanceSpline(Spline(Spline4To6(
+ (::Eigen::Matrix<double, 2, 4>() << 0.0,
+ 1.2 * absl::GetFlag(FLAGS_forward),
+ -0.2 * absl::GetFlag(FLAGS_forward),
+ absl::GetFlag(FLAGS_forward), 0.0, 0.0, 1.0, 1.0)
+ .finished()))),
+ &config, nullptr);
trajectory.set_lateral_acceleration(2.0);
trajectory.set_longitudinal_acceleration(1.0);
@@ -134,11 +136,11 @@
FinishedTrajectory finished_trajectory(&config, &trajectory_buffer.message());
::Eigen::Matrix<double, 5, 1> state = ::Eigen::Matrix<double, 5, 1>::Zero();
- state(0, 0) = FLAGS_dx;
- state(1, 0) = FLAGS_dy;
- state(2, 0) = FLAGS_dt;
- state(3, 0) = FLAGS_dvl;
- state(4, 0) = FLAGS_dvr;
+ state(0, 0) = absl::GetFlag(FLAGS_dx);
+ state(1, 0) = absl::GetFlag(FLAGS_dy);
+ state(2, 0) = absl::GetFlag(FLAGS_dt);
+ state(3, 0) = absl::GetFlag(FLAGS_dvl);
+ state(4, 0) = absl::GetFlag(FLAGS_dvr);
::std::vector<double> simulation_t = length_plan_t;
::std::vector<double> simulation_x;
::std::vector<double> error_x;
@@ -190,7 +192,7 @@
simulation_ur.push_back(U(1));
}
- if (FLAGS_plot) {
+ if (absl::GetFlag(FLAGS_plot)) {
matplotlibcpp::figure();
matplotlibcpp::plot(plan_segment_center_distance, plan_type,
{{"label", "plan_type"}});
@@ -230,7 +232,7 @@
} // namespace frc971::control_loops::drivetrain
int main(int argc, char **argv) {
- ::gflags::ParseCommandLineFlags(&argc, &argv, false);
+ aos::InitGoogle(&argc, &argv);
::aos::network::OverrideTeamNumber(971);
::frc971::control_loops::drivetrain::Main();
return 0;
diff --git a/frc971/control_loops/drivetrain/trajectory_test.cc b/frc971/control_loops/drivetrain/trajectory_test.cc
index 6e9089a..5ff8b5d 100644
--- a/frc971/control_loops/drivetrain/trajectory_test.cc
+++ b/frc971/control_loops/drivetrain/trajectory_test.cc
@@ -3,7 +3,8 @@
#include <chrono>
#include <vector>
-#include "gflags/gflags.h"
+#include "absl/flags/declare.h"
+#include "absl/flags/flag.h"
#include "gtest/gtest.h"
#include "aos/testing/test_shm.h"
@@ -18,10 +19,10 @@
#include "y2016/control_loops/drivetrain/polydrivetrain_dog_motor_plant.h"
#include "y2019/control_loops/drivetrain/drivetrain_base.h"
-DECLARE_bool(plot);
+ABSL_DECLARE_FLAG(bool, plot);
-DEFINE_string(output_file, "",
- "If set, logs all channels to the provided logfile.");
+ABSL_FLAG(std::string, output_file, "",
+ "If set, logs all channels to the provided logfile.");
namespace frc971::control_loops::drivetrain::testing {
@@ -119,7 +120,7 @@
length_plan_xva_.size() *
::aos::time::DurationInSeconds(dt_config_.dt));
#if defined(SUPPORT_PLOT)
- if (FLAGS_plot) {
+ if (absl::GetFlag(FLAGS_plot)) {
::std::vector<double> distances = trajectory_->Distances();
for (size_t i = 0; i < length_plan_xva_.size(); ++i) {