Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Messages loaded using rosbag python have incorrect type #823

Closed
felixduvallet opened this issue Jun 23, 2016 · 2 comments
Closed

Messages loaded using rosbag python have incorrect type #823

felixduvallet opened this issue Jun 23, 2016 · 2 comments

Comments

@felixduvallet
Copy link

I have found that type(msg) for a message loaded from a rosbag.Bag() does not match the actual type of the message.

For instance, a Float32 message created in a python module has type <class 'std_msgs.msg._Float32.Float32'>, but the same message loaded from a bag file has type <class 'tmpfCH1Bk._std_msgs__Float32'> (notice tmpfCH1Bk).

> Message from bag: data: 1.0. Type: <class 'tmpfCH1Bk._std_msgs__Float32'>
> New message: data: 1.0. Type: <class 'std_msgs.msg._Float32.Float32'>
> ...
> Message from bag: data: 2.0. Type: <class 'tmpfCH1Bk._std_msgs__Float32'>
> New message: data: 2.0. Type: <class 'std_msgs.msg._Float32.Float32'>
> [data: 1.0, data: 2.0]

A problem with this randomly-generated type occurs when pickling the messagess (i.e. rosbag -> pickle). After pickling, one cannot unpickle the messages since the module doesn't exist:

Traceback (most recent call last):
...
  File "/usr/lib/python2.7/pickle.py", line 1124, in find_class
    __import__(module)
ImportError: No module named tmpfCH1Bk

Note there's on exception: if you pickle and unpickle in the same instance of the interpreter, the temporary module is still defined, but that sortof goes against the point of pickling data to use later :).

Here is a MWE that reproduces this error.
https://www.dropbox.com/sh/i38kf379gmedsie/AACCe7AmdOjGCKk_aLfJmijYa?dl=0
Once the messages in the bag file get pickled, loading them from another run causes the ImportError described above.

@dirk-thomas
Copy link
Member

This sounds like a duplicate of #769.

@felixduvallet
Copy link
Author

Yes, I agree. I'll have a look and comment/contribute over there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants