0
$\begingroup$

Rosanswers logo

I want to be able to parse out bag files. I don't need to produce or change the bag files just read and parse them so I can use the data downstream in a couple of different systems/formats.

Using python is fine, and I am just trying to run this: import rosbag bag = rosbag.Bag('myfile.bag') for topic, msg, t in bag.read_messages(topics=['chatter', 'numbers']): print msg bag.close()

However, I can't seem to find a way to install the rosbag package.

I've tried variations of pip install rosbag.

From reading I see if I was on Ubuntu I should: sudo apt-get install python-rosbag

I don't have Ubuntu. Ideally I'd like to do this on CentOS and/or Mac OSX.

Of course, in testing on OSX, there's no apt-get and doesn't seem to be any homebrew equivalent...

Again I don't want to have to completely install ROS, just the python libs to parse the bag files.


Originally posted by JohnH on ROS Answers with karma: 13 on 2020-02-04

Post score: 1

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Use the custom/experimental Pypi index from rospypi/simple:

virtualenv -p python3 venv
source ./venv/bin/activate
pip install --extra-index-url https://rospypi.github.io/simple/ rospy rosbag

A couple of others packages might also come in handy, but that depends on what you want to do.

Also works with Python 2.

On Windows, Linux and most likely OSX as well (but I haven't tested it).

Related ROS Discourse post: Experimental Python package index for ROS.


Edit:

Again I don't want to have to completely install ROS, just the python libs to parse the bag files.

seeing where you're registering from, you may be interested in this company which offers data analytics interopability tools for working with .bags (presentation at the ROS-I Conference 2019, and video recording).

I have no commercial interest here, just linking to a presentation I attended at the ROS-I Conf19 last year.


Originally posted by gvdhoorn with karma: 86574 on 2020-02-04

This answer was ACCEPTED on the original site

Post score: 3


Original comments

Comment by JohnH on 2020-02-04:
That worked. Thank you!

Comment by Kansai on 2020-08-11:
After doing this, I got the error Failed to load Python extension for LZ4 support. LZ4 compression will not be available

Comment by gvdhoorn on 2020-08-11:
You'll want to discuss this with the maintainer of rospypi/simple.

Comment by rajkundu on 2021-04-06:
I used the following to get rosbag working on macOS 10.15.7 Catalina with Python 3.8.5:

  1. brew install lz4
  2. brew install boost-python3
  3. pip install --extra-index-url https://rospypi.github.io/simple/ rospy rosbag roslz4 cv-bridge
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.