jmscslgroup / bagpy

Python package for reading, and extracting data from rosbag files and performing any analysis on it.
https://jmscslgroup.github.io/bagpy/
Other
207 stars 39 forks source link

Failed to load Python extension for LZ4 support #2

Closed tyagi86 closed 4 years ago

tyagi86 commented 4 years ago

Importing "bagpy" throws the following message: "Failed to load Python extension for LZ4 support. LZ4 compression will not be available."

This results in the following error when trying to read messages/topics from rosbag file: "rosbag.bag.ROSBagException: unsupported compression type: lz4"

System OS: Windows 10 Python Version: 3.8.3

rahulbhadani commented 4 years ago

Can you try installing lz4?

pip install lz4

tyagi86 commented 4 years ago

It's installed.

lz4==3.1.0

rahulbhadani commented 4 years ago

I don't have a windows machine currently, so it will be hard to debug. In Ubuntu "Failed to load Python extension for LZ4 support. LZ4 compression will not be available." is a warning and yet it runs. You can provide a minimum viable code snippet to reproduce your issue and that may help.

rahulbhadani commented 4 years ago

@tyagi86 I have a suggestion on reading bag files. You can use Google Colab if you don't have access to Linux. See the example: https://colab.research.google.com/drive/1ZNeVcYmvd6WHgXvdfi-MD6pdZAjWTyqZ?usp=sharing

julienguegan commented 4 years ago

Hello, if someone have a solution on windows I would be also interested !

I have multiples files of ~2/3 GB to read so google colab does not seem to be a good solution as I would have to upload them ...

rahulbhadani commented 4 years ago

@tyagi86 @julienguegan I checked on a Windows system.

  1. Here are the following steps that I performed:
  2. I installed Anaconda and ran its Jupyter Server. Then in the notebook, I installed bagpy using the following command:
!pip install bagpy --user
  1. Restarted the kernel and executed the following code:
import bagpy
import pandas as pd
from bagpy import bagreader
b = bagreader("C:\\Users\\rahulbhadani\\Downloads\\2019-10-11-19-42-06.bag")
speed_file = b.message_by_topic('/vehicle/vel')
speed = pd.read_csv(speed_file)

fig, ax = bagpy.create_fig(1)
ax[0].scatter( x = 'Time', y = 'twist.linear.x', data = speed, s = 3, marker = 'o', label = 'Original Speed')
ax[0].legend()
ax[0].set_xlabel('Time')
ax[0].set_ylabel('m/s')
fig.show()

and I was able to see the plot I was expecting.

Note that I still get Failed to load Python extension for LZ4 support. LZ4 compression will not be available., but that's just a warning and it didn't hinder me from doing any downstream analysis.

rahulbhadani commented 4 years ago

Also, @tyagi86 @julienguegan Do an update of a package

!pip install -U py3rosmsgs

and the warning/error message will go away.

rahulbhadani commented 4 years ago

One final thing. If your bag file uses lz4 compression, then in Windows, bagpy will not be able to decode that, as .so file for lz4 compression works only on Linux. For windows, an equivalent of .so compression is .dll file. Generating a .dll file is beyond the scope of my package. However, you can install the Ubuntu subsystem on windows and still be able to read .bag file from the Ubuntu subsystem.

With that, I am closing this issue.

TIAN-Xiao commented 1 year ago

try this: pip install roslz4 --extra-index-url https://rospypi.github.io/simple/