blob: a6d3488fba4ae5351e2b5d4feb32a156e589835c [file] [log] [blame]
James Kuszmaul80d6c422023-01-06 14:16:04 -08001#ifndef AOS_UTIL_CLOCK_PUBLISHER_H_
2#define AOS_UTIL_CLOCK_PUBLISHER_H_
3#include "aos/events/simulated_event_loop.h"
4#include "aos/util/clock_timepoints_generated.h"
5
6namespace aos {
7// A simple class that periodically queries a SimulatedEventLoopFactory for the
8// current timestamps on all nodes and publishes a ClockTimepoints message on
9// the provided EventLoop.
10// This is used by the log_to_mcap converter to allow Foxglove users access to
11// offset estimates. In order to use this, a /clocks channel with a type of
12// aos.ClockTimepoints must be available.
13class ClockPublisher {
14 public:
15 ClockPublisher(aos::SimulatedEventLoopFactory *factory,
16 aos::EventLoop *event_loop);
17
18 private:
19 void SendTimepoints();
20
21 aos::SimulatedEventLoopFactory *const factory_;
22 aos::Sender<ClockTimepoints> timepoints_sender_;
23};
24} // namespace aos
25
26#endif // AOS_UTIL_CLOCK_PUBLISHER_H_