Registry / devops / bagpy
library0.5pypypi✓ verified 84d ago

A Python class to facilitate reading ROS bag files based on semantic datatypes. Version 0.5 is the latest release. Development appears slow; the library provides a convenient wrapper around rosbag for semantic topic reading.

pip install bagpy
INSTALL
IMPORT
SIG · BAGPY
B
bagpy
devopspythonv0.5
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

bagreader
from bagpy import bagreader
import bagpy
bagreader is the main class; direct import of bagpy is not useful.

Quick example to read a ROS bag file and extract topic data into a pandas DataFrame.

from bagpy import bagreader import pandas as pd b = bagreader('sample.bag') # list all topics for t in b.topics: print(t) # read a specific topic (e.g., '/odom') data = b.message_by_topic('/odom') df = pd.DataFrame(data) print(df.head())
Debug
Known issues
gotchabagreader expects a bag file path string; it does not resolve ROS package paths.
fix
Provide the absolute or relative path to the .bag file.
affects: <=0.5
gotchamessage_by_topic returns a list of dictionaries, not a ros message object.
fix
Expect dicts; convert to DataFrame or process accordingly.
affects: <=0.5
deprecatedThe library depends on rosbag and rospy, which are ROS1 tools. ROS1 is deprecated in favor of ROS2.
fix
Consider using ROS2-compatible libraries or rosbags for cross-version support.
affects: all
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'rosbag'
Rosbag is not installed; it requires a ROS environment.
fix
Install ROS1 (e.g., 'sudo apt install ros-<distro>-rosbag') or use a docker container with ROS.
AttributeError: 'bagreader' object has no attribute 'topics'
bagreader initialization may have failed; check file path correctness.
fix
Verify the bag file exists and is accessible: 'b = bagreader(path)' prints error if file not found.
Upgrade
Version history
0.5latest on PyPI · released Oct 16, 2022
Audit
Dependencies
rosbagrequiredCore dependency for reading ROS bag files
rospyrequiredRequired for ROS message types
Agent activity
7 hits · last 30 days
node
6
Resources
bagpy — pip install bagpy · libregistry