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 13, 2021
1 parent 79341a8 commit fde201b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 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
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class ROSBAG2_STORAGE_PUBLIC ReadOnlyInterface
{
return StorageTraits<ReadOnlyInterface>::name;
}

/**
Seeks to a given timestamp. Running read_next() after seek(t)
will return a message that is equal to or after time t. Running read_next()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class ROSBAG2_STORAGE_PUBLIC ReadWriteInterface
{
return StorageTraits<ReadWriteInterface>::name;
}

void seek(const rcutils_time_point_value_t & timestamp) override = 0;
};

Expand Down

0 comments on commit fde201b

Please sign in to comment.