Standalone rosbag loader for python3
Project description
importRosbag
Import rosbag data - pure python - standalone - no ROS installation required.
The importRosbag function imports a .rosbag file. Use the 'filePathOrName' parameter to supply the path. e.g.
from importRosbag.importRosbag import importRosbag
topics = importRosbag(filePathOrName='path/to/data.bag')
A rosbag consists of a set of topics, each of which has a set of messages. A topic has a name, which was defined by the creator, and a message type, which is standard and defines the content of each message. This function uses the topic types to interpret the messages from each topic, yielding one dict for each topic. Each of these dicts contains an iterable for each data field.
By default this function unpacks all topics for which it has a message type definition, but you can use one of the following keyword params to limit which topics are intepretted:
- 'listTopics' = True - no unpacking - just returns a list of the topics contained in the file and their associated types - use this to quickly inspect the contents of a bag;
- 'importTopics' = - only imports the listed topics;
- 'importTypes' = - only imports the listed types.
Example usage:
# Import everything
topics = importRosbag(filePathOrName='path/to/data.bag')
# Or just list the topics in the bag
topics = importRosbag(filePathOrName='path/to/data.bag', listTopics=True)
# Or just import one particular topic
importTopics = ['/dvs/camera_info']
topics = importRosbag(filePathOrName='path/to/data.bag', importTopics=importTopics)
# Or just import two particular types - Note that slash and underscore are interchangable
importTypes = ['esim_msgs_OpticFlow', 'geometry_msgs/PoseStamped']
topics = importRosbag(filePathOrName='path/to/data.bag', importTypes=importTypes)
Message types supported are a selection of standard message types, plus a couple related to event-based sensors:
Standard:
- geometry_msgs/PoseStamped
- geometry_msgs/Transform
- geometry_msgs/TransformStamped
- geometry_msgs/TwistStamped
- sensor_msgs/CameraInfo
- sensor_msgs/Image
- sensor_msgs/Imu
- sensor_msgs/PointCloud2
- tf/tfMessage
Specialised:
- dvs_msgs/EventArray
- esim_msgs/OpticFlow
The method of importation is honed to the particular needs of the author, sometimes ignoring certain fields, grouping data in particular ways etc. For example, from the CameraInfo message type we import only a single message because we're not currently interested in autocalibration or its results. However this code should serve as a model for anyone who wishes to import rosbags. Although it's possible to import messages programmatically given only the message definition files, we have chosen not to do this, because if we did it we would anyway want to take the resulting data and pick out the bits we wanted.
Timestamps: We convert timestamps to 64-bit floats. This won't work for you if you care about sub-microsecond precision, for any timestamps encoded as unix time.
Quaternions: Attention! If you import any of the types which encode rotations as quaternions, e.g. PoseStamped/Transform/TransformStamped/tfMessage: we import quaternions in the form w,x,y,z, which is the convention in certain software, like blender; however, in the rosbag, the native form is x,y,z,w.
Dependencies:
- numpy
- tqdm
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file importRosbag-1.0.4.tar.gz
.
File metadata
- Download URL: importRosbag-1.0.4.tar.gz
- Upload date:
- Size: 13.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.17
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f09a153a14cfa563810d6b5c3f26153c9320f81f0d82a6671bf8b5cd49350aa |
|
MD5 | 7b71b6fd4fcc725caeec325dfb35974f |
|
BLAKE2b-256 | d69bfd50cf899b702e7f75e424bc06ff51945cae79f0cdd80faad8d7ba5f4b39 |
File details
Details for the file importRosbag-1.0.4-py3-none-any.whl
.
File metadata
- Download URL: importRosbag-1.0.4-py3-none-any.whl
- Upload date:
- Size: 28.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.17
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 843db058e85d23ef7376ea47490bf453cd8b31ea880b24edf2408f2ff4e2eb51 |
|
MD5 | 6b5b317c96cf02a0a211fc93b798bb12 |
|
BLAKE2b-256 | c4ce04f383b0e250846ab1702caf1d71e6291b56351f98244a78862d072fc4a6 |