Add realtime replay support to SimulatedEventLoopFactory
"realtime" is heavily overloaded here, but this adds support
for making it so that you can play a SimulatedEventLoopFactory at
realtime speed (rather than just "as fast as possible"). This
can be useful in a variety of situations (e.g., debugging
tooling that will run in realtime on a robot).
Adds a demonstration of using this in an piece of AOS tooling for
plotting (this change also makes it so that that binary no longer spins
at 100% CPU indefinitely by consequence of better integrating
the EPoll object into the log replay).
Change-Id: Ia01ecd850a50c9b78dd72bfb0e8862672a716067
Signed-off-by: James Kuszmaul <james.kuszmaul@bluerivertech.com>
diff --git a/frc971/analysis/in_process_plotter.cc b/frc971/analysis/in_process_plotter.cc
index 545740d..33d999e 100644
--- a/frc971/analysis/in_process_plotter.cc
+++ b/frc971/analysis/in_process_plotter.cc
@@ -15,7 +15,8 @@
event_loop_factory_(&config_.message()),
event_loop_(event_loop_factory_.MakeEventLoop("plotter")),
plot_sender_(event_loop_->MakeSender<Plot>("/analysis")),
- web_proxy_(event_loop_.get(), aos::web_proxy::StoreHistory::kYes, -1),
+ web_proxy_(event_loop_.get(), event_loop_factory_.scheduler_epoll(),
+ aos::web_proxy::StoreHistory::kYes, -1),
builder_(plot_sender_.MakeBuilder()) {
web_proxy_.SetDataPath(kDataPath);
event_loop_->SkipTimingReport();
@@ -41,7 +42,11 @@
ColorWheelColor{.name = "white", .color = {1, 1, 1}});
}
-void Plotter::Spin() { event_loop_factory_.Run(); }
+void Plotter::Spin() {
+ // Set non-infinite replay rate to avoid pegging a full CPU.
+ event_loop_factory_.SetRealtimeReplayRate(1.0);
+ event_loop_factory_.Run();
+}
void Plotter::Title(std::string_view title) {
title_ = builder_.fbb()->CreateString(title);