18 #ifndef LOCALIZATION_ANALYSIS_MESSAGE_BUFFER_H_
19 #define LOCALIZATION_ANALYSIS_MESSAGE_BUFFER_H_
30 template <
typename MessageType>
37 if (last_measurement_time_ && std::abs(*last_measurement_time_ - timestamp) < params_.
min_msg_spacing) {
38 LOG(WARNING) <<
"BufferMessage: Dropping message that arrived too close to previous message.";
41 msg_buffer_.emplace(timestamp, msg);
42 last_measurement_time_ = timestamp;
46 if (msg_buffer_.empty())
return boost::none;
47 if (current_time - msg_buffer_.cbegin()->first < params_.
msg_delay) {
48 VLOG(2) <<
"GetMessage: Current time too close to message time, no message available.";
51 const auto msg = msg_buffer_.cbegin()->second;
52 msg_buffer_.erase(msg_buffer_.begin());
58 std::map<localization_common::Time, MessageType> msg_buffer_;
59 boost::optional<localization_common::Time> last_measurement_time_;
63 #endif // LOCALIZATION_ANALYSIS_MESSAGE_BUFFER_H_