Skip to content

Commit b292af5

Browse files
committed
Address code difference between Humble and Rolling
- Humble doesn't have `recv_timestamp` and `send_timestamp`. Replaced them with ordinary `time_stamp`. Signed-off-by: Michael Orlov <[email protected]>
1 parent 0919d48 commit b292af5

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

Diff for: rosbag2_cpp/src/rosbag2_cpp/writers/sequential_writer.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -462,9 +462,9 @@ void SequentialWriter::write_messages(
462462
if (storage_options_.snapshot_mode) {
463463
// Update FileInformation about the last file in metadata in case of snapshot mode
464464
const auto first_msg_timestamp = std::chrono::time_point<std::chrono::high_resolution_clock>(
465-
std::chrono::nanoseconds(messages.front()->recv_timestamp));
465+
std::chrono::nanoseconds(messages.front()->time_stamp));
466466
const auto last_msg_timestamp = std::chrono::time_point<std::chrono::high_resolution_clock>(
467-
std::chrono::nanoseconds(messages.back()->recv_timestamp));
467+
std::chrono::nanoseconds(messages.back()->time_stamp));
468468
metadata_.files.back().starting_time = first_msg_timestamp;
469469
metadata_.files.back().duration = last_msg_timestamp - first_msg_timestamp;
470470
metadata_.files.back().message_count = messages.size();

Diff for: rosbag2_cpp/test/rosbag2_cpp/test_sequential_writer.cpp

+4-5
Original file line numberDiff line numberDiff line change
@@ -529,8 +529,7 @@ TEST_F(SequentialWriterTest, snapshot_writes_to_new_file_with_bag_split)
529529
std::vector<rosbag2_storage::SerializedBagMessageSharedPtr> messages;
530530
for (size_t i = 0; i < num_msgs_to_write; i++) {
531531
auto message = std::make_shared<rosbag2_storage::SerializedBagMessage>();
532-
message->recv_timestamp = first_msg_timestamp + static_cast<rcutils_time_point_value_t>(i);
533-
message->send_timestamp = first_msg_timestamp + static_cast<rcutils_time_point_value_t>(i);
532+
message->time_stamp = first_msg_timestamp + static_cast<rcutils_time_point_value_t>(i);
534533
message->topic_name = topic_name;
535534
message->serialized_data =
536535
rosbag2_storage::make_serialized_message(msg_content.c_str(), msg_content.length());
@@ -540,7 +539,7 @@ TEST_F(SequentialWriterTest, snapshot_writes_to_new_file_with_bag_split)
540539
// Expect a single write call when the snapshot is triggered
541540
EXPECT_CALL(
542541
*storage_, write(
543-
An<const std::vector<std::shared_ptr<const rosbag2_storage::SerializedBagMessage>> &>())
542+
An<const std::vector<std::shared_ptr<const rosbag2_storage::SerializedBagMessage>> &>())
544543
).Times(1);
545544

546545
ON_CALL(
@@ -629,7 +628,7 @@ TEST_F(SequentialWriterTest, snapshot_writes_to_new_file_with_bag_split)
629628
EXPECT_EQ(first_file_info.message_count, num_expected_msgs);
630629
EXPECT_EQ(
631630
std::chrono::time_point_cast<std::chrono::nanoseconds>(
632-
first_file_info.starting_time).time_since_epoch().count(),
631+
first_file_info.starting_time).time_since_epoch().count(),
633632
expected_start_time);
634633
EXPECT_EQ(first_file_info.duration.count(), expected_duration);
635634
}
@@ -644,7 +643,7 @@ TEST_F(SequentialWriterTest, snapshot_can_be_called_twice)
644643
// Expect to call write method twice. Once per each snapshot.
645644
EXPECT_CALL(
646645
*storage_, write(
647-
An<const std::vector<std::shared_ptr<const rosbag2_storage::SerializedBagMessage>> &>())
646+
An<const std::vector<std::shared_ptr<const rosbag2_storage::SerializedBagMessage>> &>())
648647
).Times(2);
649648

650649
ON_CALL(*storage_, get_relative_file_path).WillByDefault(

0 commit comments

Comments
 (0)