28 #include <shared_mutex>
32 #include <Eigen/Geometry>
34 #include <SimoxUtility/math/pose/interpolate.h>
49 template <
typename MessageType>
54 TimeQueue(
const std::size_t maxQueueSize) : maxQueueSize(maxQueueSize)
59 queue(std::move(other.queue)), maxQueueSize(other.maxQueueSize)
71 std::unique_lock g{
mtx};
86 while (
queue.size() > maxQueueSize)
98 std::vector<int64_t> ts;
99 ts.reserve(
queue.size());
101 std::shared_lock g{
mtx};
104 std::back_inserter(ts),
105 [](
const MessageType& msg) { return msg.timestamp; });
115 std::shared_lock g{
mtx};
133 std::shared_lock g{
mtx};
143 std::unique_lock g{
mtx};
145 while (not
queue.empty())
160 std::lock_guard g{
mtx};
167 std::lock_guard g{
mtx};
181 auto timestampBeyond = [
timestamp](
const MessageType& poseStamped)
182 {
return poseStamped.timestamp >=
timestamp; };
184 const auto poseNextIt = std::find_if(
queue.begin(),
queue.end(), timestampBeyond);
191 auto timestampBefore = [
timestamp](
const MessageType& poseStamped)
192 {
return poseStamped.timestamp <=
timestamp; };
194 const auto poseBeforeIt = std::find_if(
queue.rbegin(),
queue.rend(), timestampBefore);
229 mutable std::shared_mutex
mtx;
233 trimUntilPriv(
const size_t pos)
235 if (pos >=
queue.size())
249 const std::size_t maxQueueSize;