Skip to content

Commit

Permalink
Removed deprecated write method (#1738)
Browse files Browse the repository at this point in the history
Signed-off-by: Alejandro Hernández Cordero <[email protected]>
  • Loading branch information
ahcorde authored Jul 8, 2024
1 parent 8f77d4e commit e860f65
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 73 deletions.
22 changes: 0 additions & 22 deletions rosbag2_cpp/include/rosbag2_cpp/writer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,28 +159,6 @@ class ROSBAG2_CPP_PUBLIC Writer
const std::string & type_name,
const std::string & serialization_format = "cdr");

/**
* Write a serialized message to a bagfile.
* The topic will be created if it has not been created already.
*
* \param message rclcpp::SerializedMessage The serialized message to be written to the bagfile
* \param topic_name the string of the topic this messages belongs to
* \param type_name the string of the type associated with this message
* \param time The time stamp of the message
* \throws runtime_error if the Writer is not open or duplicating message is failed.
*/
[[deprecated(
"Use write(std::shared_ptr<rclcpp::SerializedMessage> message," \
" const std::string & topic_name," \
" const std::string & type_name," \
" const rclcpp::Time & time) instead."
)]]
void write(
const rclcpp::SerializedMessage & message,
const std::string & topic_name,
const std::string & type_name,
const rclcpp::Time & time);

/**
* Write a serialized message to a bagfile.
* The topic will be created if it has not been created already.
Expand Down
51 changes: 0 additions & 51 deletions rosbag2_cpp/src/rosbag2_cpp/writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,57 +129,6 @@ void Writer::write(
write(message);
}

void Writer::write(
const rclcpp::SerializedMessage & message,
const std::string & topic_name,
const std::string & type_name,
const rclcpp::Time & time)
{
auto serialized_bag_message = std::make_shared<rosbag2_storage::SerializedBagMessage>();
serialized_bag_message->topic_name = topic_name;
serialized_bag_message->recv_timestamp = time.nanoseconds();
serialized_bag_message->send_timestamp = time.nanoseconds();

serialized_bag_message->serialized_data = std::shared_ptr<rcutils_uint8_array_t>(
new rcutils_uint8_array_t,
[](rcutils_uint8_array_t * msg) {
auto fini_return = rcutils_uint8_array_fini(msg);
delete msg;
if (fini_return != RCUTILS_RET_OK) {
RCLCPP_ERROR_STREAM(
rclcpp::get_logger("rosbag2_cpp"),
"Failed to destroy serialized message: " << rcutils_get_error_string().str);
}
});

// While using compression mode and cache size isn't 0, another thread deals with this serialized
// message asynchronously.
// In order to keep serialized message valid, have to duplicate message.

rcutils_allocator_t allocator = rcutils_get_default_allocator();

rcutils_ret_t ret = rcutils_uint8_array_init(
serialized_bag_message->serialized_data.get(),
message.get_rcl_serialized_message().buffer_capacity,
&allocator);
if (ret != RCUTILS_RET_OK) {
auto err = std::string("Failed to call rcutils_uint8_array_init(): return ");
err += ret;
throw std::runtime_error(err);
}

std::memcpy(
serialized_bag_message->serialized_data->buffer,
message.get_rcl_serialized_message().buffer,
message.get_rcl_serialized_message().buffer_length);

serialized_bag_message->serialized_data->buffer_length =
message.get_rcl_serialized_message().buffer_length;

return write(
serialized_bag_message, topic_name, type_name, rmw_get_serialization_format());
}

void Writer::write(
std::shared_ptr<const rclcpp::SerializedMessage> message,
const std::string & topic_name,
Expand Down

0 comments on commit e860f65

Please sign in to comment.