8 #include <Eigen/Geometry>
16 const std::string& name) :
17 debugObserver(debugObserver), name(name)
37 std::lock_guard g{mtx};
41 void FrequencyReporter::report()
44 std::vector<int64_t> ts;
47 std::lock_guard g{mtx};
50 if (timestamps.size() < 2)
53 debugObserver->setDebugChannel(name,
68 std::adjacent_difference(ts.begin(), ts.end(), ts.begin());
73 const Vector v = Eigen::Map<Vector>(ts.data() + 1, ts.size() - 1);
74 const Eigen::ArrayXf dts =
v.cast<
float>();
76 const float dtMean = dts.mean();
77 const float dtMin = dts.minCoeff();
78 const float dtMax = dts.maxCoeff();
79 const float dtStddev =
std::sqrt((dts - dtMean).square().sum() / (dts.size() - 1));
81 const float frequencyMean = 1.0F / (dtMean / 1
'000'000);
82 const float frequencyMax = 1.0F / (dtMin / 1
'000'000);
83 const float frequencyMin = 1.0F / (dtMax / 1
'000'000);
84 const float frequencyStddev = 1.0F / (dtStddev / 1
'000'000);
86 debugObserver->setDebugChannel(