Skip to content

[Python] Extend API to obtain the msg_count of a given topic in a .mcap file #1110

Closed Answered by jtbandes
nachovizzo asked this question in General
Discussion options

You must be logged in to vote

The rosbag2 python API get_metadata() was added in ros2/rosbag2#1082 and should be available in Rolling and the next major ROS release.

Using the mcap python API directly, you can do this:

>>> from mcap.reader import make_reader
>>> reader = make_reader(open("/path/to/file.mcap", "rb"))
>>> summary = reader.get_summary()

>>> summary.statistics
Statistics(attachment_count=0, channel_count=7, channel_message_counts={0: 52, 1: 234, 2: 774, 3: 156, 4: 156, 5: 156, 6: 78}, chunk_count=14, message_count=78, message_end_time=1490149587884601617, message_start_time=1490149580103843113, metadata_count=0, schema_count=7)

# NOTE: this code does not handle the case where 2 different channel IDs ref…

Replies: 0 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by defunctzombie
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
2 participants