Skip to content

Commit

Permalink
Address code difference between Humble and Rolling
Browse files Browse the repository at this point in the history
- Humble doesn't have `recv_timestamp` and `send_timestamp`. Replaced
them with ordinary `time_stamp`.

Signed-off-by: Michael Orlov <[email protected]>
  • Loading branch information
MichaelOrlov committed Nov 22, 2024
1 parent 0919d48 commit b292af5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions rosbag2_cpp/src/rosbag2_cpp/writers/sequential_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,9 +462,9 @@ void SequentialWriter::write_messages(
if (storage_options_.snapshot_mode) {
// Update FileInformation about the last file in metadata in case of snapshot mode
const auto first_msg_timestamp = std::chrono::time_point<std::chrono::high_resolution_clock>(
std::chrono::nanoseconds(messages.front()->recv_timestamp));
std::chrono::nanoseconds(messages.front()->time_stamp));
const auto last_msg_timestamp = std::chrono::time_point<std::chrono::high_resolution_clock>(
std::chrono::nanoseconds(messages.back()->recv_timestamp));
std::chrono::nanoseconds(messages.back()->time_stamp));
metadata_.files.back().starting_time = first_msg_timestamp;
metadata_.files.back().duration = last_msg_timestamp - first_msg_timestamp;
metadata_.files.back().message_count = messages.size();
Expand Down
9 changes: 4 additions & 5 deletions rosbag2_cpp/test/rosbag2_cpp/test_sequential_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,8 +529,7 @@ TEST_F(SequentialWriterTest, snapshot_writes_to_new_file_with_bag_split)
std::vector<rosbag2_storage::SerializedBagMessageSharedPtr> messages;
for (size_t i = 0; i < num_msgs_to_write; i++) {
auto message = std::make_shared<rosbag2_storage::SerializedBagMessage>();
message->recv_timestamp = first_msg_timestamp + static_cast<rcutils_time_point_value_t>(i);
message->send_timestamp = first_msg_timestamp + static_cast<rcutils_time_point_value_t>(i);
message->time_stamp = first_msg_timestamp + static_cast<rcutils_time_point_value_t>(i);
message->topic_name = topic_name;
message->serialized_data =
rosbag2_storage::make_serialized_message(msg_content.c_str(), msg_content.length());
Expand All @@ -540,7 +539,7 @@ TEST_F(SequentialWriterTest, snapshot_writes_to_new_file_with_bag_split)
// Expect a single write call when the snapshot is triggered
EXPECT_CALL(
*storage_, write(
An<const std::vector<std::shared_ptr<const rosbag2_storage::SerializedBagMessage>> &>())
An<const std::vector<std::shared_ptr<const rosbag2_storage::SerializedBagMessage>> &>())
).Times(1);

ON_CALL(
Expand Down Expand Up @@ -629,7 +628,7 @@ TEST_F(SequentialWriterTest, snapshot_writes_to_new_file_with_bag_split)
EXPECT_EQ(first_file_info.message_count, num_expected_msgs);
EXPECT_EQ(
std::chrono::time_point_cast<std::chrono::nanoseconds>(
first_file_info.starting_time).time_since_epoch().count(),
first_file_info.starting_time).time_since_epoch().count(),
expected_start_time);
EXPECT_EQ(first_file_info.duration.count(), expected_duration);
}
Expand All @@ -644,7 +643,7 @@ TEST_F(SequentialWriterTest, snapshot_can_be_called_twice)
// Expect to call write method twice. Once per each snapshot.
EXPECT_CALL(
*storage_, write(
An<const std::vector<std::shared_ptr<const rosbag2_storage::SerializedBagMessage>> &>())
An<const std::vector<std::shared_ptr<const rosbag2_storage::SerializedBagMessage>> &>())
).Times(2);

ON_CALL(*storage_, get_relative_file_path).WillByDefault(
Expand Down

0 comments on commit b292af5

Please sign in to comment.