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

[ROS2] bag API

asked 2019-04-22 16:18:37 -0500

vadbut gravatar image


I'm trying to find a way to process a ros2 bag, but at the moment it appears there is no API implemented yet to parse it like it was possible in ROS1 ( ).

What is the best way to deal with it right now? Should I just make a parsing node that grabs data from topic during replay and stores it as a csv?


edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2020-03-13 11:03:55 -0500

kyungpyo gravatar image

updated 2020-03-18 03:16:42 -0500

gvdhoorn gravatar image

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 (in Korean):

edit flag offensive delete link more


Putting the main points here in the answer would be the normal protocol (and be especially helpful for those who don't read Korean). Should the blog post disappear, then this answer would not be helpful for the users of this site.

jayess gravatar image jayess  ( 2020-03-13 14:21:16 -0500 )edit

Modified following your comment. Thanks!

kyungpyo gravatar image kyungpyo  ( 2020-03-13 17:41:13 -0500 )edit

@kyungpyo I tried to use your c++ node and I get the following error:

terminate called after throwing an instance of 'eprosima::fastcdr::exception::NotEnoughMemoryException'
  what():  Not enough memory in the buffer stream

I use my own bag for this and I have changed the msg type to look for nav_msgs/msg/Odometry. Have you seen this error occur before?

DanielRobotics gravatar image DanielRobotics  ( 2020-04-24 06:21:49 -0500 )edit

Unfortunately, exactly what was predicted by @jayess is the case now: the original article disappeared. @kyungpyo: Would it be possible to post more detailed instructions in english on how to achieve the reading of rosbag2 data in the proposed way? Maybe some small sample code would be really helpful for a lot of people... Thanks in advance!

sttobia gravatar image sttobia  ( 2021-01-05 11:26:09 -0500 )edit

And there's no archive of it at the Internet Archive either

jayess gravatar image jayess  ( 2021-01-05 18:31:30 -0500 )edit

I +100 the point about including the important parts of the article in the answer itself, for the aforementioned reasons.

However, the article is still available: ROS2 Bag File Parsing 하기.

gvdhoorn gravatar image gvdhoorn  ( 2021-01-06 02:40:03 -0500 )edit

Actually my article is very personal project and I can't move it to in English now...(I am very busy these days... really sorry for that and late reply...) As @gvdhoorn mentioned you can find my article at new page.

But I think it is better to see example API source code:

kyungpyo gravatar image kyungpyo  ( 2021-02-02 17:59:01 -0500 )edit

Question Tools



Asked: 2019-04-22 16:18:37 -0500

Seen: 2,529 times

Last updated: Mar 18 '20