ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I've implemented parsing code based on rosbag2 C++ API. Please refer my github and blog! Blog: https://kyungpyo-kim.github.io/study/ROS2-Bag-file-parsing/#getting-started

I've implemented parsing code based on rosbag2 C++ API. Please refer my github and blog! Blog: https://kyungpyo-kim.github.io/study/ROS2-Bag-file-parsing/#getting-startedYou have to deserialize "msg->serialized_data" data. If you are using data serialized "cdr" format, please look below code.

// deserialization and conversion to ros message my_pkg::msg::Msg msg; auto ros_message = std::make_shared<rosbag2_introspection_message_t>(); ros_message->time_stamp = 0; ros_message->message = nullptr; ros_message->allocator = rcutils_get_default_allocator(); ros_message->message = &msg; auto type_support = rosbag2::get_typesupport("my_pkg/msg/Msg", "rosidl_typesupport_cpp"); rosbag2::SerializationFormatConverterFactory factory; std::unique_ptr<rosbag2::converter_interfaces::serializationformatdeserializer> cdr_deserializer_; cdr_deserializer_ = factory.load_deserializer("cdr"); cdr_deserializer_->deserialize(msg, type_support, ros_message);

You have to can use rosbag2::SequentialReader package and deserialize "msg->serialized_data" data. If you are using message data serialized "cdr" format, please look below code.into ros messages.

// deserialization and conversion to ros message my_pkg::msg::Msg msg; auto ros_message = std::make_shared<rosbag2_introspection_message_t>(); ros_message->time_stamp = 0; ros_message->message = nullptr; ros_message->allocator = rcutils_get_default_allocator(); ros_message->message = &msg; auto type_support = rosbag2::get_typesupport("my_pkg/msg/Msg", "rosidl_typesupport_cpp"); rosbag2::SerializationFormatConverterFactory factory; std::unique_ptr<rosbag2::converter_interfaces::serializationformatdeserializer> cdr_deserializer_; cdr_deserializer_ = factory.load_deserializer("cdr"); cdr_deserializer_->deserialize(msg, type_support, ros_message);

You can use rosbag2::SequentialReader package to read rosbag2 data. Because bag data is serialized, you should have to deserialize that data using rosbag2::SerializationFormatConverterFactory and deserialize message data into ros messages.rosbag2::converter_interfaces.

click to hide/show revision 5
No.5 Revision

You can use rosbag2::SequentialReader rosbag2::SequentialReader package to read rosbag2 data. Because bag data is serialized, you should have to deserialize that data using rosbag2::SerializationFormatConverterFactory rosbag2::SerializationFormatConverterFactory and rosbag2::converter_interfaces.rosbag2::converter_interfaces.

Article on my blog: https://kyungpyo-kim.github.io/study/ROS2-Bag-file-parsing/#getting-started.

click to hide/show revision 6
No.6 Revision

You can use rosbag2::SequentialReader package to read rosbag2 data. Because bag data is serialized, you should have to deserialize that data using rosbag2::SerializationFormatConverterFactory and rosbag2::converter_interfaces.

Article on my blog: blog (in Korean): https://kyungpyo-kim.github.io/study/ROS2-Bag-file-parsing/#getting-started.