ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Python pickling with ros msgs

asked 2012-10-01 06:18:09 -0600

Ammar gravatar image

updated 2012-10-03 05:16:50 -0600

Hello Community, I am transmitting custom ros msgs through a ZeroMQ protocol over a network. In order to create a data stream that I can send, I use the pickle method within Python. It works perfectly when I pass and receive over localhost. However when it is unicasted to a remote machine I am unable to load it back using pickle.loads(message). I get the following error:

ImportError: No module named genpy.rostime

This is really puzzling me since I believe genpy is a part of roslib and I have imported roslib. I also imported other necessary modules like pickle, rospy etc. Has anyone used pickle to package and parse ros msgs ? I would appreciate any help or suggestions. Thank you, Ammar

EDIT: So I was experimenting with a bunch of different serialization methods to broadcast a custon ros msg over a network. However all of them give the error 'No module name genpy.rostime' during deserialization... The most recent method I am using is: initializing a ros msg using socket.send_pyobj() on the other machine: socket.recv_pyobj() --> This is where it errors out because it cannot find genpy.rostime

I am absolutely sure it is nothing with ZeroMQ (my communication protocol) since it can deserialize other python objects perfectly. Could some one please help me figure out how to deserialize ros msg objects in Python? I am completely lost

edit retag flag offensive close merge delete



Serious question: why? Why are you using fully three different serialization tools? Can you explain the problem you're trying to solve?

Mac gravatar image Mac  ( 2012-10-01 13:51:32 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2012-10-03 09:15:50 -0600

Ammar gravatar image

I figured out what the problem was!!! Basically in my ros msg type I was inheriting the PoseStamped msg from geometry_msgs. So on one of my machine the common_msgs (or geometry_msgs) package was from ROS Fuerte and the other had ROS Electric. There is probably (actually definitely) some difference in the msg definitions between the 2 versions, causing a mismatch when a Fuerte PoseStamped msg was being deserialized referencing an Electric PoseStamped msg. Thus the ERROR: No module name genpy.rostime

What is bothering is the fact that the Error said very very little about the actual problem it faced deserializing (NOT ROS's fault anyway), but such is life. Anyways please be careful mixing Electric and Fuerte, it could be dangerous.

edit flag offensive delete link more

Question Tools


Asked: 2012-10-01 06:18:09 -0600

Seen: 1,795 times

Last updated: Oct 03 '12