Add a LogReader-based timepoints channel to MCAP converter
This makes it so that I can visualize how different clock estimators are
doing relative to the estimator in the LogReader.
Change-Id: I4ebcc1052c6b043daecda82a08d0a3a29f85d58d
Signed-off-by: James Kuszmaul <james.kuszmaul@bluerivertech.com>
diff --git a/aos/util/clock_publisher.h b/aos/util/clock_publisher.h
new file mode 100644
index 0000000..a6d3488
--- /dev/null
+++ b/aos/util/clock_publisher.h
@@ -0,0 +1,26 @@
+#ifndef AOS_UTIL_CLOCK_PUBLISHER_H_
+#define AOS_UTIL_CLOCK_PUBLISHER_H_
+#include "aos/events/simulated_event_loop.h"
+#include "aos/util/clock_timepoints_generated.h"
+
+namespace aos {
+// A simple class that periodically queries a SimulatedEventLoopFactory for the
+// current timestamps on all nodes and publishes a ClockTimepoints message on
+// the provided EventLoop.
+// This is used by the log_to_mcap converter to allow Foxglove users access to
+// offset estimates. In order to use this, a /clocks channel with a type of
+// aos.ClockTimepoints must be available.
+class ClockPublisher {
+ public:
+ ClockPublisher(aos::SimulatedEventLoopFactory *factory,
+ aos::EventLoop *event_loop);
+
+ private:
+ void SendTimepoints();
+
+ aos::SimulatedEventLoopFactory *const factory_;
+ aos::Sender<ClockTimepoints> timepoints_sender_;
+};
+} // namespace aos
+
+#endif // AOS_UTIL_CLOCK_PUBLISHER_H_