Start localizer_logger on y2024_swerve
Change-Id: I1b960d2b916cb4df6b6b7e8815cf0509d47767a5
Signed-off-by: James Kuszmaul <jabukuszmaul+collab@gmail.com>
diff --git a/y2024/BUILD b/y2024/BUILD
index 8082caf..9ec03d0 100644
--- a/y2024/BUILD
+++ b/y2024/BUILD
@@ -62,7 +62,7 @@
"//y2024/vision:viewer",
"//y2024/constants:constants_sender",
"//y2024/localizer:localizer_main",
- "//y2024/localizer:localizer_logger",
+ "//frc971/orin:localizer_logger",
"//frc971/vision:foxglove_image_converter",
],
data = [
diff --git a/y2024/localizer/BUILD b/y2024/localizer/BUILD
index d5a4348..828b5bb 100644
--- a/y2024/localizer/BUILD
+++ b/y2024/localizer/BUILD
@@ -154,22 +154,3 @@
"//y2024/control_loops/drivetrain:drivetrain_base",
],
)
-
-cc_binary(
- name = "localizer_logger",
- srcs = [
- "localizer_logger.cc",
- ],
- target_compatible_with = ["@platforms//os:linux"],
- visibility = ["//visibility:public"],
- deps = [
- "//aos:configuration",
- "//aos:init",
- "//aos/events:shm_event_loop",
- "//aos/events/logging:log_writer",
- "//aos/events/logging:snappy_encoder",
- "//aos/logging:log_namer",
- "@com_github_gflags_gflags//:gflags",
- "@com_github_google_glog//:glog",
- ],
-)
diff --git a/y2024/localizer/localizer_logger.cc b/y2024/localizer/localizer_logger.cc
deleted file mode 100644
index ec8d3ac..0000000
--- a/y2024/localizer/localizer_logger.cc
+++ /dev/null
@@ -1,80 +0,0 @@
-#include <sys/resource.h>
-#include <sys/time.h>
-
-#include "gflags/gflags.h"
-#include "glog/logging.h"
-
-#include "aos/configuration.h"
-#include "aos/events/logging/log_writer.h"
-#include "aos/events/logging/snappy_encoder.h"
-#include "aos/events/shm_event_loop.h"
-#include "aos/init.h"
-#include "aos/logging/log_namer.h"
-
-DEFINE_string(config, "aos_config.json", "Config file to use.");
-
-DEFINE_double(rotate_every, 30.0,
- "If set, rotate the logger after this many seconds");
-
-DECLARE_int32(flush_size);
-
-int main(int argc, char *argv[]) {
- gflags::SetUsageMessage(
- "This program provides a simple logger binary that logs all SHMEM data "
- "directly to a file specified at the command line. It does not manage "
- "filenames, so it will just crash if you attempt to overwrite an "
- "existing file, and the user must specify the logfile manually at the "
- "command line.");
- aos::InitGoogle(&argc, &argv);
-
- aos::FlatbufferDetachedBuffer<aos::Configuration> config =
- aos::configuration::ReadConfig(FLAGS_config);
-
- aos::ShmEventLoop event_loop(&config.message());
-
- auto log_namer = std::make_unique<aos::logger::MultiNodeFilesLogNamer>(
- &event_loop,
- std::make_unique<aos::logger::RenamableFileBackend>(
- absl::StrCat(aos::logging::GetLogName("localizer_log"), "/"),
- /*O_DIRECT*/ true));
-
- log_namer->set_extension(aos::logger::SnappyDecoder::kExtension);
- log_namer->set_encoder_factory([](size_t max_message_size) {
- return std::make_unique<aos::logger::SnappyEncoder>(max_message_size,
- FLAGS_flush_size);
- });
-
- aos::monotonic_clock::time_point last_rotation_time =
- event_loop.monotonic_now();
- aos::logger::Logger logger(
- &event_loop, event_loop.configuration(),
- // Only log channels smaller than ~10 MB / sec.
- [](const aos::Channel *channel) {
- return (channel->max_size() * channel->frequency()) < 10e6;
- });
-
- if (FLAGS_rotate_every != 0.0) {
- logger.set_on_logged_period(
- [&logger, &last_rotation_time](aos::monotonic_clock::time_point t) {
- if (t > last_rotation_time +
- std::chrono::duration<double>(FLAGS_rotate_every)) {
- logger.Rotate();
- last_rotation_time = t;
- }
- });
- }
-
- event_loop.OnRun([&log_namer, &logger]() {
- errno = 0;
- setpriority(PRIO_PROCESS, 0, -20);
- PCHECK(errno == 0)
- << ": Renicing to -20 failed, use --skip_renicing to skip renicing.";
- logger.StartLogging(std::move(log_namer));
- });
-
- event_loop.Run();
-
- LOG(INFO) << "Shutting down";
-
- return 0;
-}