Use the timestamp delivery time to reconstruct time
Don't waste the data!
This exposes an issue in sim (and real life). It takes time between
when a message was sent and when it was forwarded. Timestamp messages
don't have this delay, so they end up dominating the estimate. This
causes time estimation to not be absolutely perfect when replaying
simulation, but it is close enough nobody would notice. Steady state, I
think this is actually benificial behavior.
Change-Id: I85a1e69d47ea09cc61abf82789bcc3b55981f1db
diff --git a/aos/events/logging/logger.cc b/aos/events/logging/logger.cc
index 2dd4701..7e822de 100644
--- a/aos/events/logging/logger.cc
+++ b/aos/events/logging/logger.cc
@@ -333,8 +333,7 @@
for (const Node *node : log_namer_->nodes()) {
const int node_index = configuration::GetNodeIndex(configuration_, node);
- node_state_[node_index].log_file_header =
- MakeHeader(node, config_sha256);
+ node_state_[node_index].log_file_header = MakeHeader(node, config_sha256);
}
// Grab data from each channel right before we declare the log file started
@@ -2027,8 +2026,7 @@
if (scheduled_time_ != remote_timestamps_.front().monotonic_timestamp_time) {
CHECK_NOTNULL(timer_);
- timer_->Setup(
- remote_timestamps_.front().monotonic_timestamp_time);
+ timer_->Setup(remote_timestamps_.front().monotonic_timestamp_time);
scheduled_time_ = remote_timestamps_.front().monotonic_timestamp_time;
}
}
@@ -2098,8 +2096,8 @@
SeedSortedMessages();
if (std::get<1>(result) != nullptr) {
- std::get<1>(result)->Pop(
- event_loop_->node(), std::get<0>(result).monotonic_event_time);
+ std::get<1>(result)->Pop(event_loop_->node(),
+ std::get<0>(result).monotonic_event_time);
}
return std::move(std::get<0>(result));
}
@@ -2161,6 +2159,16 @@
filter->Sample(event_loop_->node(),
timestamped_message.monotonic_event_time,
timestamped_message.monotonic_remote_time);
+
+ if (timestamped_message.monotonic_timestamp_time !=
+ monotonic_clock::min_time) {
+ // TODO(austin): This assumes that this timestamp is only logged on the
+ // node which sent the data. That is correct for now, but should be
+ // explicitly checked somewhere.
+ filter->ReverseSample(event_loop_->node(),
+ timestamped_message.monotonic_event_time,
+ timestamped_message.monotonic_timestamp_time);
+ }
}
sorted_messages_.emplace_back(std::move(timestamped_message), filter);
}