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/y2018/control_loops/python/2d_plot.cc b/y2018/control_loops/python/2d_plot.cc
index 1d2a686..c65bae6 100644
--- a/y2018/control_loops/python/2d_plot.cc
+++ b/y2018/control_loops/python/2d_plot.cc
@@ -2,17 +2,18 @@
#include <cmath>
#include <thread>
-#include "gflags/gflags.h"
+#include "absl/flags/flag.h"
+#include "absl/flags/parse.h"
#include "third_party/matplotlib-cpp/matplotlibcpp.h"
-DEFINE_double(yrange, 1.0, "+- y max");
+ABSL_FLAG(double, yrange, 1.0, "+- y max");
double fx(double x, double yrange) {
return 2.0 * ((1.0 / (1.0 + ::std::exp(-x * 2.0 / yrange)) - 0.5)) * yrange;
}
int main(int argc, char **argv) {
- gflags::ParseCommandLineFlags(&argc, &argv, false);
+ absl::ParseCommandLine(argc, argv);
matplotlibcpp::figure();
::std::vector<double> x;
@@ -21,10 +22,10 @@
for (double i = -5.0; i < 5.0; i += 0.01) {
x.push_back(i);
- y.push_back(fx(i, FLAGS_yrange));
- slope_y.push_back(
- (fx(i + 0.0001, FLAGS_yrange) - fx(i - 0.0001, FLAGS_yrange)) /
- (2.0 * 0.0001));
+ y.push_back(fx(i, absl::GetFlag(FLAGS_yrange)));
+ slope_y.push_back((fx(i + 0.0001, absl::GetFlag(FLAGS_yrange)) -
+ fx(i - 0.0001, absl::GetFlag(FLAGS_yrange))) /
+ (2.0 * 0.0001));
}
matplotlibcpp::plot(x, y, {{"label", "saturated x"}});
diff --git a/y2018/control_loops/python/BUILD b/y2018/control_loops/python/BUILD
index fcedf40..d286ce0 100644
--- a/y2018/control_loops/python/BUILD
+++ b/y2018/control_loops/python/BUILD
@@ -107,7 +107,8 @@
target_compatible_with = ["@platforms//cpu:x86_64"],
deps = [
"//third_party/matplotlib-cpp",
- "@com_github_gflags_gflags//:gflags",
+ "@com_google_absl//absl/flags:flag",
+ "@com_google_absl//absl/flags:parse",
],
)
diff --git a/y2018/control_loops/superstructure/arm/BUILD b/y2018/control_loops/superstructure/arm/BUILD
index 319e591..495e214 100644
--- a/y2018/control_loops/superstructure/arm/BUILD
+++ b/y2018/control_loops/superstructure/arm/BUILD
@@ -76,7 +76,7 @@
"//aos/analysis:in_process_plotter",
"//frc971/control_loops/double_jointed_arm:ekf",
"//frc971/control_loops/double_jointed_arm:trajectory",
- "@com_github_gflags_gflags//:gflags",
+ "@com_google_absl//absl/flags:flag",
"@org_tuxfamily_eigen//:eigen",
],
)
diff --git a/y2018/control_loops/superstructure/arm/trajectory_plot.cc b/y2018/control_loops/superstructure/arm/trajectory_plot.cc
index eeb0fbc..1811b95 100644
--- a/y2018/control_loops/superstructure/arm/trajectory_plot.cc
+++ b/y2018/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"
@@ -8,9 +8,9 @@
#include "y2018/control_loops/superstructure/arm/arm_constants.h"
#include "y2018/control_loops/superstructure/arm/generated_graph.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");
namespace y2018::control_loops::superstructure::arm {
@@ -18,8 +18,9 @@
frc971::control_loops::arm::Dynamics dynamics(kArmConstants);
frc971::control_loops::arm::Trajectory trajectory(
&dynamics,
- FLAGS_forwards ? MakeNeutralToFrontHighPath()
- : Path::Reversed(MakeNeutralToFrontHighPath()),
+ absl::GetFlag(FLAGS_forwards)
+ ? MakeNeutralToFrontHighPath()
+ : Path::Reversed(MakeNeutralToFrontHighPath()),
0.001);
constexpr double kAlpha0Max = 30.0;
@@ -254,7 +255,7 @@
t += sim_dt;
}
- if (FLAGS_plot) {
+ if (absl::GetFlag(FLAGS_plot)) {
aos::analysis::Plotter plotter;
plotter.AddFigure();
@@ -324,7 +325,7 @@
plotter.AddLine(t_array, torque1_hat_t_array, "torque1_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");