Skip to content

Commit

Permalink
remove seek_time_ updating on reads. This preserves current behavior …
Browse files Browse the repository at this point in the history
…and doesnt enforce weakly monotonic reads in time

Signed-off-by: Sonia Jin <diegothemuich@gmail.com>
  • Loading branch information
lihui815 committed Aug 12, 2021
1 parent 1f96553 commit 5886fa1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions rosbag2_cpp/include/rosbag2_cpp/readers/sequential_reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ class ROSBAG2_CPP_PUBLIC SequentialReader

void reset_filter() override;

/**
* seek(t) will cause subsequent reads to return messages that satisfy
* timestamp >= time t.
*/
void seek(const rcutils_time_point_value_t & timestamp) override;

/**
Expand Down
5 changes: 3 additions & 2 deletions rosbag2_cpp/src/rosbag2_cpp/readers/sequential_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,15 @@ bool SequentialReader::has_next()
throw std::runtime_error("Bag is not open. Call open() before reading.");
}

// Note: if files in the bag are not time
// normalized, it's possible to read messages that have a timestamp
// before the timestamp of the last read upon a file roll-over.
std::shared_ptr<rosbag2_storage::SerializedBagMessage> SequentialReader::read_next()
{
if (storage_) {
// performs rollover if necessary
if (has_next()) {
auto message = storage_->read_next();
// update seek time
seek_time_ = message->time_stamp;
return converter_ ? converter_->convert(message) : message;
}
throw std::runtime_error("Bag is at end. No next message.");
Expand Down

0 comments on commit 5886fa1

Please sign in to comment.